473,890 Members | 1,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xslt: multiple node match for one template: how?

I've made the following template:

<xsl:template match="form:str ing 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:str ing or node()=form:e-mail or node()=form:url or node()=form:pas sword]">
[cut]
</xsl:template>

But that too is not valid!

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

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


Hi,

I think that should be:

<xsl:template match="form:str ing | 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:str ing 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:str ing or node()=form:e-mail or
node()=form:url or node()=form:pas sword]">
[cut]
</xsl:template>

But that too is not valid!

How should i solve this?


Are you looking for
<xsl:template match="form:str ing | 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:str ing 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:str ing or node()=form:e-mail or
node()=form:url or node()=form:pas sword]">
[cut]
</xsl:template>

But that too is not valid!

How should i solve this?

Are you looking for
<xsl:template match="form:str ing | 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:str ing | 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(.)='passwo rd' 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:str ing | 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:pas sword'

--
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
2715
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 extension responsible for the xslt functions. The problem i have is that the obtained transformation is not the waited one. I try to proccess the same XML file with XSL file with a program called XMLspy and i obtained the desire and waited...
5
2232
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
8127
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="..." xmlns:a="..." xmlns:b=""> .... ----XSLT---- ....
6
1836
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 quite answer all my questions. How would one create a 3 level TOC when each item level / node was differently named (They used Template match and for-each, but the template match worked as on a 3 level structure they usedf the same named xml...
12
2932
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 the file. Here is the code snippet: XPathDocument xdoc = new XPathDocument(fs); XPathNavigator nav = xdoc.CreateNavigator(); xslt.Transform(nav, null, strWriter, null);
18
2095
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 look up what each feature depends on and gerenate a text file. For example, in the following file, I would like to find out feature A depends on A1 and A2 and feature B depends on B1 and B2. And write that to a text file.
8
15912
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 case that i don't know how to solve, I need to concat a string from multiple childs into a standard way, the following is an example of the source and the target XML.
3
2797
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
22787
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 in the attribute of an element. Instead of using the <xsl:attribute> element, you can simply place the xpath in the attribute itself. The most common usage of this is in creating hyperlinks.
0
9978
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9820
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11225
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5846
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4675
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3276
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.