[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: variable matching...

Subject: Re: variable matching...
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 8 Dec 2003 12:18:33 GMT
Re:  variable matching...

<xsl:template match="$stage">

Your stage variable contains a result tree fragment (or in xslt2 a node set
consisting of a single document node which has a text node child with
value "stagedir") neither of these is an Xpath pattern, so neither can be
used in a match attribute.

In XSLT 2 however you could do

<xsl:template match="*[name()=$stage]"

as the annoying restriction of not allowing variables in match patterns
is planned to be dropped.

An alternative approach of course, is rather than try to paramaterise
your tempates so they work for all inputs, do a two pass system that
normalises the input.

ie have a main stylesheet that does

<xsl:template match="title">....

then to customise for your second form, in stead of doing this:
<xsl:variable name="stage">stagedir</xsl:variable>

do this

<xsl:template mode="normalise" match="t">
<title>
<xsl:apply-templates mode="normalise"/>
</title>
</xsl:template>

This is more flexible as it can cope with differences in structure that
are slightly greater than just element renaming.

If on the other hand the structures are really identical you might not
need names at all eg your two examples could be handles using patterns
of

match="body/*[1]"                   (t or title)
match="body/*[position() &gt; 1]"   (A or Act)
match="body/*/*"                    (scn or scene)


etc

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.