Reputation: 415
I am doing some small transformations to xml files using xslt (xsltproc specifically, but should be irrelevant, right?). With the output tag I can control stuff like the encoding, or if it is going to be a standalone xml file. For example:
<xsl:output indent="yes" encoding="UTF-8"/>
But what if I want to preserve the encoding, or if it is standalone on different inputs? Where some of those inputs might be differently encoded, or some standalone xml files, some not. Since the header tag of the xml file is handled differently, not as part of the tree, I cannot access anything of it. Is there a way of doing this, or is this outside the scope of xslt?
Upvotes: 0
Views: 362
Reputation: 122364
It's outside the scope of XSLT - XSLT operates on the XDM (XPath Data Model) tree structure of the parsed document, it doesn't know about things like the encoding of the original XML (or even whether the tree was originally parsed from a stream of bytes or constructed programmatically), whether particular characters were represented as literals (>
), entity references (>
) or character references (>
), whitespace between attributes within a start tag, the order in which attributes appear, etc.
Upvotes: 1