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 7051653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:17:21+00:00 2026-05-28T03:17:21+00:00

I created a xsl file that will output two XML:s. One of the xml

  • 0

I created a xsl file that will output two XML:s.

One of the xml should be reaped just once. since its only one structure and its working so I wont post that code,
but the in the other I want to output the whole tree structure. But its only prints the first one. and not the entire tree.

This is what Ill come up to at the moment

<?xml version="1.0" encoding="iso-8859-1"?> 
<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/"> 

<html> 
<body>


<xsl:for-each select="$doc1//quiz//question">   
<xsl:value-of select="$doc1//author" />
<br />
<xsl:value-of select="$doc1//questionText" />
<br />
<xsl:text>Ger </xsl:text><xsl:value-of select="$doc1//points" /><xsl:text> Poäng </xsl:text>
</xsl:for-each>

</body> 
</html> 
</xsl:template> 
</xsl:stylesheet>

thanks

Edit:
Will ad my XML file

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="q2.xsl"?>
<quiz>
<question>
<author>Författare 1</author>
<questionText>Fråga 1</questionText>
<correct>Svar 1</correct>
<incorrect>fel 1</incorrect>
<incorrect>fel 1-2</incorrect>
<points>1</points>
</question>

<question>
<author>Författare 2</author>
<questionText>Fråga 2</questionText>
<correct>Svar 2</correct>
<incorrect>fel 2</incorrect>
<incorrect>fel 2-3</incorrect>
<points>2</points>
</question>

<question>
<author>Författare 3</author>
<questionText>Fråga 3</questionText>
<correct>Svar 3</correct>
<incorrect>fel 3</incorrect>
<incorrect>fel 3-4</incorrect>
<points>3</points>
</question>

<question>
<author>Författare 4</author>
<questionText>Fråga 4</questionText>
<correct>Svar 4</correct>
<incorrect>fel 4</incorrect>
<incorrect>fel 4-5</incorrect>
<points>4</points>
</question>

<question>
<author>Författare 5</author>+
<questionText>Fråga 5</questionText>
<correct>Svar 5</correct>
<incorrect>fel 5</incorrect>
<incorrect>fel 5-6</incorrect>
<points>5</points>
</question>

</quiz>
  • 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-05-28T03:17:22+00:00Added an answer on May 28, 2026 at 3:17 am

    Your problem is you reference back to the origional $doc instead of the actual context node when you enter the for-each statement

    This should work

    <?xml version="1.0" encoding="iso-8859-1"?> 
    <xsl:stylesheet version="1.0"  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="/"> 
    
    <html> 
    <body>
    
    
    <xsl:for-each select="$doc1/quiz/question">   
    <xsl:value-of select="author" />
    <br />
    <xsl:value-of select="questionText" />
    <br />
    <xsl:text>Ger </xsl:text><xsl:value-of select="points" /><xsl:text> Poäng </xsl:text>
    </xsl:for-each>
    
    </body> 
    </html> 
    </xsl:template> 
    </xsl:stylesheet>
    

    Extra example using apply templates!

    This is much better for reading ect. once things get complicated, and you can easily note the context of nodeset!

    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">    
            <html>
                <body>
                    <xsl:apply-templates select="$doc1/quiz/question"/>
                </body>
            </html>
        </xsl:template>
    
        <xsl:template match="question">
            <xsl:value-of select="author" />
            <br />
            <xsl:value-of select="questionText" />
            <br />
            <xsl:text>Ger </xsl:text>
            <xsl:value-of select="points" />
            <xsl:text> Poäng </xsl:text>
        </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 just created a XSL file that sorts my XML. Now I want to
I've generated the following XSLT file, and have created a Form that will post
I Need to create an XSL file so that I will use it to
I want to transform some xml using an xsl-file and output the result somehow
I have an XML file and I have an XSL translator file that came
I have an XML file (dynamically created) and an XSL style sheet; if I
I have created an XML file and transformed it into HTML using xsl. However,
I have developed an XSL file that transforms xml files into a html table.
I have one huge XML document. I have set of XSL representing each node
I am using an XSL transformation on an xml file to create an xml

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.