saveXML: Serializes XSLT-processed document to a file or string

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This method for saveXML writes the XML document stored in the XMLInternalXSLTDocument object either to a file or to an S string (character vector of length 1).

Usage

1
2
3
4
## S3 method for class 'XMLInternalXSLTDocument'
saveXML(doc, file = NULL, compression = 0,
                                indent = TRUE, prefix = "<?xml version=\"1.0\"?>\n", 
                                doctype = NULL, encoding = "", ...)

Arguments

doc

an object of (S3-style) class XMLInternalXSLTDocument which contains both the XML document reference and the XSLT stylesheet reference. This is typically obtained from a call to xsltApplyStyleSheet.

file

if non-NULL, this is taken to be a string giving the name of the file to which the XML is written. If this is NULL, the XML is written to a string and returned to the caller.

compression

an integer value between 0 and 9 giving the compression level to use when writing the XML to a file. This is ignored if file is NULL.

indent

ignored, but here for compatability with the saveXML generic function in the XML package.

prefix

inherited from the generic function definition and ignored

doctype

inherited from the generic function definition and ignored

encoding

the character string giving the choice of encoding, e.g. "UTF-8", "Latin1".

...

additional parameters pased to methods

Details

This does not use the same mechanism for serializing a XML document as is used in the XML package.

Value

If file is NULL, the result is an S string containing the document. If file is the name of a file, TRUE is returned if the serialization was successful. Otherwise and error is thrown.

Note

In the future, this can be made to support S connections.

Author(s)

Duncan Temple Lang <[email protected]>

References

http://www.omegahat.org/Sxslt, http://www.omegahat.org/SXalan, http://www.w3.org/Style/XSL http://xmlsoft.org/XSLT htt

See Also

saveXML xsltApplyStyleSheet xsltParseStyleSheet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 library(XML)

 doc <- xsltApplyStyleSheet(system.file("examples", "register.xml", package = "Sxslt"),
                            system.file("examples", "register.xsl", package = "Sxslt"), FALSE)

 cat(saveXML(doc))

 outFile <- tempfile()
 saveXML(doc$doc, outFile)

  # to an R string
 saveXML(doc)

## Not run: 
# These files won't exist. Will fix up the example soon!
 sheet <- xsltParseStyleSheet("../../../Literate/fragment.xsl")
 doc <- xsltApplyStyleSheet("../../../RSXMLObjects/Src/writeRS.xml", sheet)

 cat(saveXML(doc))

 saveXML(doc, "/tmp/foo.xml")

## End(Not run)

sckott/sxslt documentation built on May 26, 2017, 3:49 a.m.