Subject: RE: [xsl] apply-templates, rule-based, and saxon - REPLY From: "kfricovsky" <kfricovsky@xxxxxxxxxxx> Date: Thu, 10 May 2001 17:24:29 -0400 |
>> It's happening because the default templates are kicking in But isn't this conflicting to the philosophy behind template rules, unless I am wrong in my thinking: only if you specify a template rule will that element be matched and displayed in the output? Or, do I need to match on every element in the source document? Thanks. -Kevin -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Chris Bayes Sent: Thursday, May 10, 2001 4:58 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] apply-templates, rule-based, and saxon k, It's happening because the default templates are kicking in. Change your stylesheet to <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="tip_list"> <xsl:apply-templates/> </xsl:template> <xsl:template match="tip"> <xsl:value-of select="." /><br/> </xsl:template> <xsl:template match="title" /> </xsl:stylesheet> Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml >-----Original Message----- >From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx >[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of kfricovsky >Sent: 10 May 2001 21:31 >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >Subject: [xsl] apply-templates, rule-based, and saxon > > >XSL-LIST, > >I am wondering why I am still getting the <title> elements from my XML >source document in my HTML output document. I am trying to implement the >"rule based" design method. > >I am using the saxon processor with XML SPY. My XML and XSL are pasted >below, along with the output. > >You will see that the <title> elements are in my output. Why is this. I >know how to correct this, but I am wondering if my rule-based design is >the cause of this. Thanks... > >Here is my XML: > ><?xml version="1.0" encoding="UTF-8"?> ><tips> > <tip_list> > <title>Eight tips for how to write efficient >XSLT:</title> > <tip>Avoid repeated use of "//item".</tip> > <tip>Don't evaluate the same node-set more than once; >save it in a variable.</tip> > <tip>Avoid xsl:number if you can. For example, by using >position().</tip> > <tip>Use xsl:key, for example to solve grouping >problems.</tip> > <tip>Avoid complex patterns in template rules. Instead, >use xsl:choose within the rule.</tip> > <tip>Be careful when using the preceding[-sibling] or ></tip> > <tip>Don't sort the same node-set more than once.</tip> > <tip>To output the text value of a simple #PCDATA >element,</tip> > <title>Michael Kay's XSLT tips:</title> > <tip>Keep the source documents small. If necessary split >the document first.</tip> > <tip>Keep the XSLT processor (and Java VM) loaded in >memory between runs</tip> > <tip>If you use the same stylesheet repeatedly, compile >it first.</tip> > <tip>If you use the same source document repeatedly, >keep it in memory.</tip> > <tip>If you perform the same transformation repeatedly, >don't. Store the result instead.</tip> > <tip>Keep the output document small. For example, if >you're generating HTML, use CSS.</tip> > <tip>Never validate the same source document more than >once.</tip> > <tip>Split complex transformations into several >stages.</tip> > </tip_list> ></tips> > > >Here is my XSL: > ><xsl:stylesheet version="1.0" >xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >xmlns:fo="http://www.w3.org/1999/XSL/Format"> ><xsl:output method="html"/> > ><xsl:template match="/"> > <xsl:apply-templates/> ></xsl:template> > ><xsl:template match="tip_list"> > <xsl:apply-templates/> ></xsl:template> > ><xsl:template match="tip"> > <xsl:value-of select="." /><br/> ></xsl:template> > ></xsl:stylesheet> > >OUTPUT: > >Eight tips for how to write efficient XSLT: Avoid repeated use of >"//item". >Don't evaluate the same node-set more than once; save it in a variable. >Avoid xsl:number if you can. For example, by using position(). >Use xsl:key, for example to solve grouping problems. >Avoid complex patterns in template rules. Instead, use xsl:choose within >the rule. >Be careful when using the preceding[-sibling] or >Don't sort the same node-set more than once. >To output the text value of a simple #PCDATA element, >Michael Kay's XSLT tips: Keep the source documents small. If necessary >split the document first. >Keep the XSLT processor (and Java VM) loaded in memory between runs >If you use the same stylesheet repeatedly, compile it first. >If you use the same source document repeatedly, keep it in memory. >If you perform the same transformation repeatedly, don't. Store the >result instead. >Keep the output document small. For example, if you're generating HTML, >use CSS. >Never validate the same source document more than once. >Split complex transformations into several stages. > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] apply-templates, rule-bas, Chris Bayes | Thread | Re: [xsl] apply-templates, rule-bas, Thomas B. Passin |
Re: [xsl] apply-templates, rule-bas, Thomas B. Passin | Date | [xsl] parameters from Javascript to, Gitanjali |
Month |