Subject: RE: [xsl] outputing a non existant element. From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Wed, 12 Sep 2001 20:54:31 +0100 |
> i have one optional element in my schema-file say: > <fruit>orange</fruit>.The default value of fruit is > "apple".I would like to have a xslt-transformation > which gives me the content of the fruit element if it > appears in the xml-file or its default value if it > doesn't appear. The simple answer is <xsl:choose> <xsl:when test="fruit"><xsl:value-of select="fruit"/></xsl:when> <xsl:otherwise>apple</xsl:otherwise> </xsl:choose> If you prefer brevity to clarity, you can write <xsl:value-of select="concat(fruit, substring('apple', 1, not(fruit)*5) Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] outputing a non existant , Jörg Heinicke | Thread | [xsl] Sorting Problem, Dev Chandramani |
RES: [xsl] Selecting an option, Carlos Durand Silves | Date | Re: [xsl] Selecting an option, Jörg Heinicke |
Month |