Re: where to put the filter?

Subject: Re: where to put the filter?
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Wed, 04 Oct 2000 14:04:14 -0400
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">

you might have a template rule like this:

  <xsl:template match="/rootelem">
      <xsl:value-of select="@title"/>
      <xsl:apply-templates />

See? xsl:template contains both xsl:value-of and xsl:apply-templates. The result tree will contain:

    child1 child2 grandkid

[Now comes the part where Evan jumps in and qualifies all the above. :)]

John E. Simpson | "Curiosity killed the cat, | but for a while I was a
XML Q&A: | suspect." (Steven Wright)

XSL-List info and archive:

Current Thread