[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Selecting only one element using templates
> > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|