This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: <xsl:choose>'ing from different forms of a tag
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 17 Jul 2002 19:02:34 +0100
- Subject: RE: [xsl] <xsl:choose>'ing from different forms of a tag
- Reply-to: xsl-list at lists dot mulberrytech dot com
Firstly, if the outermost thing in a template rule is a <choose>, then
it probably makes sense to have one template rule for each case.
It looks to me as if your three rules are:
<xsl:template match="term[_literal_='*']">
<xsl:template match="term[_literal_='/']">
<xsl:template match="term[not(_literal_)]">
This looks like an interesting use case for the proposed XSLT 2.0
feature allowing template rules to match elements by schema-defined type
rather than by name or by content. The main difficulty is that the
relevant types are often anonymous, so the stylesheet can't refer to
them easily. I'd be interested to see what your schema actually looks
like.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of
> xml@kinowin.zeddiclan.com
> Sent: 17 July 2002 18:25
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] <xsl:choose>'ing from different forms of a tag
>
>
> 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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list