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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:58:41+00:00 2026-06-06T04:58:41+00:00

This is my Xml file.i want to transform this xml file into another customized

  • 0

This is my Xml file.i want to transform this xml file into another customized xml file by using xslt.

XML FILE:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
    <w:body>
    <w:p>
        <w:r>
            <w:t>Text1-</w:t>
        </w:r>
        <w:smartTag>
            <w:smartTag>
                <w:smartTag>
                    <w:smartTag>
                        <w:r>
                            <w:t>Text2-</w:t>
                        </w:r>
                    </w:smartTag>
                </w:smartTag>
                <w:r>
                    <w:t>Text3-</w:t>
                </w:r>
                <w:smartTag>
                        <w:r>
                            <w:t>Text4-</w:t>
                        </w:r>
                </w:smartTag>
                <w:r>
                    <w:t>Text5-</w:t>
                </w:r>
            </w:smartTag>
        </w:smartTag>
        <w:r>
            <w:t>Text6-</w:t>
        </w:r>
    </w:p>
    </w:body>
    </w:document>

and MY XSLT Snippt is :

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">                              
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="*">

    <Document>
        <xsl:choose>
            <xsl:apply-templates select="//w:p[w:r[w:t]]">
            </xsl:apply-templates>      
      </xsl:choose>
    </Document>
  </xsl:template>


  <xsl:template match="w:p">
    <Paragraph>

     <xsl:if test="(.//w:smartTag/w:r/w:t)">
            <xsl:apply-templates select="//w:smartTag//w:r//w:t"/>
     </xsl:if>
    <xsl:apply-templates select="./w:r/w:t"/>
    </Paragraph>    
  </xsl:template>


  <xsl:template match="w:t">
    <xsl:value-of select="."/>
  </xsl:template>
  </xsl:stylesheet>

My Current Output is :

<Document>
<Paragraph>
       Text2-Text3-Text4-Text5-Text1-Text6-
</Paragraph>
</Document>

My Required Output is :

<Document>
    <Paragraph>
           Text1-Text2-Text3-Text4-Text5-Text6-
    </Paragraph>
</Document>

Please Guide me to get the elements without losing the order it preserves…

  • 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-06T04:58:42+00:00Added an answer on June 6, 2026 at 4:58 am

    Unless you have some extra rules about what should be processed, this could done quite simply by having a template to match w:t elements

    <xsl:template match="w:r/w:t">
       <xsl:value-of select="." />
    </xsl:template>
    

    You would also need matchs to handle the document and paragraph. Try the following XML

    <xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"    
     xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 
     exclude-result-prefixes="w">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:template match="/">
          <Document>
             <xsl:apply-templates />
          </Document>
       </xsl:template>
    
       <xsl:template match="w:p">
          <Paragraph>
             <xsl:apply-templates />
          </Paragraph>
       </xsl:template>
    
       <xsl:template match="w:r/w:t">
          <xsl:value-of select="." />
       </xsl:template>
    
       <!-- Ignore text for all other elements -->
       <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    When applied to your sample XML, the following is output

    <Document>
       <Paragraph>Text1-Text2-Text3-Text4-Text5-Text6-</Paragraph>
    </Document>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is XML Document. <?xml version=1.0 encoding=UTF-8 standalone=yes?> <w:document xmlns:w=http://schemas.openxmlformats.org/wordprocessingml/2006/main> <w:body> <w:p> <w:pPr> <w:pStyle
I am using XSLT to transform a XML into a html/php file. In this
I want to convert one xml file into another xml file using xslt.here, i
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have this simple XML file : <?xml version=1.0 encoding=utf-8 ?> <Artists> <artist artistId=1>
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have an XML file that I want to transform using an XSLT. It
I have an xml file like this: <?xml version=1.0 encoding=UTF-8?> <todo> <list><item>first</item><item>second</item></list> <list><item>first</item><item>second</item></list> </todo>
i have xml file that looks like this: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE pointList SYSTEM
this is my xml file. i want to use xslt to transfer them into

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.