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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:27:03+00:00 2026-05-30T19:27:03+00:00

I have an XML like this: <?xml version=1.0 encoding=UTF-8?> <row> <cell colname=1><Name>SomeValue<Ref format=Ref Idref=ABC/></Name></cell>

  • 0

I have an XML like this:

<?xml version="1.0" encoding="UTF-8"?>
<row>
    <cell colname="1"><Name>SomeValue<Ref format="Ref" Idref="ABC"/></Name></cell>
    <cell colname="2"><Selection>
        <Config><Configuration>AAA</Configuration></Config>
        <Config><Configuration>BBB</Configuration></Config>
    </Selection></cell>
    <cell colname="6"><Notes>
        <Text><IteratorDef>
            <IteratorTag Id="ABC">DDi</IteratorTag>
            <IteratorList>
                <IteratorChoice>05</IteratorChoice>
                <IteratorChoice>10</IteratorChoice>
                <IteratorChoice>15</IteratorChoice>
            </IteratorList>
        </IteratorDef></Text>
    </Notes></cell>
</row>

I’d like to get the result like this:

The Ref points to the IteratorTag:
There are two Configuration namely AAA and BBB. For each Configuration there are several IteratorChoice values. Each need to be concatenated with the Name value + IteratorTag value so SomeValue+DDi+05, SomeValue+DDi+10, and SomeValue+DDi+15.

   AAA
   SomeValueDDi05
   SomeValueDDi10
   SomeValueDDi15

   BBB
   SomeValueDDi05
   SomeValueDDi10
   SomeValueDDi15

My thought is write a loop in a loop with for-each keying on IteratorList and Configuration tags (Configuration loop will be inside IteratorList loop), is this the correct approach using XSLT ?.

TIA,

John

  • 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-30T19:27:04+00:00Added an answer on May 30, 2026 at 7:27 pm

    solution1: this works only on provided input.
    Here is the code:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text" indent="yes"/>
      <xsl:variable name="newline" select="'&#13;'"/>
    
      <xsl:template match="row/cell/Selection/Config/Configuration">
        <xsl:value-of select="concat(.,$newline)"/><!--AAA, BBB, etc-->
    
        <xsl:for-each select="/row/cell/Notes/Text/IteratorDef/IteratorList/IteratorChoice">
          <xsl:variable name="zstring" select="."/>
          <xsl:for-each select="ancestor::IteratorDef/IteratorTag">
            <xsl:variable name="ystring" select="concat(.,$zstring)"/>
            <xsl:for-each select="ancestor::row/cell/Name">
              <xsl:value-of select="concat(normalize-space(.),$ystring,$newline)"/>
            </xsl:for-each>
          </xsl:for-each>
        </xsl:for-each>
    
        <!--this is for extra line space after each CONFIGURATION block-->
        <xsl:value-of select="$newline"/>
      </xsl:template>
      <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    Edit: Solution 2.. I have used no reverse XPath but complete XPath ..
    this works on robust XML. the method is slightly different .. here I
    am going from high level (XPath) to lower level. This is the code:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text" indent="yes"/>
      <xsl:variable name="newline" select="'&#13;'"/>
    
      <xsl:template match="row/cell/Selection/Config/Configuration">
        <xsl:value-of select="concat(.,$newline)"/><!--AAA, BBB, etc-->
    
        <xsl:for-each select="/row/cell/Name">
          <xsl:variable name="astring" select="normalize-space(.)"/>
          <xsl:for-each select="/row/cell/Notes/Text/IteratorDef/IteratorTag">
            <xsl:variable name="bstring" select="concat($astring,normalize-space(.))"/>
            <xsl:for-each select="/row/cell/Notes/Text/IteratorDef/IteratorList/IteratorChoice">
              <xsl:value-of select="concat($bstring,normalize-space(.),$newline)"/>
            </xsl:for-each>
          </xsl:for-each>
        </xsl:for-each>
    
        <!--this is for extra line space after each CONFIGURATION block-->
        <xsl:value-of select="$newline"/>
      </xsl:template>
    
      <!--disable all unwanted text nodes-->
      <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    If this is your XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <row>
      <cell colname="1">
        <Name>
          SomeValue<Ref format="Ref" Idref="ABC"/>
        </Name>
      </cell>
      <cell colname="2">
        <Selection>
          <Config>
            <Configuration>AAA</Configuration>
          </Config>
          <Config>
            <Configuration>BBB</Configuration>
          </Config>
          <Config>
            <Configuration>CCC</Configuration>
          </Config>
        </Selection>
      </cell>
      <cell colname="6">
        <Notes>
          <Text>
            <IteratorDef>
              <IteratorTag Id="ABC">DDi</IteratorTag>
              <IteratorTag Id="ABC">EEi</IteratorTag>
              <IteratorList>
                <IteratorChoice>05</IteratorChoice>
                <IteratorChoice>10</IteratorChoice>
                <IteratorChoice>15</IteratorChoice>
                <IteratorChoice>20</IteratorChoice>
              </IteratorList>
            </IteratorDef>
          </Text>
        </Notes>
      </cell>
    </row>
    

    This would be your output:

    AAA
    SomeValueDDi05
    SomeValueDDi10
    SomeValueDDi15
    SomeValueDDi20
    SomeValueEEi05
    SomeValueEEi10
    SomeValueEEi15
    SomeValueEEi20
    
    BBB
    SomeValueDDi05
    SomeValueDDi10
    SomeValueDDi15
    SomeValueDDi20
    SomeValueEEi05
    SomeValueEEi10
    SomeValueEEi15
    SomeValueEEi20
    
    CCC
    SomeValueDDi05
    SomeValueDDi10
    SomeValueDDi15
    SomeValueDDi20
    SomeValueEEi05
    SomeValueEEi10
    SomeValueEEi15
    SomeValueEEi20
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML like this :: <?xml version=1.0 encoding=utf-8 ?> <Rows> <Row Id=1>
I have an XML file which looks like this : <?xml version=1.0 encoding=UTF-8?> <resultset
have an xml file like this. <?xml version =1.0 encoding =utf-8?> <menu> <menuNode title=Register
I have a xml like this: <?xml version=1.0 encoding=utf-8?> <assessment xmlns=http://xml.thinkcentral.com/pub/xml/hsp/assessment xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xhtml=http://www.w3.org/1999/xhtml xmlns:tia=http://xml.thinkcentral.com/pub/xml/hsp/tia
I have row for ListView(listview is inside LinearLayout) like <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
I have an xml file which looks like this <?xml version=1.0 encoding=UTF-8 ?> <BulkDataExchangeRequests
I have some xml like this: <Data> <Rows> <Row> <Field Name=title>Mr</Field> <Field Name=surname>Doe</Field> <Row>
I have xml like this: <configurationData> <path name='b'> <path name='a'> <setting name='s1'> ![CDATA[XXXX]] </setting>
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five
hi i have an xml like this <?xml version=1.0?> <DataSetExchangeWMS xmlns=http://tempuri.org/DataSetExchangeWMS.xsd> <dtObjektInfo> <LanguageCode>1031</LanguageCode> <LiegenschaftID>7463</LiegenschaftID>

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.