This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: where to put the filter?
- To: xsl-list at mulberrytech dot com
- Subject: Re: where to put the filter?
- From: "John E. Simpson" <simpson at polaris dot net>
- Date: Wed, 04 Oct 2000 14:04:14 -0400
- Reply-To: xsl-list at mulberrytech dot com
At 10:43 AM 10/04/2000 -0500, Keith wrote:
>...When I call the transformXML() function after the alerts the page comes
>back blank. I am placing this strFilter in the <filter></filter> tags when
>the SOAP request is sent. I am sure it's because I am placing the
><xsl:apply-templates select="filter"/>, <xsl:template match
>select="filter">,<xsl:value-of select="filter"> in the wrong place. I can't
>find any documentation on this at all. They all give the syntax for
>building a filter, but not on where to place it.
Not sure if this will help or not....
An xsl:template is always a top-level element, i.e. a child of the
xsl:stylesheet element. xsl:apply-templates sends the XSLT processor off on
a hunt for template rules (explicit or built-in) for children of the
context node established by the <xsl:template match="..."> pattern;
assuming it finds any such template rules, the processor handles them at
that point in the containing template. xsl:value-of inserts *content* from
the source doc into a template, so it too is a descendant of xsl:template.
So given a source document like this:
<rootelem title="MyRoot">
<childelem>child1</childelem>
<childelem>child2<grandchildelem>grandkid</grandchildelem></childelem>
</rootelem>
you might have a template rule like this:
<xsl:template match="/rootelem">
<newrootelem>
<xsl:value-of select="@title"/>
<xsl:apply-templates />
</newrootelem>
</xsl:template>
See? xsl:template contains both xsl:value-of and xsl:apply-templates. The
result tree will contain:
<newrootelem>
MyRoot
child1 child2 grandkid
</newrootelem>
[Now comes the part where Evan jumps in and qualifies all the above. :)]
==========================================================
John E. Simpson | "Curiosity killed the cat,
http://www.flixml.org | but for a while I was a
XML Q&A: http://www.xml.com | suspect." (Steven Wright)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list