[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
On 02/06/2010 09:22, Gabor Tsth wrote:
Dear All,Given this source document: <text> <w ID=" " >car</w> <w ID=" ">dog</w> <w ID=" ">cat</w> <w ID=" ">house</w> </text> and this stylesheet <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="@*|node()|comment()|processing-instruction()"> <xsl:copy><xsl:apply-templates select="@*|node()|comment()|processing-instruction()"/></xsl:copy> </xsl:template> <xsl:template match="@ID"> <xsl:attribute name="Id"> <countNo><xsl:number count="w"/></countNo> </xsl:attribute> </xsl:template> </xsl:stylesheet> 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> </text> 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 Saxonica
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|