Mike Brown and David Carlisle Is it possible to specify a hexadecimal value (00-ff) as the
third argument to the translate function?
Well, you can't refer to bytes, per se, because XPath and
XSLT functions operate on the data model prescribed in the
XPath spec. This model does not deal with bytes; it deals
with nodes, and (following the reference
Well, you can't refer to bytes, per se, because XPath and
XSLT functions operate on the data model prescribed in the
XPath spec. This model does not deal with bytes; it deals
with nodes, and (following the reference to the XML Infoset
spec) at a lower level, with Unicode/UCS characters,
regardless of how they are represented when serialized as a
byte stream.
Since an XML parser will resolve character references before
the stylesheet tree is built, you should be able to put any
Unicode characters in the arguments to the translate()
function. For example,
translate($someString,'abcde','ABCDE') is the same as
($someString,'abcde','ABCDE').
If your goal is to output bytes that represent characters
from the Windows CP-1252 (or whatever) character set, you'll
need to determine what the proper Unicode/UCS code points
are for those characters, and then rely on your
serialization mechanism to encode the characters as the
bytes you want. It may take some experimentation depending
on your particular situation.
David C adds:
> Something special about null character? yes it's not allowed in XML. But then neither is character 1
(not checking for disallowed characters is a known feature
of the IE parser, if I recall)
the XML char production is:
<prod id="NT-Char"><lhs>Char</lhs>
<rhs>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
| [#x10000-#x10FFFF]</rhs>
<com>any Unicode character, excluding the
surrogate blocks, FFFE, and FFFF.</com> </prod>
In other words nothing in the ascii control range except
tab, line feed and newline.
|