Create name of attribute then get value

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I dont control the data so I cant do much about it.
There will be (N)umber of attributes abc1...abc<n> and they are sorted alphabetically as in the example.
Im looking for an effective way of getting the first X number of items in true order of 1,2,3,4,5, etc and
NOT 1,10,11,12,13,2,3.
The xsl is what I am trying but isnt working.
Any help would be appreciated.
<pre><DataFile record_id="123"
abc1="10"
abc10="100"
abc11="110"
abc12="120"
abc13="130"
abc2="20"
abc3="30"
abc4="40"
abc5="50"
abc6="60"
abc7="70"
abc8="80"
abc9="90" >
</DataFile>[/code]
<pre class="prettyprint <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/
<xsl:apply-templates select="//DataFile"/>
</xsl:template>
<xsl:template match="DataFile
<details>
<xsl:for-each select="@*[starts-with(name(), abc)]
<xsl:variable name="abcNode" select="concat(@abc, position())" />
<detail>
<xsl:attribute name="answer
<xsl:value-of select="concat(../, @abc, position())" />
<!--<xsl:value-of select="../@abc1" />-->
</xsl:attribute>
</detail>
</xsl:for-each>
</details>
</xsl:template>
</xsl:stylesheet>[/code]
<br/>
<br/>

View the full article
 
Back
Top