469,327 Members | 1,200 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

xslt: multiple node match for one template: how?

I've made the following template:

<xsl:template match="form:string or form:e-mail or form:url or form:password">
[cut]
</xsl:template>

But the match attribute has an invalid xpath pattern, so i tried this:

<xsl:template match=".[node()=form:string or node()=form:e-mail or node()=form:url or node()=form:password]">
[cut]
</xsl:template>

But that too is not valid!

How should i solve this?
Jul 20 '05 #1
7 18679
> I've made the following template:

<xsl:template match="form:string or form:e-mail or form:url or form:password">
[cut]
</xsl:template>


Hi,

I think that should be:

<xsl:template match="form:string | form:e-mail | form:url | form:password">
[cut]
</xsl:template>
regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #2


Tjerk Wolterink wrote:
I've made the following template:

<xsl:template match="form:string or form:e-mail or form:url or
form:password">
[cut]
</xsl:template>

But the match attribute has an invalid xpath pattern, so i tried this:

<xsl:template match=".[node()=form:string or node()=form:e-mail or
node()=form:url or node()=form:password]">
[cut]
</xsl:template>

But that too is not valid!

How should i solve this?


Are you looking for
<xsl:template match="form:string | form:e-mail | form:url |
form:password">
maybe?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #3
Martin Honnen wrote:


Tjerk Wolterink wrote:
I've made the following template:

<xsl:template match="form:string or form:e-mail or form:url or
form:password">
[cut]
</xsl:template>

But the match attribute has an invalid xpath pattern, so i tried this:

<xsl:template match=".[node()=form:string or node()=form:e-mail or
node()=form:url or node()=form:password]">
[cut]
</xsl:template>

But that too is not valid!

How should i solve this?

Are you looking for
<xsl:template match="form:string | form:e-mail | form:url |
form:password">
maybe?


Ok that solved my problem,

but it raises a new question:

In xpath or is the or operator, why use | in xslt??

I think it has something todo with that you do not want a boolean return value from the expression in the match,
you want a node to be returned, am i right?
Jul 20 '05 #4
Ok now i have the following problem:

i've:

<xsl:template match="form:string | form:e-mail | form:url | form:password">
<xsl:if test="current()=form:password">
[cut]
</xsl:if>
</xsl:template>

But the test in the if tag does not work, how should i check wether the current() is a form:password??

name(.)='password' does not help
current()=form:password does not help

please help
Jul 20 '05 #5
> In xpath or is the or operator, why use | in xslt??

I think it has something todo with that you do not want a boolean return value from the expression in the match,
you want a node to be returned, am i right?

you're right

the '|' is the union operator for node-sets, while 'or' and 'and' does boolean logic (they return not node-set but a boolean value)
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #6
> <xsl:template match="form:string | form:e-mail | form:url | form:password">
<xsl:if test="current()=form:password">
[cut]
</xsl:if>
</xsl:template>

But the test in the if tag does not work, how should i check wether the current() is a form:password??


Normally, you test something like that with 'self::node'.
But I'm not sure how to handle the namespace. one guess: 'self::form:password'

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #7

use | not or
or is an Xpath boolean operator an XSLT patterns have to match nodes not
boolean values.

David
Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sergio del Amo | last post: by
5 posts views Thread by Ruthless | last post: by
8 posts views Thread by Hercules Dev. | last post: by
3 posts views Thread by abhishek.smu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.