This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: <xsl:choose>'ing from different forms of a tag


xml@kinowin.zeddiclan.com wrote:

Hi,

I have an XSD file that uses a xsd:union to allow the tag <term> to have
one of three different sequences. In particular, <term> can be of any
of the following:

(1) <term>
<term>...</term>
<_literal_>*</_literal_>
<factor>...</factor>
</term>


(2) <term>
<term>...</term>
<_literal_>/</_literal>
<factor>...</factor>
</term>


(3) <term>
<factor>...</factor>
</term>



My question is: when I write a templat for <term>, can I match against
the different sequences? For example, I would like to write a
transform like:

<xsl:template match="term">
<xsl:choose>

<xsl:when test="[ somehow test for form (1) ]">
(do stuff)
</xsl:when>


<xsl:when test="[ somehow test for form (2) ]">
(do different stuff)
</xsl:when>


<xsl:when test="[ somehow test for form (3) ]">
(do completely different stuff)
</xsl:when>


<xsl:otherwise>
(never get here, no other forms are allowed)
</xsl:otherwise>

</xsl:choose>
</xsl:template>

I don't know what to put in the test="..." areas though. Any ideas?

Thanks,

Jared



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


.


You can use test=" name(*[1])='term' " style conditions
Also possible (I think) test=" *[1]/self::term "
None are tested.

However, if there is no common treatment to all three forms, that you could factor outside the xsl:choose, I would suggest you to use three different templates. Something like:

<xsl:template match=" term[*[1]/self::term and *[2]/self::literal = '*' ] ">

Antonio Fiol


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]