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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:29:06+00:00 2026-06-09T05:29:06+00:00

I have an input xml as below <maindocument> <first> <testing>random text</testing> <checking>random test</checking> </first>

  • 0

I have an input xml as below

<maindocument>
<first>
<testing>random text</testing>
<checking>random test</checking>
</first>
<testing>
<testing>sample</testing>
<checking>welcome</checking>
<import>
<downloading>valuable text</downloading>
</import>
</testing>
</maindocument>

The output here i want the same output like below

<maindocument>
<import>
<doctype>Valuable</doctype>
<docint>text</docint>
</import>
</maindocument

I am trying for the above code in xslt With the help of absolute path and relative path my question is how i will get into testing element then i have to select import element from there.

Please guide me

Regards
Karthic

  • 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-09T05:29:07+00:00Added an answer on June 9, 2026 at 5:29 am
    With the help of absolute path and relative path my question is how i will get into testing element then i have to select import element from there.
    

    Actually, there is no need to specify a complete path to testing and check that it has an import child.

    The XSLT processing model (built-in templates), combined with your templates and proper template match patterns, does the navigation for you.

    The built-in templates are selected for execution if there is no explicit template that matches a particular node. he cumulative result of applying the built-in templates is that the document tree is traversed and only text nodes are output.

    One can specify templates to override the built-in ones only for nodes that should be processed in a different, specific way. When the built-in templates apply templates for a child of a node and there is explicit (user-provided) template matching that node, this explicit template is selected for execution/processing of that node.

    This short XSLT 1.0 transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="/">
         <maindocument>
            <xsl:apply-templates/>
         </maindocument>
     </xsl:template>
    
     <xsl:template match="import/downloading">
      <import>
        <doctype><xsl:value-of select="substring-before(., ' ')"/></doctype>
        <docint><xsl:value-of select="substring-after(., ' ')"/></docint>
      </import>
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when applied on the provided XMLdocument:

    <maindocument>
        <first>
            <testing>random text</testing>
            <checking>random test</checking>
        </first>
        <testing>
            <testing>sample</testing>
            <checking>welcome</checking>
            <import>
                <downloading>valuable text</downloading>
            </import>
        </testing>
    </maindocument>
    

    produces the wanted, correct result:

    <maindocument>
       <import>
          <doctype>valuable</doctype>
          <docint>text</docint>
       </import>
    </maindocument>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input XML as below <testing> <subject ref=yes> <firstname> tom </firstname> </subject>
I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>
I have a query in the xml and xslt The below is the Input
Below is My input XML <First> <practice-session note=yes> <lessons>13000</lessons> <lessons>15000</lessons> <lessons>note</lessons> </practice-session> <practice-repeats note=yes>>
I have an input xml as follows, <?xml version=1.0 encoding=utf-8 ?> <?xml-stylesheet type=text/xsl href=cdcatalog.xsl?>
I have an XML input as shown below: <?xml version=1.0 encoding=utf-8?> <Content> <section name=FileID/>
i have input xml as <content> <date> <day>14</day> <month>06</month> <year>2012</year> </date> </content> want it
This is my input xml. The xml can have maximunm three nodes and minimum
I have this use case of an xml file with input like Input: <abc
I have written xml file which contains html tags as element like <component> <input

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.