Pages

Showing posts with label Process XSLT step by step. Show all posts
Showing posts with label Process XSLT step by step. Show all posts

Monday, March 21, 2011

XSLT piping, Staging

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template match="/">
<xsl:variable name="fullxml">
<xsl:apply-templates/>
</xsl:variable>

<xsl:apply-templates select="$fullxml" mode="s2"/>
</xsl:template>

<xsl:template match="a">
<b>
<xsl:apply-templates/>
</b>
</xsl:template>


<xsl:template match="b" mode="s2">
<c>
<xsl:apply-templates mode="s2"/>
</c>
</xsl:template>

</xsl:stylesheet>



Input XML
<?xml version="1.0" encoding="UTF-8"?>
<element-group>
<a>Saai</a>
<a>121212</a>
<a>23232</a>
<a>vfvfvfv</a>
<a>frrfrf</a>
<a>bgbgbg</a>
<a>bgbgbgbg</a>
</element-group>




Stage one Output
<?xml version="1.0" encoding="UTF-8"?>
<b>Saai</b>
<b>121212</b>
<b>23232</b>
<b>vfvfvfv</b>
<b>frrfrf</b>
<b>bgbgbg</b>
<b>bgbgbgbg</b>


Stage Two Output
<?xml version="1.0" encoding="UTF-8"?>
<c>Saai</c>
<c>121212</c>
<c>23232</c>
<c>vfvfvfv</c>
<c>frrfrf</c>
<c>bgbgbg</c>
<c>bgbgbgbg</c>