Subject: RE: [xsl] attribute position help !!! From: "Michael Kay" <mhk@xxxxxxxxx> Date: Tue, 14 Oct 2003 18:21:06 +0100 |
> > Is there any function allowing to know the position of a > > given attribute ? In XPath 2.0 you can do count(../@*[.<<$given-attribute]). In XSLT 1.0 you can do <xsl:for-each select="$given-attribute/../@*"> <xsl:if test="generate-id(.) = generate-id($given-attribute)"> <xsl:value-of select="position()"/> </xsl:if> </xsl:for-each> But of course all this does is tell you what order the system has decided to put the attributes in, which isn't very useful information, since it can put them in any order it likes. Michael Kay > > No. > > > example: > > is it wright to write : > > -------------------------------------------------------------------- > > <xsl:for-each select="element"> > > > > <xsl:if test="name(@[2])='type'"> > > > > <xsl:text> the postion of the type attribute is 2 > > No. Did you quess the syntax? > > The thing is, attributes don't have positions, they're > unordered in the XPath data model. They might have an order > in the XML lexical representation, but in the XPath data > model they're unordered. > > Cheers, > > Jarno - <http://www.synthetic.org/play.html> > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] attribute position help !, Jarno . Elovirta | Thread | [xsl] count() expression in transfo, Abie Hamaoui |
RE: [xsl] need help with converting, Michael Kay | Date | [xsl] document() function - unknown, Jim Nachlin |
Month |