Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:45:20+00:00 2026-06-04T17:45:20+00:00

I am using XSLT to transform XML to HTML. Currently i am trying to

  • 0

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 :

<data>
    <ACCOUNTS elem="0">
        <ACCOUNT_NO>12345</ACCOUNT_NO>
    </ACCOUNTS>
    <ACCOUNTS elem="1">
        <ACCOUNT_NO>67890</ACCOUNT_NO>
    </ACCOUNTS>
</data>

This is my the XSLT that i try to figured out but is not working :

<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>

How can i add the position into the XML node so that i’m able to display it out by using

<xsl:value-of select="$account[@elem=1]" />

Please help me and let me know if got any concern. Thanks.

UPDATED :

My full XSLT 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>

And when i compile i get this error :

JAXPSAXProcessorInvoker  - Error checking type of the expression 'FilterParentPath(variable-ref(accounts/result-tree), step("child", 40, pred(=(step("attribute", 18), literal-expr(0)))))'.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:45:22+00:00Added an answer on June 4, 2026 at 5:45 pm

    If my understanding is correct,

    INPUT XML:

    <data>
        <ACCOUNTS elem="0">
            <ACCOUNT_NO>12345</ACCOUNT_NO>
        </ACCOUNTS>
        <ACCOUNTS elem="1">
            <ACCOUNT_NO>67890</ACCOUNT_NO>
        </ACCOUNTS>
    </data>
    

    XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="html"/>
        <xsl:template match="/">
            <xsl:for-each select="data/ACCOUNTS">
                <child elem="{@elem}">
                    <xsl:value-of select="ACCOUNT_NO"/>
                </child>
            </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>
    

    OUTPUT HTML:

    <child elem="0">12345</child>
    <child elem="1">67890</child>
    

    ANOTHER XSLT:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="html"/>
        <xsl:template match="/">
            <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:value-of select="$accounts/child[@elem='1']"/>
        </xsl:template>
    </xsl:stylesheet>
    

    OUTPUT:

    67890
    

    UPDATED:

    @Kelvingo: As per your updated XSLT, I feel you may require msxsl:node-set to use this

    <xsl:value-of select="msxsl:node-set($accounts)/child[@elem='0']"/>
    

    accounts variable.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
        <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="msxsl:node-set($accounts)/child[@elem='0']"/>
                </body>
            </html>
        </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to transform some XML into HTML using XSLT . Problem: I can't
I use this code to transform XML to HTML using XSLT template: string uri
I am using XSLT to transform a XML into a html/php file. In this
I am trying to transform XML to xHTML using XSLT. After doing this I
I am using xslt to transform an xml document to html for use in
Hi Can anyone help me in html to xml conversion using xslt in java.I
I am trying to do a simple transform of XML using XSLT to generate
I am trying to transform an RDF file to HTML using XSLT. I am
I am trying to transform a .html document using xslt. The generated html for
I am using xslt to transform an xml file to html. The .net xslt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.