Project

Profile

Help

Bug #2478 » sample.xslt

Markus Lauer, 2015-10-20 23:38

 
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:accumulator name="state" initial-value="()">
<xsl:accumulator-rule match="*" phase="end" select="($value, concat(name(),')'))"/>
<xsl:accumulator-rule match="*" phase="start" select="($value, concat('(',name()))"/>
</xsl:accumulator>


<xsl:template match="/">
<root>
<start state="{accumulator-before('state')}"/>
<xsl:apply-templates select="*"/>
<end state="{accumulator-after('state')}"/>
</root>
</xsl:template>

<xsl:template match="*">
<start name="{name()}" state="{accumulator-before('state')}"/>
<xsl:apply-templates select="*"/>
<end name="{name()}" state="{accumulator-after('state')}"/>

</xsl:template>

</xsl:stylesheet>
(2-2/4)