This is basically the coding structure you need, although you can use variables or named templates to avoid duplicating the code in the two branches.
 
The Saxon list is intended for questions specific to the Saxon product: for general XSLT coding questions, I would recommend the xsl-list at mulberrytech.com.
 
Michael Kay


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Néstor Boscán
Sent: 27 April 2004 02:56
To: saxon-help@lists.sourceforge.net
Subject: [saxon] How to insert an element depending in a condition

Hi
 
I would like to insert an element in the result xml based on a condition. For example if the condition is true
 
<element>
... continue to process ...
</element>
 
if the condition is false:
 
... continue to process ...
 
I'm basically doing this processing like this:
 
<xsl:choose>
  <xsl:when test="condition">
    <element>
      ... continue to process ...
    </element>
  </xsl:when>
  <xsl:when>
    ... continue to process ...
  </xsl:when>
</xsl:choose>
 
I wanted to know if there is an easier way?