xslt: multiple node match for one template: how?

Tjerk Wolterink

Usenet Archive
Joined
Sep 18, 2004
Messages
218
Reaction score
0
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?
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
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,
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Tjerk said:
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?
 

Tjerk Wolterink

Usenet Archive
Joined
Sep 18, 2004
Messages
218
Reaction score
0
Martin said:
Tjerk said:
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?
 

Tjerk Wolterink

Usenet Archive
Joined
Sep 18, 2004
Messages
218
Reaction score
0
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
 

Joris Gillis

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
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

Usenet Archive
Joined
Sep 28, 2004
Messages
355
Reaction score
0
<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'
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
use | not or
or is an Xpath boolean operator an XSLT patterns have to match nodes not boolean values.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top