Bug #3414
closedvalue-of generates extra white-space and new line characters
0%
Description
We are using Saxon-HE in one of our .NET projects. We’ve noticed recently the following issue – when ‘value-of’ is applied to multiple nodes as below
XSLT:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<data>
<value id="febf90c4">
<xsl:attribute name="value">
<xsl:value-of select="/Clients/Client1/Personal/Initial" />
</xsl:attribute>
</value>
</data>
</xsl:template>
</xsl:transform>
Input XML:
<Clients>
<Client1 Id="6180657">
<Personal Id="6180657">
<Initial>
<FirstName type="q5:string">M</FirstName>
<LastName type="q6:string">P</LastName>
</Initial>
</Personal>
</Client1>
</Clients>
the transformation produces incorrect result
Output XML:
<data xmlns:xs="http://www.w3.org/2001/XMLSchema">
<value id="febf90c4" value="
 M
 P
 " />
</data>
Expected XML:
<data xmlns:xs="http://www.w3.org/2001/XMLSchema">
<value id="febf90c4" value="MP" />
</data>
I assume concatenation of several nodes includes indentation characters into the output value.
Files
Updated by Michael Kay about 7 years ago
- Status changed from New to Rejected
Unless you use xsl:strip-space, the whitespace text nodes in the content of the <Initial>
element form part of the string value of the element and are therefore included in the result. Possible solutions:
-
Use xsl:strip-space to remove insignificant whitespace text nodes from the input
-
Use a schema-aware transformation, where the schema contains the information to distinguish significant from non-significant whitespace
-
Use
<xsl:value-of select="/Clients/Client1/Personal/Initial/string-join(*)" />
to select only the element children of Initial, and not its text node children.
Please register to edit this issue