Project

Profile

Help

Bug #3414

closed

value-of generates extra white-space and new line characters

Added by Artsiom Yandulski about 7 years ago. Updated about 7 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2017-08-28
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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="&#xA;        M&#xA;        P&#xA;      " />
</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

Saxon_XSLT.zip (4.15 KB) Saxon_XSLT.zip Sample VS solution Artsiom Yandulski, 2017-08-28 13:26
Actions #1

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

Also available in: Atom PDF