0

I'm using XPath1.0

XML:

<A a="2" b="2" c="2" d="2" e="2"/> 

Q: How many attributes before attribute d

 

A: There are 3 attributes(a,b,c) before attribute d

If a~e are not attributes but elements, I can do this:

 <xsl:template match="/">
    <xsl:value-of select="count(../A/*[text()='d']/preceding-sibling::*) + 1"/>
  </xsl:template>

But now a~e are attributes, how can I do the same between <xsl:template match="/"> and </xsl:template>

DaveG
  • 491
  • 1
  • 6
  • 19
  • 1
    Attributes are considered "unordered" in XML (See https://stackoverflow.com/questions/33746224/in-xml-is-the-attribute-order-important) – Tim C Jul 16 '18 at 09:23
  • 1
    Duplicate of [***XSLT to order attributes***](https://stackoverflow.com/questions/19718597/xslt-to-order-attributes) – kjhughes Jul 16 '18 at 13:17

0 Answers0