Subject: Re: Template rules vs. XQuery (was RE:"*NEVER* use for-each")
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Feb 2001 09:04:56 +0000
|
Hi Evan,
> <xsl:when test="count(.|../@*)=count(../@*)">
> <!-- built-in rule for attribute nodes -->
> <!-- btw: someone please give me a better way to
> test whether the current node is an attribute -->
> <xsl:value-of select="."/>
> </xsl:when>
In this context, you could use:
.. and not(self::node())
In fact the root node has already been filtered out, so you don't have
to test whether this node has a parent. The other thing to be aware of
is that this matches namespace nodes too. But if you're only dealing
with a conversion from the matching template version to a named
template version then you're fine because namespace nodes can't be
matched on.
> Is there anything that I'm missing here? Or is there anything that
> could not be converted in such a way?
xsl:apply-imports? - there's no equivalent for named templates. There
isn't a programmatic way of supporting that because you can't know
which next template is going to be processed without knowing what the
source is going to be.
I think you'd also start running into problems when you add support
for parameters in named templates - you could add them to your
applyTemplates template, but you'd have to take care of name clashes
(with possibly different default values) in it. But that's a fairly
minor issue - just requires a generate-id()-ed modifier on the name to
make them unique.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
- Re: RE:"*NEVER* use for-each", (continued)
- Ben Robb - Tue, 27 Feb 2001 12:41:32 -0500 (EST)
- Evan Lenz - Tue, 27 Feb 2001 14:14:18 -0500 (EST)
- Jeni Tennison - Wed, 28 Feb 2001 04:41:06 -0500 (EST) <=
- Beckers, Marc - Tue, 27 Feb 2001 12:43:14 -0500 (EST)
- Duffey, Kevin - Tue, 27 Feb 2001 12:56:49 -0500 (EST)
- Patrick, Curtis W - Tue, 27 Feb 2001 14:30:16 -0500 (EST)
|
|