<xsl:template match="node()|@*" mode="s2">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="s2"/>
</xsl:copy>
</xsl:template>
Tuesday, March 22, 2011
Capturing with child elements in pipeline
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>
Friday, February 18, 2011
Handling Comments and processing-instruction in XSLT
<xsl:template match="//comment()">
<xsl:comment>
<xsl:value-of select="."/>
</xsl:comment>
</xsl:template>
<xsl:template match="//processing-instruction()">
<xsl:processing-instruction name="{name()}">
<xsl:value-of select="."/>
</xsl:processing-instruction>
</xsl:template>
Friday, December 3, 2010
how to paste code to blogger
Copy and paste sourcecode onto : http://formatmysourcecode.blogspot.com/
It replaces any non-alphanumeric characters in your text, so you can then copy/paste it into your blog
Sunday, July 18, 2010
Create List of Elements from a XML file
<?xml version="1.0"encoding="UTF-8"?>
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="2.0">
<
<
</xsl:template>
<
<Doc>
<
<
<Xpath>
<xsl:for-eachselect="ancestor-or-self::node()[.]">
<xsl:iftest="name(.)!=''">
<xsl:text>/</
</xsl:if>
<xsl:value-ofselect="name(.)"/>
<xsl:variablename="attr" select="@*"/>
<xsl:iftest="$attr!=' '">
<
<
<
<
<
<
</xsl:if>
</xsl:for-each>
</
</
</Doc>
</
</xsl:stylesheet>
Tuesday, July 13, 2010
Create XSLT from XSLT
The below XSLT can be used to create a XSLT from a requirementXML.
KEY XML File
<doc>
<xpath-group><xpath>/catalog</xpath></XPATH-GROUP>
<xpath-group><xpath>/catalog/cd</xpath></XPATH-GROUP>
</doc>
XSLT FILE
<?xml:namespace prefix = xsl /><xsl:stylesheetversion="2.0" xsl="http://www.w3.org/1999/XSL/Transform"axsl="http://www.w3.org/1999/XSL/Transform/alias">
<xsl:variablename="XpLocCat"></xsl:variable>
<xsl:output method="xml"></xsl:output>
<xsl:namespace-aliasprefix="xsl"></xsl:namespace-alias>
<xsl:template match="/">
<?xml:namespace prefix = axsl /><axsl:stylesheetversion="2.0"xsl="http://www.w3.org/1999/XSL/Transform">
<axsl:outputmethod="xml"></axsl:output>
<axsl:template match="* @*">
<axsl:copy>
<axsl:apply-templatesselect="@*"></axsl:apply-templates>
<axsl:apply-templates></axsl:apply-templates>
</axsl:copy>
</axsl:template>
<xsl:apply-templates></xsl:apply-templates>
</axsl:stylesheet>
</xsl:template>
<xsl:template match="/Doc">
<xsl:for-each select="/Doc/Xpath-Group">
<axsl:template match="{Xpath}">
<xsl:element name="{XpathNew}">
<axsl:apply-templatesselect="@*"></axsl:apply-templates>
<xsl:if test="XpathCon!=''">
<axsl:apply-templatesselect="{XpathCon}"></axsl:apply-templates>
</xsl:if>
<xsl:if test="XpathCon=''">
<axsl:apply-templates></axsl:apply-templates>
</xsl:if>
</xsl:element>
</axsl:template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>