XML Processing Functions {odfWeave}R Documentation

XML Processing Functions

Description

These function takes a character vector of XML for the Open Document Format and process it it various ways.

odfTranslate converts some XML modified characters (such as &gt) to R code (>). This function also tries to mistake proof the code by anticipating characters that might be in UTF-8 encoding to R compliant characters (e.g. OpenOffice may convert some characters. For example, " will become a UTF-8 character, which R will choke on).

stripXmlTag removes any text between "<" and ">" and optionally remove leading or trailing whitespace.

processInLine uses odfTranslate and stripXmlTag to process in-line Sweave statements. Similarly, xml2R does the same thing for code chunks.

Usage

odfTranslate(x, toR = TRUE)
stripXmlTag(x, leadWhite = FALSE, endWhite = FALSE)
processInLine(x, matches)
xml2R(x)

Arguments

x a character vector
toR a logical. If TRUE, the text is translated from XML to R. The opposite is done if FALSE.
leadWhite a logical for removing leading white space
endWhite a logical for removing tailing white space
matches an integer vector with the character positions of any Sweave tags. matches must contain attributes match.length and match.type which are the length of the tag and the type (e.g. "sepxr"), respectively

Value

a character vector

Author(s)

Max Kuhn and Nathan Coulter

Examples


x <- "   <text:p text:style-name=\"P3\"><text:s text:c=\"3\"/>lm(y~x)</text:p>"
y <- "\Sexpr{paste(letters[1:5], <text:s text:c=\"2\"/>collapse = &quot;,&quot;)}"
z <- " <text:span text:style-name=\"T1\">\Sexpr{x &gt; 2}</text:span>"

stripXmlTag(x)
odfTranslate(y)
xml2R(y)
#processInLine(z)

[Package odfWeave version 0.4.9 Index]