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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:10:55+00:00 2026-05-20T16:10:55+00:00

I’ve got the following XML structure : <Article> <id>1</id> <line>L11</line> <line>L12</line> <line>L13</line> </Article> <Article>

  • 0

I’ve got the following XML structure :

    <Article>
         <id>1</id>
         <line>L11</line>
         <line>L12</line>
         <line>L13</line>
     </Article>
    <Article>
         <id>2</id>
         <line>L21</line>
         <line>L22</line>
         <line>L23</line>
     </Article>

I want to use XSLT to iterate over all the lines of only one article at a time so that I can achieve the following structure : (every article is converted into an order, and its lines are converted to line structures in the new structure)

        <orders>
           <order>
              <id>1</id>
              <order_line>L11</order_line>
              <order_line>L12</order_line>
              <order_line>L13</order_line>
            </order>
           <order>
              <id>2</id>
              <order_line>L21</order_line>
              <order_line>L22</order_line>
              <order_line>L23</order_line>
            </order>
        </orders>
  • 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-20T16:10:56+00:00Added an answer on May 20, 2026 at 4:10 pm

    With XSLT, try to think of the task at hand as a set of patterns or rules you have to match, and the actions to be taken each time such a pattern is encountered. You can usually let the runtime worry about looping, etc, to discover patterns.

    In your specific case, you’ve described two patterns you want special logic. Every time there is the element Article, you wish to apply the rule to change its name to order.
    Every time the element line is encountered as a child of Article, replace it with order_line. For any other pattern, you just want to copy the contents as they were in the original document:

    <!-- Match element Article, and whenever it's encountered, insert an 'order' element, and copy the contents of Article -->
    <xsl:template match="Article">
      <order> <xsl:apply-templates/> </order>
    </xsl:template>
    
    <!-- Match element 'line', and whenever it's encountered, insert an 'order_line' element, and copy the contents -->
    <xsl:template match="Article/line">
      <order_line> <xsl:apply-templates/> </order_line>
    </xsl:template>
    
    <!-- Match any other element we haven't specified explicity, and copy it verbatim -->
    <xsl:template match="node()">
      <xsl:copy>
        <xsl:apply-templates/>
      </xsl:copy>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.