This is XML Document.
<w:document xmlns:w="w">
<w:body>
<w:p>
<w:pPr>
<w:pStyle w:val="Normal"/>
</w:pPr>
<w:r>
<w:t>
Para1
</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
</w:pPr>
<w:r>
<w:t>
Para2
</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading2"/>
</w:pPr>
<w:r>
<w:t>
Para3
</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
</w:pPr>
<w:r>
<w:t>
Para4
</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading2"/>
</w:pPr>
<w:r>
<w:t>
Para5
</w:t>
</w:r>
</w:p>
<w:tbl>
<w:tr>
<w:tc>
<w:p>
<w:r>
<w:t>
Para6
</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p>
<w:r>
<w:t>
Para7
</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
</w:pPr>
<w:r>
<w:t>
Para8
</w:t>
</w:r>
</w:p>
<w:tbl>
<w:tr>
<w:tc>
<w:p>
<w:r>
<w:t>
Para9
</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p>
<w:r>
<w:t>
Para10
</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading2"/>
</w:pPr>
<w:r>
<w:t>
Para11
</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
Now ,
-
i want to search first
<w:p><w:pPr><w:pStyle>that having it’sw:valattribute value starting with “Heading”. -
After finding this, assign that attribute value(for example,Heading1 which is in the 2nd
<w:p><w:pPr><w:pStyle>) to a variable(for example,variableName in xslt file). -
Assign that variable(for example,topLevelHeadings in xslt file) into my specific another variable where i wanted.
This is Xslt File for your reference…
<xsl:template match="*">
<Document>
<xsl:variable name="variableName" select="?"/> <!-- here i want the stuff -->
<xsl:variable name="topLevelHeadings" select = "//w:body/w:p[w:pPr[w:pStyle(@w:val,'$variableName')]]"/>
<xsl:choose>
<xsl:when test="$topLevelHeadings">
<!-- Do things here -->
</xsl:when>
<xsl:otherwise>
<!-- Do things here -->
</xsl:otherwise>
</xsl:choose>
</Document>
</xsl:template>
Please Guide me to get out of this issue…
1 Answer