Tom is correct. There is no way of limiting the compilation to
just one stylesheet, and doing so would be incorrect and the
behaviour you request would cause XSLT to not conform to the
XSLT spec. Any XSLT processor has to evaluate the patterns of
all templates in all included and imported stylesheets.
Consider an XML source document like this:

  <foo>
    <bar>
      <baz>BLOB!</baz>
    </bar>
  </foo>

Your main stylesheet has a single template:

  <xsl:template match="baz">
    <xsl:text>Found a BAZ&#xa;</xsl:text>
    <xsl:value-of select="."/>
    <xsl:text>&#xa;</xsl:text>
  </xsl:template>

You assume here that you will get the <baz> element because of
the implicit template that every stylesheet has:

  <xsl:template match="*">
    <xsl:apply-template select="*"/>
  </xsl:template>

But that is not necessarily the case if your stylesheet imports
some other stylesheet with this single template:

  <xsl:template match="bar">
    <!-- do nothing -->
  </xsl:template>

This will intercept the XML document traversal at the <bar>
element, so the <baz> element is never reached and the template
in the parent stylesheet is never executed.

So, with this in mind, any XSLT processor has to parse all
templates in all imported and included stylesheets before
applying any templates to the source document.

Morten


Tom Amiro wrote:
> 
> The behavior you see is as expected. I didn't mean to
> imply otherwise. I don't know of anyway for you to
> compile the main stylesheet and not have the included/imported
> stylesheets pulled-in and be included in the compiled translet.
> 
> Tom
> 
> [EMAIL PROTECTED] wrote:
> 
> > Tom,
> >
> > How do you actually limit the compilation to just the 'main' stylesheet? When I
> > have tried this, the compilation process always seems to 'call out' for the
> > import statements. Is there any chance you could provide an example?
> >
> > Many thanks,
> >
> > Ron Tomlinson
> >
> > ____________________Reply Separator____________________
> > Subject:    Re: Import
> > Author: Tom Amiro <[EMAIL PROTECTED]>
> > Date:       18/06/2001 13:47
> >
> > If have a stylesheet that includes or imports other stylesheets,
> > you compile only that "main" stylesheet. You don't compile
> > the "to-be-imported" or "to-be-included" stylesheets individually.
> >
> > Tom
> >
> > [EMAIL PROTECTED] wrote:
> >
> > > Is it possible to compile an xsl file and to add it later comiled in
> > > another xsl file.

Reply via email to