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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:57:26+00:00 2026-05-27T01:57:26+00:00

I have a source xml that looks something like this: <item> <id>1</id> <property name=representative_email><value>Jallu.Kola@foo.bar.com</value></property>

  • 0

I have a source xml that looks something like this:

<item>
    <id>1</id>
    <property name="representative_email"><value>Jallu.Kola@foo.bar.com</value></property>
    <property name="representative_name"><value>Jallu Kola</value></property>
    <property name="representative_phone"><value>555 123 456</value></property>
    <property name="representative_email"><value>Sala.Rakas@foo.bar.com</value></property>
    <property name="representative_name"><value>Sala Rakas</value></property>
    <property name="representative_phone"><value>555 2314 124</value></property>
</item>
<item>
    <id>2</id>
    <property name="representative_email"><value>Sala.Rakas@foo.bar.com</value></property>
    <property name="representative_name"><value>Sala Rakas</value></property>
    <property name="representative_phone"><value>555 2314 124</value></property>
</item>
<item>
    <id>3</id>
    <property name="representative_email"><value>Jallu.Kola@foo.bar.com</value></property>
    <property name="representative_name"><value>Jallu Kola</value></property>
    <property name="representative_phone"><value>555 123 456</value></property>
    <property name="representative_email"><value>Sala.Rakas@foo.bar.com</value></property>
    <property name="representative_name"><value>Sala Rakas</value></property>
    <property name="representative_phone"><value>555 2314 124</value></property>
    <property name="representative_email"><value>ville.kalle@foo.bar.com</value></property>
    <property name="representative_name"><value>Ville Kalle</value></property>
    <property name="representative_phone"><value>555 124 124124</value></property>
</item>

Unfortunately there’s not much I can do about this other than use xslt to convert it to something more sensible.
I would like to convert it to look like this:

<item>
    <id>
    <representatives>
        <representative>
            <email></email>
            <name></name>
            </phone></phone>
        </representative
    </representatives
</item>

Any ideas how this can be achieved with xslt?I’m thinking that I need to collect the representative_* elements into memory while procedding an element. Once the end of that item element is reached, I should output the new element. Under that I would need to create a element for each group of the email+name+phone elements that appear in sequence.

  • 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-27T01:57:27+00:00Added an answer on May 27, 2026 at 1:57 am

    So, if each group always contain all 3 elements, you could iterate over one of them then select others by the same position:

    <xsl:template match="item">
      <item>
        <xsl:copy-of select="id"/>
        <representatives>
          <xsl:apply-templates select="property[@name='representative_email']"/>
        </representatives>
      </item>
    </xsl:template>
    <xsl:template match="property">
      <representative>
        <email>
          <xsl:value-of select="../property[@name='representative_email'][position()]"/>
        </email>
        <name>
          <xsl:value-of select="../property[@name='representative_name'][position()]"/>
        </name>
        <phone>
          <xsl:value-of select="../property[@name='representative_phone'][position()]"/>
        </phone>
      </representative>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML document that looks like this: <file> <name>NAME_OF_FILE</name> </file> <file> <name>NAME_OF_FILE</name>
I have an xml file that looks something like this <Data> <NumberID>23423</NumberID> <NumberID>34234</NumberID> <NumberID>45435</NumberID>
I have an XML document that looks like this: <kmsg xmlns=http://url1 xmlns:env=url1 xmlns:xsi=http://www.w3.org/2001/XMLSchemainstance xsi:schemaLocation=http://location
I have an ant properties file that looks like this (although I can adjust
I have table with a XML column (called MetaData) which looks like this: <props>
Have a source xml document that uses namespace containing prefixes and a default namespace.
I have a source XML file that is used to create C# files that
I'm using the jasmine maven plugin and my pom.xml looks like this: <plugin> <groupId>com.github.searls</groupId>
I have a source document with XML structure similar to this: <FOO> <BAR>x</BAR> <BAR>y</BAR>
I have a directory structure something like this: base subdir1 subdir2 subdir3 subsubdir1 subsubdir2

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.