[XSL-LIST Mailing List Archive Home]
Re: [xsl] Question about xsl:apply-imports
At 2009-09-10 18:27 -0700, Bill French wrote:
xsl:import is pretty awesome, let me say that right off.
I totally agree. Here is a paper describing the publishing system I
designed and implemented for publishing individual US intelligence
documents according to a common XSD using different skins for every
intelligence gathering agency (e.g. CENTCOM, STRATCOM, US Forces
South Korea, US Coast Guard, etc.) that heavily relies on xsl:import:
Note that the XSLStyle documentation methodology is very helpful in
documenting a multi-import/include stylesheet including an
alphabetized index of top-level named constructs and in which module
each construct is found:
But it sometimes yields surprising results.
I've found it very reliable when using Saxon. I've found it very
unreliable using Xalan and other XSLT processors (but of course I've
not tried them all).
I have a stylesheet called rendereddocument.xsl that imports a
number of other stylesheets using the xsl:import instructions:
in fields.xsl, I have a template defined as follows:
and in rendereddocument.xsl I have two templates that are defined as follows:
<xsl:template match="rm:document" priority="-0.1">
<xsl:template match="rm:associated" priority="-0.1">
In the last template, there's an xsl:imports instruction. The
element on which this template is matching, rm:associated, has
rm:document children. It's my understanding that xsl:apply-imports
should elect to apply the xsl:template defined in fields.xsl, not in
Not quite, but very close.
However, this isn't what's happening. Instead, the template matching
rm:document defined in rendereddocument.xsl is being applied.
Probably because of the way that rm:associated is being handled by
the imported stylesheets.
<xsl:imports> *re-applies* the last-matched node using only the
imported stylesheets ... so it is as if you wrote
<xsl:apply-templates select="."/> with imported stylesheets, it isn't
(as I think you've written above) an <xsl:apply-templates
select="node()"/> or <xsl:apply-templates/> with imported stylesheets.
So, to figure out what is happening in your situation, check out how
you are handling rm:associated in the imported stylesheets, and that
will probably tell you how rm:document is being pushed at your stylesheet.
Any help would be most appreciated. Let me know if you need to see
all the files. Last time, the issue was glaringly apparent from just
the first email. ;)
Hopefully you've found this just as helpful.
. . . . . . . . . . . Ken
Interested in these classes? http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal