This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: import/include and apply-imports


There can be more templates on the same element, when for instance making 
use of the xsl:import you can use apply-imports to make sure the template 
in the imported stylesheet are 2 processed.  Actually with the example 
given saxon outputs something diffrent than msxml.

msxml actually outputs what I too would have expected namely the "AM I EVER 
EVER MATCHED?"
string, where saxon does not.

If I replace the include second.xsl with the actual content of second.xsl, 
than saxon too outputs that particular string.

It looks like saxon does not treat the include second.xsl the same as if it 
were actually part of first.xsl.

Though I might be missing something else.

The code I used to play with:
xml:
<a><book>bbb</book></a>

first.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:import href="third.xsl"/>
<xsl:include href="second.xsl"/>
</xsl:stylesheet>

second.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="book">
<b><xsl:apply-imports/></b>
</xsl:template>
</xsl:stylesheet>

third.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="book">
<xsl:apply-templates/>AM I EVER EVER MATCHED?
</xsl:template>
</xsl:stylesheet>

Ronald Heller
At 10:16 AM 5/10/01 +1000, you wrote:
>Janning
>
>As I understand it, there can be only one <template match="book"> in an xsl.
>
>If first.xsl has a <template match="book"> that will be used over the ones
>from  the included xsl's, and otherwise if there are more than one then the
>last one is used (in Saxon - depends on the XSL Parser I think)
>
>As second.xsl is imported after third.xsl, only the template match in
>second.xsl is used.
>
>Otherwise, what would the processor do?  Which should it use? It wouldn't
>make sense to have more than one template matching the same node.
>
>I'm pretty sure I read about this in Michael Kays XSLT book, but he may
>clarify your question.
>
>Tim :)
>-----Original Message-----
>From: Janning Vygen
>Sent: Thursday, 10 May 2001 3:19 AM
>Subject: [xsl] import/include and apply-imports
>
>first.xsl:
>------
><xsl:import href="third.xsl">
><xsl:include href="second.xsl">
>
>second.xsl
>--------
><template match="book">
>   <xsl:apply-imports/>
></template>
>
>third.xsl
>------
><template match="book">
>   AM I EVER EVER MATCHED?
></template>
>
>
>the template in the third.xsl is NEVER matched!!
>Why? I thought, that include means, the stylesheet is included like it was
>always in this file??
>
>Janning
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]