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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:43:29+00:00 2026-05-26T23:43:29+00:00

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

  • 0

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 w:val="Heading1"/>
      </w:pPr>
      <w:r>
        <w:t>Tables</w:t>
      </w:r>
    </w:p>

    <w:p>
      <w:r>
        <w:t>Table1</w:t>
      </w:r>
    </w:p>

    <w:tbl>
      <w:tr>
        <w:tc>
          <w:p>
            <w:r>
              <w:t>row1col1</w:t>
            </w:r>
          </w:p>
        </w:tc>
        <w:tc>
          <w:p>
            <w:r>
              <w:t>row1col2</w:t>
            </w:r>
          </w:p>
        </w:tc>
      </w:tr>

      <w:tr>
        <w:tc>
          <w:p>
            <w:r>
              <w:t>row2col1</w:t>
            </w:r>
          </w:p>
        </w:tc>

        <w:tc>
          <w:p>
            <w:r>
              <w:t>row2col2</w:t>
            </w:r>
          </w:p>
        </w:tc>
      </w:tr>
    </w:tbl>

    <w:p>
      <w:r>
        <w:t>Table2</w:t>
      </w:r>
    </w:p>

    <w:tbl>
      <w:tr>
        <w:tc>
          <w:p>
            <w:r>
              <w:t>row11col11</w:t>
            </w:r>
          </w:p>
        </w:tc>

        <w:tc>
          <w:p>
            <w:r>
              <w:t>row11col12</w:t>
            </w:r>
          </w:p>
        </w:tc>
      </w:tr>

      <w:tr>
        <w:tc>
          <w:p>
            <w:r>
              <w:t>row12col11</w:t>
            </w:r>
          </w:p>
        </w:tc>

        <w:tc>
          <w:p>
            <w:r>
              <w:t>row12col12</w:t>
            </w:r>
          </w:p>
        </w:tc>
      </w:tr>
    </w:tbl>
  </w:body>
</w:document>

and i want to transform this xml document into below mentioned format using my xslt file.

<Document>
<Heading1>
<title>Tables</title>
<paragraph>Table1</paragraph>
<table>
   <paragraph>row1col1</paragraph>
   <paragraph>row1col2</paragraph>
   <paragraph>row2col1</paragraph>
   <paragraph>row2col2</paragraph>
</table>
<paragraph>Table2</paragraph>
<table>
   <paragraph>row11col11</paragraph>
   <paragraph>row11col12</paragraph>
   <paragraph>row12col11</paragraph>
   <paragraph>row12col12</paragraph>
</table>
</Heading1>
</Document>

This is my XSLT File for your reference…

<?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"
                              xmlns:fn="http://www.w3.org/2005/xpath-functions">

  <xsl:output method="html" indent="yes"/>

  <xsl:template match="*">

    <Document>

      <xsl:variable name="headingName" select="(//w:body/w:p/w:pPr/w:pStyle[starts-with(@w:val, 'Heading')])[1]/@w:val"/>
      <xsl:variable name="topLevelHeadings" select = "//w:body/w:p[w:pPr/w:pStyle/@w:val = $headingName]"/>

      <xsl:choose>

        <xsl:when test="$topLevelHeadings">
          <xsl:apply-templates select="$topLevelHeadings">
          </xsl:apply-templates>
        </xsl:when>

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


  <xsl:template match="w:p">
    <Paragraph>
      <xsl:apply-templates select="./w:r/w:t"/>
    </Paragraph>
    <xsl:apply-templates select="descendant::w:p">
    </xsl:apply-templates>
  </xsl:template>


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



  <xsl:template match="//w:body/w:p[w:pPr[w:pStyle[starts-with(@w:val,'Heading')]]]">

    <Heading1>
      <Title>
        <xsl:apply-templates select="./w:r/w:t"/>
      </Title>

      <xsl:choose>

        <xsl:when test="following-sibling::w:tbl//w:p[w:r[w:t]]">
          <xsl:for-each select="following-sibling::w:tbl">

            <table>
              <xsl:apply-templates select="descendant::w:p ">
              </xsl:apply-templates>
            </table>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="descendant::w:p">
            <!-- | following-sibling::w:tbl//w:p[w:r[w:t]]-->
          </xsl:apply-templates>
        </xsl:otherwise>

      </xsl:choose>

      <xsl:apply-templates select="following-sibling::w:p[w:r and not(w:pPr[w:pStyle])] | following-sibling::w:p[w:r and not(w:pPr[w:pStyle[starts-with(@w:val,'Heading')]])]">
      </xsl:apply-templates>

      <xsl:variable name="nextHead" select="concat('Heading', number(substring-after('Heading1', 'Heading'))+1)"/>

      <!-- Get a list of child nodes (headings) for the current node -->
      <xsl:variable name="nextLevelHeadings" select="following-sibling::w:p[w:pPr[w:pStyle[@w:val=$nextHead]]]"/>

      <!-- Apply recursively for next level headings within the scope -->
      <xsl:apply-templates select="$nextLevelHeadings">
      </xsl:apply-templates>

      <!-- Close heading tag -->
    </Heading1>

  </xsl:template>
</xsl:stylesheet>

But the output is :

<Document>
<Heading1>
 <Title>Table Manipulation</Title>
  <table>
       <paragraph>row1col1</paragraph>
       <paragraph>row1col2</paragraph>
       <paragraph>row2col1</paragraph>
       <paragraph>row2col2</paragraph>
  </table>
  <table>
       <paragraph>row11col11</paragraph>
       <paragraph>row11col12</paragraph>
       <paragraph>row12col11</paragraph>
       <paragraph>row12col12</paragraph>
 </table>
  <Paragraph>Table1</Paragraph>
  <Paragraph>Table2</Paragraph>
  </Heading1>
</Document>

So, Please Guide me to get this issue and it will be work like my above said output requirement.Because, i want to transform this xml file without changing order of the paragraphs or tables.

Thanks & Regards,
p.saravanan

  • 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-26T23:43:30+00:00Added an answer on May 26, 2026 at 11:43 pm

    I have completed that task and thank you all for your co-operation in this…

    i just attached modified xslt file that is working absolutley fine…

    <?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"
                                  xmlns:fn="http://www.w3.org/2005/xpath-functions">
    
      <xsl:output method="html" indent="yes"/>
    
      <xsl:template match="*">
    
        <Document>
    
          <xsl:variable name="headingName" select="(//w:body/w:p/w:pPr/w:pStyle[starts-with(@w:val, 'Heading')])[1]/@w:val"/>
          <xsl:variable name="topLevelHeadings" select = "//w:body/w:p[w:pPr/w:pStyle/@w:val = $headingName]"/>
    
          <xsl:choose>
    
            <xsl:when test="$topLevelHeadings">
              <xsl:apply-templates select="$topLevelHeadings">
              </xsl:apply-templates>
            </xsl:when>
    
            <xsl:otherwise>
              <xsl:apply-templates select="//w:p[w:r[w:t]]">
              </xsl:apply-templates>
            </xsl:otherwise>
          </xsl:choose>
        </Document>
      </xsl:template>
    
    
      <xsl:template match="w:p">
        <Paragraph>
          <xsl:apply-templates select="./w:r/w:t"/>
        </Paragraph>
        <xsl:apply-templates select="descendant::w:p">
        </xsl:apply-templates>
      </xsl:template>
    
    
      <xsl:template match="w:t">
        <xsl:value-of select="."/>
      </xsl:template>
    
    
    
      <xsl:template match="//w:body/w:p[w:pPr[w:pStyle[starts-with(@w:val,'Heading')]]]">
    
        <Heading1>
          <Title>
            <xsl:apply-templates select="./w:r/w:t"/>
          </Title>
    
         <xsl:for-each select="following-sibling::*">
            <xsl:choose>
              <xsl:when test="descendant::w:p">
                <table>
                  <xsl:apply-templates select="descendant::w:p ">
                  </xsl:apply-templates>
                </table>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="self::w:p[w:r and not(w:pPr[w:pStyle])] | self::w:p[w:r and not(w:pPr[w:pStyle[starts-with(@w:val,'Heading')]])]">
                </xsl:apply-templates>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:for-each>
    
          <!--<xsl:apply-templates select="following-sibling::w:p[w:r and not(w:pPr[w:pStyle])] | following-sibling::w:p[w:r and not(w:pPr[w:pStyle[starts-with(@w:val,'Heading')]])]">
          </xsl:apply-templates>-->
    
          <xsl:variable name="nextHead" select="concat('Heading', number(substring-after('Heading1', 'Heading'))+1)"/>
    
          <!-- Get a list of child nodes (headings) for the current node -->
          <xsl:variable name="nextLevelHeadings" select="following-sibling::w:p[w:pPr[w:pStyle[@w:val=$nextHead]]]"/>
    
          <!-- Apply recursively for next level headings within the scope -->
          <xsl:apply-templates select="$nextLevelHeadings">
          </xsl:apply-templates>
    
          <!-- Close heading tag -->
        </Heading1>
    
      </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my 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> <!--
This is my XML document <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:v="urn:schemas-microsoft-com:vml"> <w:body> <w:p>
<?xml version=1.0 encoding=UTF-8 standalone=yes?> <w:document xmlns:ve=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:o=urn:schemas-microsoft-com:office:office xmlns:r=http://schemas.openxmlformats.org/officeDocument/2006/relationships xmlns:m=http://schemas.openxmlformats.org/officeDocument/2006/math xmlns:v=urn:schemas-microsoft-com:vml xmlns:wp=http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing xmlns:w10=urn:schemas-microsoft-com:office:word xmlns:w=http://schemas.openxmlformats.org/wordprocessingml/2006/main xmlns:wne=http://schemas.microsoft.com/office/word/2006/wordml>
This is my XML Document(Small Snippt). <?xml version=1.0 encoding=UTF-8 standalone=yes?> <w:document xmlns:w=http://schemas.openxmlformats.org/wordprocessingml/2006/main> <w:body> <w:p>
I have the following XML document <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009' gd:etag='W/DEAERH47eCl7ImA9WhZTFEQ.'><id>http://code.google.com/feeds/issues/p/chromium/issues/full/921</id><published>2008-09-03T22:51:22.000Z</published><updated>2011-03-19T01:05:05.000Z</updated><title>Incorrect rendering</title><content
I have the following XML: <?xml version=1.0 encoding=UTF-8 standalone=yes?> <application xmlns=http://research.sun.com/wadl/2006/10> <doc xmlns:jersey=http://jersey.dev.java.net/ jersey:generatedBy=Jersey:
I have example.xml <?xml version=1.0 encoding=UTF-8 standalone=no?> <Document xmlns=urn:iso:std:iso:20022:tech:xsd:pain.001.001.02> <content> <books> <book> <qty>12</qty> <title>C++</title>
I have a simple xml file that looks like this: <?xml version=1.0 encoding=UTF-8 standalone=yes
I have generated this WSDL file... <?xml version=1.0 encoding=UTF-8 standalone=yes?> <!-- Generated by JAX-WS
Is this a valid (well-formed) XML document? <?xml version=1.0 encoding=UTF-8 ?> <outer> <inner>&copy;</inner> </outer>

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.