Description Usage Arguments Value Examples
Transform an XML document with an XSLT stylesheet
1 | xslt_transform(xml_doc, xslt_doc, is_html = FALSE, fix_ns = FALSE)
|
xml_doc |
an XML or HTML document (either a string with XML/HTML, a filename
or URL pointing to a file wiht XML/HTML). This can also be the result
of a value returned from |
xslt_doc |
an XSLT document (either a string with XML/XSLT, a filename
or URL pointing to a file wiht XML/XSLT). This can also be the result
of a value returned from |
is_html |
is |
fix_ns |
intercourse the namespaces (highly useful for HTML processing - default |
Either objects comparable to xml2::read_xml
or xml2::read_html
(if the
XSLT output method was xml
or html
respectively) or a single-element
character vector with the transformed document text.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(xml2)
library(xslt)
xml_src <- "<test/>"
xslt_src <- '<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<article>
<title>Hello World</title>
</article>
</xsl:template>
</xsl:stylesheet>'
doc <- read_xml(xml_src)
xsl <- read_xslt(xslt_src)
res <- xslt_transform(doc, xsl)
cat(as.character(res))
res <- xslt_transform(xslt_src, xslt_src)
cat(as.character(res))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.