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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:39:35+00:00 2026-06-18T21:39:35+00:00

I have a input and desired output xml file , but not able to

  • 0

I have a input and desired output xml file , but not able to write generic xsl transformer for that. Can anybody here help me out ? address/billing may have more elements at runtime, which should be directly copied to main person block.

<searchPersonResponse>
 <persons>
  <person>
   <name>name2</name>
   <address>
   <billing>
     <city>xx</city>
     <state>yyyy</state>
     <zip>zzzzz</zip>
   </billing>
   </address>
  </person>
  <person>
    <name>name1</name>
    <address>
      <billing>
       <city>xx</city>
       <state>yyyy</state>
       <zip>zzzzz</zip>
      </billing>
    </address>
   </person>
  </persons>
 </searchPersonResponse>

desired output xml

<searchPersonResponse>
 <persons>
  <person>
     <name>name2</name>
     <city>xx</city>
     <state>yyyy</state>
     <zip>zzzzz</zip>
  </person>
  <person>
       <name>name1</name>
       <city>xx</city>
       <state>yyyy</state>
       <zip>zzzzz</zip>
   </person>
  </persons>
 </searchPersonResponse>
  • 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-18T21:39:37+00:00Added an answer on June 18, 2026 at 9:39 pm

    EDITED: OP is only looking to “unwrap” address and billing elements when address is present with a billing child. XSLT now does that. Also, OP mentions needs a XSLT 1.0 solution; no XSLT 2.0 features were being used, so I simply changed the version to “1.0”.

    This XSLT:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
        <xsl:template match="@*|node()">
            <xsl:copy>
                    <xsl:apply-templates/>
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="address[child::billing]|billing[parent::address]">
            <xsl:apply-templates/>
        </xsl:template>
    </xsl:stylesheet>
    

    When applied to this XML:

    <searchPersonResponse>
        <persons>
            <person>
                <name>name2</name>
                <address>
                    <billing>
                    <city>xx</city>
                    <state>yyyy</state>
                    <zip>zzzzz</zip>
                    </billing>
                </address>
            </person>
            <person>
                <name>name1</name>
                <address>
                    <billing>
                    <city>xx</city>
                    <state>yyyy</state>
                    <zip>zzzzz</zip>
                    </billing>
                </address>
            </person>
        </persons>
    </searchPersonResponse>
    

    Produces the desired result:

    <searchPersonResponse>
        <persons>
            <person>
                <name>name2</name>
                <city>xx</city>
                <state>yyyy</state>
                <zip>zzzzz</zip>
            </person>
            <person>
                <name>name1</name>
                <city>xx</city>
                <state>yyyy</state>
                <zip>zzzzz</zip>
            </person>
        </persons>
    </searchPersonResponse>
    

    The identity template will copy all nodes and attributes. The address and billing matching template (which matches either element) will copy their children but not themselves.

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

Sidebar

Related Questions

Currently I have Input: e.g., '123456789'.'+'.'987654321' Desired Pattern: Output: e.g., '123456789987654321' How can I
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
I have a file that is supposed to be \n\n delimited, but of course
I have a file that contains entries sorted by timestamp, but which contains multiple
i have input xml as <content> <date> <day>14</day> <month>06</month> <year>2012</year> </date> </content> want it
I have an input string that will follow the pattern /user/<id>?name=<name> , where <id>
Hi I have an input as ID data 1 hello 2 sql The desired
I have a text input that I'd like to replace with a textarea, preserving
I have a text file as input like this:let say it as xyz.txt TIME
If I have input file containing statementes asda rertte something nothing here I want

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.