[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: [xsl] apply-templates, rule-based, and saxon
From: "kfricovsky" <kfricovsky@xxxxxxxxxxx>
Date: Thu, 10 May 2001 16:50:50 -0400

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



Current Thread
Keywords