Altova Mailing List Archives


RE: [xsl] apply-templates, rule-based, and saxon

From: "Chris Bayes" <Chris@----------->
To:
Date: 5/10/2001 12:57:00 PM
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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.