473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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 19036
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
5
by: Ruthless | last post by:
hello. All XML and XSLT are processed by preprocessor as a trees. How can i simply display my XML as some kind of tree. given xml: <struct> <node level="1" no="1">
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
6
by: Neal | last post by:
Hi All, I used an article on XSLT and XML and creating a TOC written on the MSDN CodeCorner. ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dncodecorn/html/corner042699.htm However, it did'nt...
12
by: das | last post by:
Hello all, I am using .NET XSLT to transform an XML into another XML file. All this is fine with small files, but when tested with big files (30MB) it is taking between 1hr-2hrs to just transform...
18
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
8
by: Hercules Dev. | last post by:
Hi all, I'm new in xslt and xpath, so my question might be simple but i'm learning. I have an XML document and need to transform it into another XML, I use xslt and it works, but there is a...
3
by: abhishek.smu | last post by:
Given an XML like: <root> <node>8</node> <node>21</node> <node>-7</node> <node>13</node> <node>43</node> <node>2</node> </root>
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.