Keep tree stucture in XSL

umywua

New Member
I have the following document:\[code\]<Doc> <If cond="c"> <Expr>Expr1</Expr> </If> <Expr>Expr2</Expr></Doc>\[/code\]Which should create an output like this:\[code\]If c { Expr1 } Expr2\[/code\]However, in my case it creates:\[code\]Expr1 If c { Expr1 } Expr2\[/code\]I have the following XSLT:\[code\]<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:element name="Doc"> <xsl:apply-templates select="*" /> </xsl:element> </xsl:template> <xsl:template match="If"> <xsl:text>if </xsl:text><xsl:value-of select="@cond"/><xsl:text> {</xsl:text> <xsl:apply-templates select="Expr"/><xsl:text>}</xsl:text> </xsl:template> <xsl:template match="Expr"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="*"> </xsl:template></xsl:stylesheet>\[/code\]
 
Back
Top