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

  • SEARCH
  • Home
  • 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 7660423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:27:49+00:00 2026-05-31T13:27:49+00:00

I’m looking for a way to output this code as html. <legal> <heading>Poo</heading> <g>fart

  • 0

I’m looking for a way to output this code as html.

<legal>
  <heading>Poo</heading>
  <g>fart <a href="http://www.bclaws.ca/EPLibraries/bclaws_new/document/ID/freeside/96165_01">Freedom of Information and Protection of Privacy Act</a> (RSBC 1996 ch. 165):</g>
  <foo>
    <bar>a </bar>
    <bar>b </bar>
    <bar>c </bar>
    <bar>d </bar>
    <bar>e </bar>
    <bar>f </bar>
  </foo>
  <g> faf </g>
  <g> faf </g>
  <g> faf </g>
  <g> faf </g>
  <g> faf </g>
  <g> faf </g>
  <g> faf </g>
    <foo>
      <bar> a </bar>
      <bar> b </bar>
      <bar> c </bar>
    </foo>
  <g> asfd </g>
  <g> asfd </g>
  <g> asfd </g>
  <g> asfd </g>
  <g> asfd </g>
  <g> asfd </g>
  <g> asfd </g>
    <foo>
      <bar> a </bar>
      <bar> b </bar>
      <bar> c </bar>
    </foo>
</legal>

Here is my XSLT so far… I cannot seem to output each and every g element within the p tags… it only seems to output it once and never again. Also, I seem to only be outputting the same thing twice… Where am I going wrong?

<xsl:variable name="legal" select="document('legal.xml')/legal"/>
  <xsl:for-each select="$legal/heading">
    <h3><xsl:value-of select="$legal/heading"/></h3>
    <p><xsl:value-of select="$legal/g"/></p>
      <ul>
        <xsl:for-each select="$legal/foo/bar">
          <li><xsl:value-of select="."/></li>
        </xsl:for-each>
      </ul>
  </xsl:for-each>
  • 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-31T13:27:50+00:00Added an answer on May 31, 2026 at 1:27 pm

    I’d suggest replacing the entire code fragment you’ve shown with this:

    <xsl:apply-templates select="document('legal.xml')/legal" />
    

    and adding these templates:

    <xsl:template match="heading">
      <h3><xsl:apply-templates /></h3>
    </xsl:template>
    
    <xsl:template match="g">
      <p><xsl:apply-templates /></p>
    </xsl:template>
    
    <xsl:template match="foo">
      <ul>
        <xsl:apply-templates />
      </ul>
    </xsl:template>
    
    <xsl:template match="bar">
      <li><xsl:apply-templates /></li>
    </xsl:template>
    

    The reason you’re getting duplicates at the moment is because you’re iterating over each header, and then in each iteration of that loop, you’re processing the same g element, and iterating over the same foo elements, regardless of which header they’re after. In both your source and the html output, g/p elements are not children of header/h3 elements, it doesn’t make sense to treat them as such in your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.