Re: [xsl] Generating attributes from the position of an element

Subject: Re: [xsl] Generating attributes from the position of an element
From: Gábor Tóth <roysy@xxxxxxxx>
Date: Wed, 2 Jun 2010 09:22:33 +0100
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

</xsl:template>
    <xsl:template match="@ID">
            <xsl:attribute name="xml:id">w.<xsl:number
count="w"/></xsl:attribute>

</xsl:template>

while the built-in option does, is it somehow related to Saxon 9B? or
alternatively it might be also the problem of this adds-on-

Thanks,

Gabor

On Tue, Jun 1, 2010 at 9:29 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>
>> I have the following xml file and wish to generate ID-s based on the
>> position to the<w>  elements with the following XSL file, however, the
>> end result of the ID attribute is always 1, I have no idea why.
>>
>>
>
> The reason the value is always 1 is that the @ID attribute is always at
> position 1 in the list of nodes selected by
>
> <xsl:apply-templates
select="@*|node()|comment()|processing-instruction()"/>
>
> If you want the position in the source tree of the parent element of the
@ID
> attribute, try<xsl:number/>.
>
> Michael Kay
> Saxonica Limited

Current Thread