← Prev in month ← Prev in thread

XSLT stylistics query

From
Simon Kissane <>
To
Date
2005-02-08T06:45:52Z
ID
<>
Thread
XSLT stylistics query
Hi,

When I write XSL stylesheets, I often find myself writing code like
the following sample:

<xsl:template name="check-root-sections">
<xsl:for-each select="document($cfgschema)/ConfigSchema/RootSection">
<xsl:variable name="SectName" select="@Name" />
<xsl:variable name="SectType" select="@Type" />
<xsl:variable name="SectTypeDef"
select="document($cfgschema)/ConfigSchema/SectionType[@Name=$SectType]"
/>
<xsl:variable name="SectInstance"
select="document($srcdoc)/Config/Section[@Name=$SectName]" />
....

Notice that I declare these two variables, $SectName and $SectType. My
purpose in doing
so is because inside the [ ... ] operator, according to my
understanding, the context node changes to the node before the
operator. So, if I want to find something in my original context node,
before the [ ], I need to assign it to a variable first. (In fact, in
the above example, the two context nodes belong to entirely different
documents...)

Is there a cleaner way of doing this? Some XPath syntax to enable me
to say "the context node previous to the current top of stack..."? If
there was such a syntax, my code would be a lot cleaner, since I
wouldn't need so many variable declarations.

Cheers
Simon Kissane
← Prev in month ← Prev in thread