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

RE: apply-templates, rule-based, and saxon - REPLY

Subject: RE: apply-templates, rule-based, and saxon - REPLY
From: "kfricovsky" <kfricovsky@xxxxxxxxxxx>
Date: Thu, 10 May 2001 17:24:29 -0400
rule based stylesheet examples
>> 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:  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:  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

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.