XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Mark EisenbergSubject: Problem with position() and last()
Author: Mark Eisenberg
Date: 26 Jan 2007 03:22 PM
Originally Posted: 26 Jan 2007 03:10 PM
Here's a snippet of an XML file containing table data:

<tbody>
<row rowsep="1">
<entry valign="top" colname="C1"><p id="c00p000810">&abreve;</p></entry>
<entry valign="top" colname="C2"><p id="c00p000820"><emph type="2">hat</emph> [h&abreve;t]</p></entry>
</row>
<row rowsep="1">
<entry valign="top" colname="C1"><p id="c00p000830">&amacron; <emph type="2">or ay</emph></p></entry>
<entry valign="top" colname="C2"><p id="c00p000840"><emph type="2">hate</emph> [h&amacron;te], <emph type="2">trait</emph> [trayt]</p></entry>
</row>
</tbody>

And the code I am currently debugging:

<xsl:template match="row">
<xsl:if test="contains(name(..),'tbody')" >
<xsl:apply-templates/>
<xsl:choose>
<xsl:when test="(position() mod 5) = 0">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<p/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="linebreak" />
</xsl:if>
</xsl:template>

<xsl:template match="entry">
<xsl:if test="contains(name(../..),'tbody')" >
<xsl:variable name="entry-colname" select="@colname"/>
<xsl:variable name="column-header" select="ancestor::tgroup/thead/row/entry[@colname = $entry-colname]/p/text()"/>
<xsl:if test="string-length($column-header)>0">
<xsl:value-of select="$column-header" />
<xsl:text>: </xsl:text>
</xsl:if>
<xsl:value-of select="name(.)" />
<xsl:value-of select="position()"/>
<xsl:value-of select="last()"/>
<xsl:apply-templates />
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:if>
</xsl:template>

Sample output from the Built-in XSLT processor:

symbols: {entry25{<br/>examples: hat [h{t]entry45<i>hat</i>[h{t]<br/><p/>
symbols: eI or ayentry25eI<i>or ay</i><br/>examples: hate [heIte], trait [trayt]entry45<i>hate</i>[heIte],<i>trait</i>[trayt]<br/><p/>

Sample output from Saxon 8.7.1:

symbols: {entry12{<br/>examples: hat [h{t]entry22<i>hat</i>[h{t]<p/>
symbols: eI or ayentry12eI<i>or ay</i><br/>examples: hate [heIte], trait [trayt]entry22<i>hate</i>[heIte],<i>trait</i>[trayt]<p/>

------------------------------------------------------------
Why does the built-in processor return 2 & 4 for position() and 5 for last()?

Thanks,
Mark

Posttop
Mark EisenbergSubject: Problem with position() and last()
Author: Mark Eisenberg
Date: 28 Jan 2007 04:16 PM
Further investigation leads me to conclude that the issue I have raised above is being caused by whitespace in the <row> nodes. I have a strip-space directive in my XSLT so all of this should be gone. I understand that the built-in processor does not support strip space so I have been working with the .NET processor because it is way faster than the Saxon processor. This processor strips some of the white space, but not all.

Any thoughts?

Thanks,
Mark

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.