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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:24:17+00:00 2026-05-25T19:24:17+00:00

This is my Xml File… <w:document> <w:body> <w:p> <w:r> <w:t> Paragraph1 </w:t> </w:r> </w:p>

  • 0

This is my Xml File…

<w:document>

        <w:body>

           <w:p>
                <w:r>
                    <w:t>
                      Paragraph1
                     </w:t>
                 </w:r>
             </w:p>
          </w:body>
</w:document>

This is my Second XML file…

 <w:document>
    <w:body>
        <w:p>
            <w:r>
               <w:pict>
                    <v:shape>
                       <v:textbox>
                           <w:txbxContent>
                              <w:p>
                                 <w:r>
                                    <w:t>
                                       Paragraph2
                                     </w:t>
                                 </w:r>
                                </w:p>
                             </w:txbxContent>
                           <v:textbox>
                        </v:shape>
                     </w:pict>
                  </w:r>
                </w:p>
              </w:body>
             </w:document>

Here, i have written one xslt file and calling my template whenever i found //w:body/w:p/w:r/w:t.

   for example,


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

my own template is

<xsl:template match="w:p">
            Do something here
       </xsl:template>

my xslt working correctly with my first xml document.But it is not working with second one and also some scenario like that.So, how can i achieve both of this scenario by modifying this query here…

<xsl:apply-templates select="?????"> <!-- how to find the case that also matching my second xml file -->
</xsl:apply-templates>

Please guide me get out of this issue…

  • 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-25T19:24:18+00:00Added an answer on May 25, 2026 at 7:24 pm

    Use:

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

    You may aso change the template’s match attribute to be slightly more specific:

    <xsl:template match="w:p[w:r/w:t]"> 
      <!-- Processing here -->
    </xsl:template> 
    

    Complete code:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:w="w:w">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="/">
       <xsl:apply-templates select="//w:p[w:r/w:t]"/>
     </xsl:template>
    
     <xsl:template match="w:p[w:r/w:t]">
      <xsl:value-of select="w:r/w:t"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the first provided XML document (namespace defined to make it well-formed):

    <w:document xmlns:w="w:w">
        <w:body>
            <w:p>
                <w:r>
                    <w:t>
                     Paragraph1
                 </w:t>
                </w:r>
            </w:p>
        </w:body>
    </w:document>
    

    the correct result is produced:

                 Paragraph1
    

    when the same transformation is applied on the second provided “XML” (it is severely malformed and I spent many minutes until I made it well-formed!!!):

    <w:document xmlns:w="w:w">
        <w:body>
            <w:p>
                <w:r>
                    <w:pict>
                        <v:shape xmlns:v="v:v">
                            <v:textbox>
                                <w:txbxContent>
                                    <w:p>
                                        <w:r>
                                            <w:t>
                          Paragraph2
                                            </w:t>
                                        </w:r>
                                    </w:p>
                                </w:txbxContent>
                            </v:textbox>
                        </v:shape>
                    </w:pict>
                </w:r>
            </w:p>
        </w:body>
    </w:document>
    

    again the wanted result is produced:

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

Sidebar

Related Questions

I have a xml file <events date=30/08/2010> <event> <title>here</title> <description> This is first Event
Say I have this given XML file: <root> <node>x</node> <node>y</node> <node>a</node> </root> And I
I have an xml file like this: <root> <item> <name>one</name> <status>good</status> </item> <item> <name>two</name>
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have this XML file: <Response> <errorCode>error Code</errorCode> <errorMessage>msg</errorMessage> <ResponseParameters> <className> <attribute1>a</attribute1> <attribute2>b</attribute2> </className>
I have this xml-file: <objects> <object> <value>test</value> </object> <object> <value>foo</value> </object> <object> <value>bar</value> </object>
So say I have this XML file: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root> <Category Name=Tasties>
I have this XML file, and I want to deserialize it to an object.
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> ...

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.