[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Generating attributes from the position of an elem

Subject: Re: Generating attributes from the position of an element
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 02 Jun 2010 11:08:04 +0100
Re:  Generating attributes from the position of an elem
On 02/06/2010 09:22, Gabor Tsth wrote:
Dear All,

Thanks for your answers, Michael I tried it out and it worked,
however, I have not so far managed to install Saxon to my Mac, so as a
temporal solution I am using a Firefox adds-on, called "Get XSLT
results" and it has two options for creating transformations, one is
the Saxon 9B, and the other one is called "Built-in XSLT", if I am
trying with the Saxon 9B option, it does not generate the id for this

Given this source document:

<w ID=" " >car</w>
<w ID=" ">dog</w>
<w ID=" ">cat</w>
<w ID=" ">house</w>

and this stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<xsl:template match="@*|node()|comment()|processing-instruction()">
<xsl:copy><xsl:apply-templates select="@*|node()|comment()|processing-instruction()"/></xsl:copy>

<xsl:template match="@ID">
<xsl:attribute name="Id">
<countNo><xsl:number count="w"/></countNo>


Saxon produces this output:

<?xml version="1.0" encoding="UTF-8"?><text>
<w Id="1">car</w>
<w Id="2">dog</w>
<w Id="3">cat</w>
<w Id="4">house</w>

Note, I had to remove the xpath-default-namespace attribute, because your input is not in a namespace. Perhaps the stylesheet worked with the Transformiix processor because an XSLT 1.0 processor running a stylesheet that specifies version="2.0" will ignore the xpath-default-namespace attribute.

If you're having problems installing Saxon on your Mac, you might find that "Kernow for Saxon" is easier to install. and use This will automatically install Saxon as well as Kernow.

Michael Kay

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.