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

RE: Selecting only one element using templates

Subject: RE: Selecting only one element using templates
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 1 Dec 2003 12:46:16 -0000
using with xsl element
> 
> I was able to find the solution to my problem:
> 
> <xsl:template match="class[class]">
>         <xsl:apply-templates select="class"/>
>     </xsl:template>
> 
>     <xsl:template match="class">
>         <xsl:element name="option">
>             <xsl:apply-templates/>
>         </xsl:element>
>     </xsl:template>

Quite how this selects elements called <name> is beyond me...
> 
> 
> I did not know you could use a select attribute when applying 
> templates. But this leaves me with a question: If I left 
> "select" out of the apply-templates xsl element, I would have 
> thought it would only apply the templates that I defined. 
> Does the processor output all nodes anyway? In other words, 
> if I put in an "apply-templates" element, and I have no 
> templates defined for a particular node (or set?), why do I 
> get output?
> 

There is a built-in template rule for nodes that are not matched by an
explicit template rule. This rule does a recursive apply-templates for
element nodes, and for text nodes it outputs the content. If you want to
override this, write a rule such as:

<xsl:template match="*"/>

Michael Kay


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


Current Thread
  • Selecting only one element using templates
    • JCS - Mon, 1 Dec 2003 04:02:49 -0500 (EST)
      • JCS - Mon, 1 Dec 2003 05:34:58 -0500 (EST)
        • Michael Kay - Mon, 1 Dec 2003 07:46:41 -0500 (EST) <=
          • JCS - Mon, 1 Dec 2003 08:17:23 -0500 (EST)
          • JCS - Mon, 1 Dec 2003 09:40:16 -0500 (EST)
      • Michael Kay - Mon, 1 Dec 2003 07:37:36 -0500 (EST)
        • JCS - Mon, 1 Dec 2003 08:02:27 -0500 (EST)

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.