Click to See Complete Forum and Search --> : The ' ' character, hexadecimal value 0x20, cannot be included in a name


VikramSingh
06-25-2008, 06:39 AM
I am facing a problem in while compiling XSLT for the Following Input XML

This is my Input XML..
<Attributes>
<Attribute Name="$State" Value="Available" />
<Attribute Name="$SubType" Value="MeasurementDevice" />
<Attribute Name="AbsoluteDeviationNeg" Value="" />
<Attribute Name="AbsoluteDeviationPos" Value="" />
<Attribute Name="CheckRange" Value="No" />
<Attribute Name="ClippingCheckRange" Value="No" />
<Attribute Name="ClippingIsRangeUsed" Value="False" />
<Attribute Name="FA[w ]" Value="4535" />
<Attribute Name="HasAttachment" Value="True" />
<Attribute Name="IoBus" Value=" " />
<Attribute Name="IsCalibrated" Value="False" />
<Attribute Name="IsExternalSensors" Value="False" />
</Attributes>

and my XSLT is

<xsl:when test="starts-with(@Name,'FA[')">
<xsl:attribute name="{concat('ATTR',translate(@Name,'&#xA0;&lt;&gt;&quot;,\ÁáÄäÅåÉéÜüÚúÍíÓóÖöñÑçÇ«»£¤¥§ßØø°¶Ææ¢µ¿();:`´“€!=°_-@+.>$%^?/]~&amp;*$[]#{}|','_'))}">
<xsl:value-of select="@Value"/>
</xsl:attribute>
</xsl:when>

When i implement this XSLT i get a crash with a message:

The ' ' character, hexadecimal value 0x20, cannot be included in a name

Can any one help me in this regard:

rpgfan3233
06-25-2008, 08:21 AM
I just tried it client-side in Firefox 3 (after changing xsl:when to xsl:if because it was a single test) and all was well, except that it came out as attrfaw=4535.

I think you should be aware of how fn::translate() works. Check out this quote from the W3C XPath documentation on it:
If there is a character in the second argument string with no character at a corresponding position in the third argument string (because the second argument string is longer than the third argument string), then occurrences of that character in the first argument string are removed. For example, translate("--aaa--","abc-","ABC") returns "AAA".
In other words, because your replacement is only one character long, the only character that is recognized is &#xA0;. Everything else in the second string is simply removed from @Name. I'm not sure if that is what you wanted, but I figured you might benefit from the information if you didn't know.

Are you sure there aren't any other errors?