[Home] [By Thread] [By Date] [Recent Entries]
Hi,
You can use a template for each condition that triggers the generation of an element. The role of each such template will be to check its condition and emit the element to the output if the condition is met and in either case it will do some other processing required at that stage and then delegate to the template that checks the next condition. In your case you can have a template to check if the paragraph element should be present, a template for bold and a template for italic. <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="label"> <xsl:call-template name="checkParagraph"/> </xsl:template> <xsl:template name="checkParagraph"> <xsl:choose> <xsl:when test="@paragraph='true'"> <p> <span> <xsl:copy-of select="@align"/> <xsl:call-template name="checkBold"/> </span> </p> </xsl:when> <xsl:otherwise> <span> <xsl:copy-of select="@align"/> <xsl:call-template name="checkBold"/> </span> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="checkBold"> <xsl:choose> <xsl:when test="@bold='true'"> <b> <xsl:call-template name="checkItalic"/> </b> </xsl:when> <xsl:otherwise> <xsl:call-template name="checkItalic"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="checkItalic"> <xsl:choose> <xsl:when test="@italic='true'"> <b> <xsl:value-of select="."/> </b> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> Hope that helps, George ----------------------------------------------- George Cristian Bina <oXygen/> XML Editor & XSLT Editor/Debugger http://www.oxygenxml.com Tim Lord wrote: Hi,
|

Cart



