[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] variable matching...
Subject: Re: [xsl] variable matching... From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 8 Dec 2003 12:18:33 GMT |
<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() > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] variable matching..., James Cummings | Thread | Re: [xsl] variable matching..., James Cummings |
Re: [xsl] variable matching..., Frédéric Laurent | Date | RE: [xsl] variable matching..., James Cummings |
Month |