[xsl] Conditional initialisation of variable outside a template: just checking

Subject: [xsl] Conditional initialisation of variable outside a template: just checking
From: "Michael Beddow" <mbnospam@xxxxxxxxxxx>
Date: Sat, 11 Aug 2001 11:30:03 +0100
Can I just check up that I've got the right idea about something?

I have a sheet that needs to initialise a variable that will be in scope
in all
templates. I was doing this near the top of the sheet with

<xsl:variable name="mainID" select ="//body//div/@id"/>

Fine. But now I'm gettimg data that disregards the project's encoding
guidelines and uses div1 in the place of div. Since I know I can't use
<xsl:choose> or <xsl:if> outside a template for a conditional
initialisation,
I came up with this

<xsl:variable name="mainID" select ="//body//div1/@id |
//body//div/@id"/>

which works in all the cases I've tried. But am I storing up some sort
of problem for myself, and if so, is there a better way?

Michael
---------------------------------------------------------
Michael Beddow   http://www.mbeddow.net/
XML and the Humanities page:  http://xml.lexilog.org.uk/
---------------------------------------------------------



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


Current Thread