[xsl] variable matching...

Subject: [xsl] variable matching...
From: James Cummings <James.Cummings@xxxxxxxxxxxxxx>
Date: Mon, 8 Dec 2003 11:40:03 +0000 (GMT)
Hi there,

Let's say I have many different files, all with similar-but-differing
markup all of which I'm converting to the same structure.  In this case,
let's say I'm looking at plays so everything has the same basic
structure (acts, scenes, speeches, lines, stage directions).  Is there
a way of using variables (or parameters) to make transforming the names
easier without continually editing the main templates throughout the

file a:
<title>A test file</title>
<Act><head>Act 1</head>
    <sd>Enter somebody</sd>
     <speech actor="foo">
      <line>This is a line</line>...

file b:
<t>A test file</t>
<A><h1>Act 1</h1>
    <stagedir>Enter somebody</stagedir>
     <lines actor="foo">
      <l>This is a line</l>...

These have basically the same structure, but with differing element

Is there a way for me to do something like:

<xsl:variable name="title">title</xsl:variable>
<xsl:variable name="act">Act</xsl:variable>
<xsl:variable name="scene">scene</xsl:variable>
<xsl:variable name="stage">sd</xsl:variable>

for the first file and then change the xsl it (or
pass these as parameters instead):

<xsl:variable name="title">t</xsl:variable>
<xsl:variable name="act">A</xsl:variable>
<xsl:variable name="scene">scn</xsl:variable>
<xsl:variable name="stage">stagedir</xsl:variable>

And do something like

<xsl:template match="$stage">

I think this is not allowed, but was wondering if
there was a way (xslt2 acceptable) to do this kind
of thing?  I suppose instead of variables or parameters,
a secondary xml file would be another option.

Obviously I don't want to just do:
<xsl:template match="sd|stagedir">
because sometimes one file will use an element name
that conflicts with another file's use of it.

I'm really looking for an easy way to not have to
customise the main bit of the xslt for each and every


Dr James Cummings, Oxford Text Archive, James.Cummings@xxxxxxxxxxxxxx

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

Current Thread