XPath 2.0 position() function and SaxonB 9.1.0.3
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 4
- Joined: Mon Dec 15, 2008 7:28 pm
XPath 2.0 position() function and SaxonB 9.1.0.3
Post by DAndres109 »
Hi,
I'm getting odd results when I use the position() function within an XSLT 2.0 stylesheet and the SaxonB 9.1.0.3 transformer.
Given a simple XML document such as the following
and an XSLT template:
I expect to see an ordered list of numbers starting with 1. However, the transformation prints out the numbered sequence 2, 4, 6... (text nodes perhaps?) This does not occur with the SaxonSA transformer or with XPath 2.0 and XPath 2.0 SA searches.
I understand that this is most likely an issue with the transformer and not with Oxygen XML, but I thought I'd give this a try anyway.
I'm getting odd results when I use the position() function within an XSLT 2.0 stylesheet and the SaxonB 9.1.0.3 transformer.
Given a simple XML document such as the following
Code: Select all
<xml ...>
<table>
<table-row>
...
</table-row>
<table-row>
...
</table-row>
...
</table>
Code: Select all
<xsl:template match="/table/table-row">
<xsl:value-of select="position()"/>
</xsl:template>
I understand that this is most likely an issue with the transformer and not with Oxygen XML, but I thought I'd give this a try anyway.
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: XPath 2.0 position() function and SaxonB 9.1.0.3
Hi,
That is the correct behavior and I get the same also with Saxon SA. The cause is the built in template that matches on table and applies the templates on all child nodes of table. If you put a second template as below
you will see
[text 1]2[text 3]4[text 5]
as result.
If you want 1, 2, etc. for table rows then match on table and apply templates only on elements:
Best Regards,
George
That is the correct behavior and I get the same also with Saxon SA. The cause is the built in template that matches on table and applies the templates on all child nodes of table. If you put a second template as below
Code: Select all
<xsl:template match="/table/table-row">
<xsl:value-of select="position()"/>
</xsl:template>
<xsl:template match="/table/text()">
<xsl:text>[text </xsl:text>
<xsl:value-of select="position()"/>
<xsl:text>]</xsl:text>
</xsl:template>
[text 1]2[text 3]4[text 5]
as result.
If you want 1, 2, etc. for table rows then match on table and apply templates only on elements:
Code: Select all
<xsl:template match="table">
<xsl:apply-templates select="*"/>
</xsl:template>
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service