How XSLT generate a dynamic variable array from XML?

simbiosis

New Member
I am using XSLT to transform XML to HTML. Currently i am trying to figured out how can i make an array variable in XSLT.This is my XML : \[code\]<data> <ACCOUNTS elem="0"> <ACCOUNT_NO>12345</ACCOUNT_NO> </ACCOUNTS> <ACCOUNTS elem="1"> <ACCOUNT_NO>67890</ACCOUNT_NO> </ACCOUNTS></data>\[/code\]This is my the XSLT that i try to figured out but is not working :\[code\]<xsl:variable name="accounts"> <xsl:for-each select="data/ACCOUNTS"> <child elem="<xsl:value-of select='position()' />"><xsl:value-of select="ACCOUNT_NO" /></child> </xsl:for-each></xsl:variable>\[/code\]How can i add the position into the XML node so that i'm able to display it out by using\[code\]<xsl:value-of select="$account[@elem=1]" />\[/code\]Please help me and let me know if got any concern. Thanks.UPDATED :My full XSLT code :\[code\]<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" encoding="utf-8" indent="yes"/><xsl:variable name="accounts"> <xsl:for-each select="data/ACCOUNTS"> <child elem="{@elem}"><xsl:value-of select="ACCOUNT_NO" /></child> </xsl:for-each></xsl:variable><xsl:template match="/"> <html> <head><title>testing</title></head> <body> <xsl:value-of select="$accounts/child[@elem='0']" /> </body> </html></xsl:template></xsl:stylesheet>\[/code\]And when i compile i get this error : \[code\]JAXPSAXProcessorInvoker - Error checking type of the expression 'FilterParentPath(variable-ref(accounts/result-tree), step("child", 40, pred(=(step("attribute", 18), literal-expr(0)))))'.\[/code\]
 
Back
Top