Martin Honnen created XALANJ-2780:
-------------------------------------
Summary: xsl:value-of separator with sequence constructor adds
final separator after sequence
Key: XALANJ-2780
URL: https://issues.apache.org/jira/browse/XALANJ-2780
Project: XalanJ2
Issue Type: Bug
Security Level: No security risk; visible to anyone (Ordinary problems in
Xalan projects. Anybody can view the issue.)
Components: transformation, Xalan, Xalan-CmdLine
Affects Versions: The Latest Development Code
Environment: Java 8 build 422, Windows 11
Reporter: Martin Honnen
Attachments: value-of-sequence-constr-test1.xsl
This is a bug report against the XSLT 3.0 development branch of Apache Xalan.
While testing the support of `xsl:value-of` with a `separator` attribute I
found that with a `select` attribute I get the `separator` nicely inserted
between the selected items; however, if I don't use a `select` attribute but
put a sequence constructor inside of the `xsl:value-of`, the separator is also
included after the last item which seems wrong to me.
Example test case:
{code:java}
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<section>
<h2>Test 1</h2>
<p>
<xsl:value-of select="1 to 5" separator=" | "/>
</p>
</section>
<section>
<h2>Test 2</h2>
<p>
<xsl:value-of separator=" | ">
<xsl:sequence select="1 to 5"/>
</xsl:value-of>
</p>
</section>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates/>
<xsl:comment>Run with <xsl:value-of
select="system-property('xsl:vendor')"/> at <xsl:value-of
select="current-dateTime()"/></xsl:comment>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
{code}
Run against any XML input sample and the output is something like
{code:java}
<?xml version="1.0" encoding="UTF-8"?><root>
<section>
<h2>Test 1</h2>
<p>1 | 2 | 3 | 4 | 5</p>
</section>
<section>
<h2>Test 2</h2>
<p>1 | 2 | 3 | 4 | 5 |</p>
</section>
</root><!--Run with Apache Xalan at 2024-08-24T13:25:01+02:00–>{code}
while I think it should be like
{code:java}
<?xml version="1.0" encoding="UTF-8"?><root>
<section>
<h2>Test 1</h2>
<p>1 | 2 | 3 | 4 | 5</p>
</section>
<section>
<h2>Test 2</h2>
<p>1 | 2 | 3 | 4 | 5</p>
</section>
</root><!--Run with Apache Xalan at 2024-08-24T13:25:01+02:00–>{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]