Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Number formatting with

From: Jeni Tennison <jeni@---------------->
To:
Date: 7/2/2000 9:25:00 AM
Ragnar,

>What do I do wrong? Or doesn't the XSLT engine in built-in Xeena support 
><xsl:number>? I thought that was a mandatory element...

There doesn't seem to be anything wrong with your XSLT - it works fine in
SAXON (when an 'l' is added before the ':' in the closing xs:variable tag).
 I don't know if Xeena supports xsl:number - different XSLT processors have
different levels of compliance, and even 'mandatory' elements aren't
supported in some.  The Xeena documentation should tell you what they've
missed out.

A couple of things about your XSLT (though bear in mind that I don't know
what your input looks like or Xeena's proclivities, and you might well be
using the code you're using because of your input or because other code
doesn't work in Xeena):

Firstly, when you set your variable, you want to give '$rowIndex' the value
that is simply the number of preceding 'option' siblings.  When you set a
variable using the *content* of the xsl:variable element, you create a
'result-tree fragment' consisting of a text node with the content
specified.  This is *slightly* more work for the processor to work with
later on than if you set the value of the variable using the 'select'
attribute, which just sets the value of the variable to the (string of the)
number.  In other words, rather than using:

<xsl:variable name="rowIndex">
  <xsl:value-of select="count(preceding-sibling::option)"/>
</xsl:variable>

you should probably use:

<xsl:variable name="rowIndex" select="count(preceding-sibling::option)" />

Secondly, doing anything to do with the axes descendent, preceding,
following, preceding-sibling and following-sibling are generally to be
avoided if at all possible.  I'm not sure what your input looks like: if
the 'option' elements aren't mixed up with other elements inside their
parent, then you can probably simply use position() instead:

<xsl:variable name="rowIndex" select="position()" />

If they *are* mixed up with other elements, then you should still use
position(), but make sure that the current node list contains only the
'option' elements by doing something like:

<xsl:apply-templates select="option" mode="HTML" />

Finally, all this is by the by because when you're using xsl:number it's
*extremely rare* that you need to use its 'value' attribute.  You will
probably be able to simply use:

<xsl:number format="a" />

as this defaults to using the position of the current node (the 'option'
element) in the node list consisting of all the sibling nodes of the same
node type (i.e. elements) that are called the same thing (i.e. the sibling
'option' elements).

So, try the template:

<xsl:template match="option" mode="HTML">
  <TR>
    <TD>
      <xsl:number format="a" />
    </TD>
    <TD>
      further row content
    </TD>
  </TR>
</xsl:template>

I hope that helps,

Jeni

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent