xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benoit Fouche" <b.fou...@cross-systems.com>
Subject XSL: howto test if an element have a child ?
Date Wed, 12 Apr 2000 11:35:11 GMT
Hi !
I am currently applying XSL stylesheet to an XML doc to generate WML (=HTML
for WAP)

My XML doc looks like this (and must be like this, I can't change the
structure nor the attributes...) :

    <select name="sites">
        <option url="http://www.yahoo.com">Yahoo</option>
        <option url="http://www.caramail.com">Caramail</option>

    <select name="prefixes">
        <option value="prefix">Mr.</option>
        <option value="prefix">Mrs.</option>

    <select name="activities" multiple="true">
        <option value="activity">sport</option>
        <option value="activity">cinema</option>

In the tag option, you can have several differents attributes, so I would
like to make a test on those attribute like this:
I would like to do the following algorithm in XSL:

For all the "select/option" tag where the option@url DOESN'T exists I would
like to output a copy of the select tag:
    <select (with the EXACT copy of  the attributes of select tag)>
        <option value=...>
And for the "select/option" tag where the option@url exists I just want to
output a link:
    <a href=value-of select="@url">value-of option</a>
   (without the "select" tag, here is the problem...)

My steelsheet looks like this, but doesn't work (parser crashes...) :

<xsl:template match="option[@url]">
 <a><xsl:attribute name="href"><xsl:value-of

<xsl:template match="select">
  <xs:when test="option[@url]"/>
            <xsl:apply-templates select="*|@*|comment()|pi()|text)"/>

any help would be great !

View raw message