2
votes

What would be the effect of using different encodings with xml documents and xslt.

The xslt stylesheet would have the output encoding UTF-8, the input xml will have not encoding declared and will be generated using a string, inside the xslt will be:

<xsl:variable name="doc" select="document('file.xml')"/>

The file is iso-8859-1.

Will using different encodings effect the output?

1
guessing: you will get different results depending on the transformer implementation you use. if no encoding is declared i suspect the OS encoding will be used (which will be different on different computers). easy way out: do everything in utf8 :)kritzikratzi

1 Answers

3
votes

The trees operated upon by XSLT are abstract objects, typically (but not necessarily) created by parsing XML documents. The characters in those abstract trees are from the character repertoire of ISO 10646 and Unicode; any variations in the encoding used for the input XML are leveled by the XML parser before any representations of the trees are ever built.

So the answer to your question is: if the XML parser(s) used know the input encodings, the effect of different encodings on the input is nil. If the XML parsers don't know and accept the encodings, the effect will be to make it impossible for the XSLT engine to read the input at all.