[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Default template match

Subject: RE: Default template match
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 30 Nov 2001 17:23:25 -0000
template adult
> So I wrote several templates for all "active" tags (that
> correspond to a special
> action), and a final "otherwise" template that simply copies
> the "non-active"
> templates to the output.
> The first question is, is it possible to define the default
> template without
> that long line such as "match="node()[name() != 'adult' and
> name() != 'object'
> and name() != 'content' and name() != 'gender']""?

yes, just set it to match="*", the default priorities will ensure that it's
only fired when none of the others match.

> Second question: my XSL is cycling through a list of persons
> in an XML doc, and
> parsing a content document. To keep the reference to the
> correct person, I am
> passing the reference to that person's data as a variable
> through all templates.
> Is this the only way to do it (certainly not! :-) ?

You haven't shown us the structure, but one would usually be able to
reference the correct person by a path, e.g. ancestor::person.

Mike Kay
>
> ...
> <xsl:template match="adult"> <!-- Output only if age > 17 -->
>   <xsl:param name="doc-ref"/> <!-- pass the reference through
> the templates
> recursively -->
>   <xsl:if test="$doc-ref/customer/age &gt; 17">
>     <xsl:apply-templates select="./*">
>       <xsl:with-param name="doc-ref" select="$doc-ref"/> <!--
> pass the reference
> through the templates recursively -->
>     </xsl:apply-templates>
>   </xsl:if>
> </xsl:template>
>
> <xsl:template match="gender"> <!-- Output only if person of
> appropriate sex -->
>   <xsl:param name="doc-ref"/> <!-- pass the reference through
> the templates
> recursively -->
>   <xsl:apply-templates select="current()[@gender =
> $doc-ref/customer/gender]/*">
>     <xsl:with-param name="doc-ref" select="$doc-ref"/> <!--
> pass the reference
> through the templates recursively -->
>   </xsl:apply-templates>
> </xsl:template>
>
> <!-- 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']">
>   <xsl:param name="doc-ref"/> <!-- pass the reference through
> the templates
> recursively -->
>   <xsl:copy>
>     <xsl:apply-templates select="node()">
>       <xsl:with-param name="doc-ref" select="$doc-ref"/>
>     </xsl:apply-templates>
>   </xsl:copy>
> </xsl:template>
> ...
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.