I want to convert one xml format to another specified format by using xslt. This is my Xml File.I have to create some dynamic xml element by using some type of recursive call in xslt.
<?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:pPr>
<w:r>
<w:t>Text1-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1" />
</w:pPr>
<w:r>
<w:t>Text2-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
</w:pPr>
<w:r>
<w:t>Text3-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
</w:pPr>
<w:r>
<w:t>Text4-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading2" />
</w:pPr>
<w:r>
<w:t>Text5-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
</w:pPr>
<w:r>
<w:t>Text6-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading3" />
</w:pPr>
<w:r>
<w:t>Text7-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
</w:pPr>
<w:r>
<w:t>Text8-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1" />
</w:pPr>
<w:r>
<w:t>Text9-</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
</w:pPr>
<w:r>
<w:t>Text10-</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
And my required output xml is :
<Document>
<Paragraph>Text1-</Paragraph>
<Heading1>
<Title>Text2-</Title>
<Paragraph>Text3-</Paragraph>
<Paragraph>Text4-</Paragraph>
<Heading2>
<Title>Text5-</Title>
<Paragraph>Text6-</Paragraph>
<Heading3>
<Title>Text7-</Title>
<Paragraph>Text8-</Paragraph>
</Heading3>
</Heading2>
<Heading1>
<Heading1>
<Title>Text9-</Title>
<Paragraph>Text10-</Paragraph>
<Heading1>
</Document>
Please Guide me a way to get out of this issue…
Here is a sample stylesheet:
When applied with Saxon 9.4 on your sample input document I get the following result: