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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:33:50+00:00 2026-06-02T02:33:50+00:00

I have some xml XML Document with duplicate tag names like below :: <ROOT>

  • 0

I have some xml XML Document with duplicate tag names like below ::

<ROOT>
    <RECORD>
        <ID>A1</ID>
        <NAME>Name1</NAME>
        <ADDRESS>StreetName</ADDRESS>
        <ADDRESS>CityName</ADDRESS>
        <ADDRESS>State</ADDRESS>
        <ADDRESS>321</ADDRESS>
        <PHONE>12345</PHONE>
    </RECORD>
    <RECORD>
        <ID>A1</ID>
        <NAME>Name1</NAME>
        <ADDRESS>StreetName</ADDRESS>
        <ADDRESS>CityName</ADDRESS>
        <ADDRESS>State</ADDRESS>
        <ADDRESS>123</ADDRESS>
        <PHONE>12345</PHONE>
    </RECORD>
</ROOT>

So i have to get total address but when i am applying XSLT i am getting only First Tag Value.
Is there any possibilty to change that ADDRESS tag names to apropriate Tag names like STREET, CITY,STATE and ZIP Tags.

  • 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-06-02T02:33:51+00:00Added an answer on June 2, 2026 at 2:33 am

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:my="my:my">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <my:reps>
      <rep pos="1">STREET</rep>
      <rep pos="1">CITY</rep>
      <rep pos="1">STATE</rep>
      <rep pos="1">ZIP</rep>
     </my:reps>
    
     <xsl:variable name="vReps"
          select="document('')/*/my:reps/*"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="ADDRESS">
      <xsl:variable name="vPos" select=
         "count(preceding-sibling::ADDRESS)+1"/>
      <xsl:element name="{$vReps[position()=$vPos]}">
        <xsl:apply-templates/>
      </xsl:element>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <ROOT>
        <RECORD>
            <ID>A1</ID>
            <NAME>Name1</NAME>
            <ADDRESS>StreetName</ADDRESS>
            <ADDRESS>CityName</ADDRESS>
            <ADDRESS>State</ADDRESS>
            <ADDRESS>321</ADDRESS>
            <PHONE>12345</PHONE>
        </RECORD>
        <RECORD>
            <ID>A1</ID>
            <NAME>Name1</NAME>
            <ADDRESS>StreetName</ADDRESS>
            <ADDRESS>CityName</ADDRESS>
            <ADDRESS>State</ADDRESS>
            <ADDRESS>123</ADDRESS>
            <PHONE>12345</PHONE>
        </RECORD>
    </ROOT>
    

    produces the wanted, correct result:

    <ROOT>
       <RECORD>
          <ID>A1</ID>
          <NAME>Name1</NAME>
          <STREET>StreetName</STREET>
          <CITY>CityName</CITY>
          <STATE>State</STATE>
          <ZIP>321</ZIP>
          <PHONE>12345</PHONE>
       </RECORD>
       <RECORD>
          <ID>A1</ID>
          <NAME>Name1</NAME>
          <STREET>StreetName</STREET>
          <CITY>CityName</CITY>
          <STATE>State</STATE>
          <ZIP>123</ZIP>
          <PHONE>12345</PHONE>
       </RECORD>
    </ROOT>
    

    Explanation:

    Overriding the identity rule with a template matching ADDRESS and generating an element according to the position of this ADDRESS element.

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

Sidebar

Related Questions

I have some XML that looks something like this: <Root> <Documents> <Document id=1/> </Documents>
I have an XML document containing contact information as seen below: <contact type=individual> <firstname>Some</firstname>
I have some XML which contains records and sub records, like this: <data> <record
I have some xml like this: <Data> <Rows> <Row> <Field Name=title>Mr</Field> <Field Name=surname>Doe</Field> <Row>
I have some XML files and schemas that I would like to document. Everything
I have some sort of ... xml document as below : <file src=136090000-136100000> <member
I have some XML where I would like to remove identical consecutive child nodes,
I have an Xml like this: <root> <item> <content type=HTML> <![CDATA[<html> <head></head> <body>something goes
I have some working Javascript code that generates an RDF/XML document using variables picked
I have an xml document that contains some html. <begin-line> <verse-num>6</verse-num>a mixed people<footnote id=f2>

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.