xsl-list
[Top] [All Lists]

Re: Writing an optional element

2004-07-05 12:41:53
"Nestor" == Nestor Boscan 
<nestor(_dot_)boscan(_at_)tcs(_dot_)com(_dot_)ve> writes:

    Nestor> Hi I have an XSL template that has to write an element
    Nestor> depending on a condition.
 
    Nestor> If Condition is true
 
    Nestor> <element> ... continue processing ...  </element>
 
    Nestor> If Condition is false
 
    Nestor> ... continue processing ...
 
    Nestor> Is there a better way to do it than:
 
    Nestor> <xsl:choose> <xsl:when test="condition"> <element>
    Nestor> ... processing instructions ...  </element> </xsl:when>
    Nestor> <xsl:otherwise> ... repeat processing instructions ...
    Nestor> </xsl:otherwise> </xsl:choose>
 
If by a better way, you mean you want to avoid writing the same
"continue processing" code, then you could call a named template
each time. Said named template to contain the common code.
-- 
Colin Paul Adams
Preston Lancashire


<Prev in Thread] Current Thread [Next in Thread>