Re: [xsl] Default template match

Subject: Re: [xsl] Default template match
From: Costantino_Sertorio@xxxxxxxxxx
Date: Mon, 3 Dec 2001 11:59:56 +0100

Thank you very much for the hint and sorry for that basic question...
Regarding the second question, I paste my "/" template to explain the situation
a little better.
I have two source files: I cycle through the customers listed in the first
"metadata" file and for each entry (customer) I output an element, which I
compose in a way which is defined in the second file ("templates.xml" - OK,
maybe this was a bad name choice...).
Therefore, how can I refer to the specific customer (from the "metadata" file),
when I am applying other templates?
Thank you!
Costantino

...
  <xsl:variable name="templates" select="'templates.xml'"/>
  <xsl:variable name="metadata" select="'metadata.xml'"/>

  <xsl:template match="/">
    <xsl:element name="docs">
      <xsl:for-each select="document($metadata)/data/doc"> <!-- select each
requested doc/customer -->
        <xsl:element name="doc">

           <xsl:element name="metadata"><xsl:copy-of select="./*"/></xsl:element
>

           <xsl:element name="object">
             <xsl:apply-templates select="
document($templates)/docs/doc[@label=current()/label and
@lang=current()/customer/language]/object">
<!-- pass the metadata doc context as parameter (this is the "document request")
-->
               <xsl:with-param name="doc-ref" select="current()"/>
             </xsl:apply-templates>
           </xsl:element> <!-- object -->

           <xsl:element name="content">
             <xsl:apply-templates select="
document($templates)/docs/doc[@label=current()/label and
@lang=current()/customer/language]/content">
<!-- pass the metadata doc context as parameter (this is the "document request")
-->
               <xsl:with-param name="doc-ref" select="current()"/>
             </xsl:apply-templates>
           </xsl:element> <!-- content -->

        </xsl:element> <!-- doc -->
      </xsl:for-each> <!-- cycle through metadata's docs -->
    </xsl:element> <!-- docs -->
  </xsl:template>


----------------------------------------------------------------------

Date: Fri, 30 Nov 2001 16:41:17 GMT
From: David Carlisle <davidc@xxxxxxxxx>
Subject: Re: [xsl] Default template match

> <!-- HOW DO I AVOID TO USE THIS HORRIBLE ROW, EXCLUDING ALL OTHER TEMPLATES?
-->
> <xsl:template match="node()[name() != 'paste' and name() != 'object' and
name()
> != 'content' and name() != 'gender']">

JUST USE
<xsl:template match="*"/>

your other templates have higher priority so will be called when they
apply.

>  <xsl:param name="doc-ref"/>

move that to the top level of the stylesheet so it is a global parameter
then you will not have to explictly pass it down.

David




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


Current Thread