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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:30:54+00:00 2026-05-11T21:30:54+00:00

I have a following XML structure that I need to transform: <recordset rowCount=68 fieldNames=ITEM,ECL,LEAD_TIME

  • 0

I have a following XML structure that I need to transform:

<recordset rowCount="68" fieldNames="ITEM,ECL,LEAD_TIME" type="**coldfusion.sql.QueryTable**">
<field name="ITEM">
 <string>ITEM_A</string>
 <string>ITEM_B</string>
 <string>ITEM_C</string>
</field>
<field name="REV">
 <string>A</string>
 <string>B</string>
 <string>C</string>
</field>
<field name="LEAD_TIME">
 <string>10</string>
 <string>15</string>
 <string>25</string>
</field>
</recordset>

Into:

<records>
<item_line>
 <item>ITEM_A</item>
 <rev>A</rev>
 <lead_time>10</lead_time>
</item_line>
<item_line>
 <item>ITEM_B</item>
 <rev>B</rev>
 <lead_time>15</lead_time>
</item_line>
<item_line>
 <item>ITEM_C</item>
 <rev>C</rev>
 <lead_time>25</lead_time>
</item_line>
</records>

My knowledge of XSLT is very limited…

Thank you in advance!

  • 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-11T21:30:54+00:00Added an answer on May 11, 2026 at 9:30 pm
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
    
      <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
      <xsl:template match="/recordset">
        <records>
          <xsl:apply-templates select="field[@name='ITEM']/string" />
        </records>
      </xsl:template>
    
      <xsl:template match="field[@name='ITEM']/string">
        <xsl:variable name="currpos" select="position()" />
    
        <item_line>
          <item>
            <xsl:value-of select="." />
          </item>
          <rev>
            <xsl:value-of select="/recordset/field[@name='REV']/string[$currpos]" />
          </rev>
          <lead_time>
            <xsl:value-of select="/recordset/field[@name='LEAD_TIME']/string[$currpos]" />
          </lead_time>
        </item_line>
      </xsl:template>
    
    </xsl:stylesheet>
    

    A slightly more readable and probably marginally faster version would be using an <xsl:key>:

    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
    
      <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
      <xsl:key name="k_field" match="recordset/field" use="@name" />
    
      <xsl:template match="/">
        <records>
          <xsl:apply-templates select="key('k_field', 'ITEM')/string" />
        </records>
      </xsl:template>
    
      <xsl:template match="field[@name='ITEM']/string">
        <xsl:variable name="currpos" select="position()" />
    
        <item_line>
          <item>
            <xsl:value-of select="." />
          </item>
          <rev>
            <xsl:value-of select="key('k_field', 'REV')/string[$currpos]" />
          </rev>
          <lead_time>
            <xsl:value-of select="key('k_field', 'LEAD_TIME')/string[$currpos]" />
          </lead_time>
        </item_line>
      </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 have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567
I have the following sample XML structure: <SavingAccounts> <SavingAccount> <ServiceOnline>yes</ServiceOnline> <ServiceViaPhone>no</ServiceViaPhone> </SavingAccount> <SavingAccount> <ServiceOnline>no</ServiceOnline>
If i have the following directory structure: Project1/bin/debug Project2/xml/file.xml I am trying to refer
I have a huge bunch of XML files with the following structure: <Stuff1> <Content>someContent</name>
I have the following xml that's sent to me from a web service. I'm
I have the following XML source structure: <turnovers> <turnover repid=1 amount=500 rate=0.1/> <turnover repid=5
I have the following XML structure: <node name=A> <node name=B> <node name=C/> <node name=D/>
I have the following method that I use to serialize various objects to XML.
I have the following xml I'd like to deserialize into a class <?xml version=1.0
I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31/10/2008

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.