Project

Profile

Help

Bug #2788

closed

xsl:strip-space is not applied to the results of collection()

Added by Michael Kay almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2016-06-09
Due date:
% Done:

100%

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

Description

Reported by Eliot Kimber on saxon-help list on SourceForge.

I have code like this:

<xsl:if test="not(position() = last())">

         <xsl:text>,</xsl:text>

       </xsl:if>

When I run this transform under Saxon 9.6.0.7 (the version of 9.6 I had

lying about) I get the expected result from my data set.

However, when I run with 9.7.0.1 or 9.7.0.5 I appear to get the position

and next for the parent of the context element.

The source XML is:

   <ref name="title"/>

   <optional>

     <ref name="titlealts"/>

   </optional>

   <optional>

     <choice>

       <ref name="abstract"/>

       <ref name="shortdesc"/>

     </choice>

   </optional>

   <optional>

     <ref name="prolog"/>

   </optional>

   <optional>

     <ref name="body"/>

   </optional>

   <optional>

     <ref name="related-links"/>

   </optional>

   <zeroOrMore>

     <ref name="mytopic-info-types"/>

   </zeroOrMore>

 </define>

And my template is matching on elements, using the position() =

last() check to determine when to omit commas

When I run with 9.6 I get the correct result, and these position() and

last() values:

[java]  + [DEBUG] element-decls: rng:ref(), name="info-types",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="titlealts",

position="1", last="1"

[java] + [DEBUG] element-decls: rng:ref(), name="abstract", position="1",

last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="shortdesc",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="prolog",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="body",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="related-links",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(),

name="mytopic-info-types", position="1", last="1"

(Although I notice looking at these results that abstract and shortdesc,

which are siblings, do not report the expected position() or last()

values, so something is not right here.

With 9.7 I get these results:

[java]  + [DEBUG] element-decls: rng:ref(), name="info-types",

position="2", last="3"

[java]  + [DEBUG] element-decls: rng:ref(), name="titlealts",

position="2", last="3"

[java]  + [DEBUG] element-decls: rng:ref(), name="abstract",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="shortdesc",

position="1", last="1"

[java]  + [DEBUG] element-decls: rng:ref(), name="prolog",

position="2", last="3"

[java]  + [DEBUG] element-decls: rng:ref(), name="body",

position="2", last="3"

[java]  + [DEBUG] element-decls: rng:ref(), name="related-links",

position="2", last="3"

[java]  + [DEBUG] element-decls: rng:ref(),

name="mytopic-info-types", position="2", last="3"

For all but abstract and shortdesc, the position() and last() values are

different and also not what was expected.

The transform and source I'm using is available here:

https://github.com/oasis-open/dita-rng-converter/commit/c5dbc3379e0b7b6684e

38fa63439e391fbb34a47

The command line I'm running is:

ant generate-dtd

-DdoctypesDir=test/specializations/org.example/1.3/rng/mytopic

-Doutdir=test/specializations/org.example -DgenerateCatalogs=true

-DgenerateModules=true -Ddebug=false

I think the abstract and shortdesc results are explained by this code:

<xsl:for-each select="rng:*">

 <xsl:if test="not(position()=1)">

   <xsl:text> |&#x0a;</xsl:text>

 </xsl:if>

 <xsl:apply-templates select="." mode="#current" />

</xsl:for-each>

Which is used for choice groups, which abstract and shortdesc are children

of. In that case, each group has size 1 so the 1/1 result makes sense.

But the other results make no sense that I can see and there is definitely

a difference from 9.6 to 9.7.

It also looks like my code works by accident with 9.6 but definitely fails

with 9.7.

Cheers,

Eliot


Eliot Kimber, Owner

Contrext, LLC

http://contrext.com


Files

saxon-issue-2788.zip (11.3 MB) saxon-issue-2788.zip Eliot Kimber, 2016-06-10 16:25

Please register to edit this issue

Also available in: Atom PDF