RE: [xsl] Problems with apersand (&) when trying to dynamically define a character value as an attribute value.

Subject: RE: [xsl] Problems with apersand (&) when trying to dynamically define a character value as an attribute value.
From: "Robert Eaton" <reaton@xxxxxxxxxxxxxxx>
Date: Thu, 26 Oct 2006 15:13:01 +0100
>Write a throwaway XSLT 2 stylesheet that does
>
><chars>
>  <xsl:for-each select="20 to 65535">
>    <xsl:value-of select="codepoints-to-string(.)"/>>
>
>Paste the result into your XSLT 1 stylesheet inside an xsl:variable
>name="chars".
>
>Then in your XSLT 1 stylesheet do
>
>substring($chars, @character - 20, 1)
>
>Michael Kay

This looks like the neatest solution available to me but I am having a
bit of trouble getting it working. I have created the throw away XSLT
stylesheet with the following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >
<xsl:template match="/">
	 <xsl:for-each select="32 to 65535">
    	<xsl:value-of select="codepoints-to-string(.)"/>
    	</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Then I have tried to process this with Saxon8 and get the following
error:

Saxon 8.8J from Saxonica
Java version 1.5.0_06
Stylesheet compilation time: 328 milliseconds
Processing file:/C:/saxon/amptest.xml
Building tree for file:/C:/saxon/amptest.xml using class
net.sf.saxon.tinytree.T
inyBuilder
Tree built in 0 milliseconds
Tree size: 7 nodes, 0 characters, 1 attributes
Error at xsl:value-of on line 5 of
file:/C:/saxon/generatecharstring.xsl:
  FOCH0001: Invalid XML character [x d800]
Transformation failed: Run-time errors were reported

Have I misunderstood what you meant?

Thanks,
Rob

Current Thread