473,406 Members | 2,816 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,406 software developers and data experts.

simple XPath query

R
Hello everybody.

I'm new to XML and I've got problem with one XPath query.
This is my situation:
<group>
<test required='1'></test>
<test required='1' noregexp='1'></test>
</group>

inside group there are few (usually from 10 to 20) test nodes.

if among all of the tests there is at least one node that doesn't have
"noregexp" attribute - like in the above example
I should call template for validating regexps.

well my idea was this:

if (count(required) != count(required and noregexp) ) { call template }

if counts varies that means there is a node that need to be validated
(at least one node)

in XPath:

<xsl:if test="count(*/@required='1' and */@noregexp='1') != count(*/@required='1')">
<!-- my template goes here -->
</xsl:if>

but this XPath query is incorrect and I don't know how to fix it

sorry for bothering but I'm just a newbie

thanks in advance for helping me with this query

best regards R
Jul 20 '05 #1
2 2979
Tempore 23:15:41, die Friday 18 February 2005 AD, hinc in foro {comp.text.xml} scripsit R <ru******@poczta.onet.pl>:
<xsl:if test="count(*/@required='1' and */@noregexp='1') != count(*/@required='1')">
<!-- my template goes here -->
</xsl:if>

but this XPath query is incorrect and I don't know how to fix it

Hi,

You're forgetting that predicates should be between [brackets]

<xsl:if test="count(*[@required='1' and @noregexp='1']) != count(*[@required='1'])">

Be careful with '!= ' , you'de better use 'not(...=...)'
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Veni, vidi, wiki (http://www.wikipedia.org)
Jul 20 '05 #2
<group>
<test required='1'></test>
<test required='1' noregexp='1'></test>
</group>

inside group there are few (usually from 10 to 20) test nodes.

if among all of the tests there is at least one node that doesn't have
"noregexp" attribute - like in the above example
I should call template for validating regexps.

well my idea was this:

if (count(required) != count(required and noregexp) ) { call template }

that's more complicated (for you and the system) than necessary.
There is no need to count anything: The Xpath can more closely model
your description in English:

test="test[not(@noregexp)]"

matches the description
if among all of the tests there is at least one node that doesn't have
"noregexp" attribute -


although your attempt seems to be implementing:

if among all of the tests __that have a required attribute__ there is at
least one node that doesn't have "noregexp" attribute -

which would be
test="test[@required and not(@noregexp)]"

David
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joshua Beall | last post by:
Hi All, I have a task that should be very simple but I'm running into trouble. All I want to do is query a document using XPath, and save the resulting XML in a string. Here's that I am trying...
6
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
7
by: chris.millar | last post by:
The below xml is saved as a file, i want the quickest way in c# of reading just the DataSource section and returning it as a string, can anyone help me out. Cheers Chris. <NewDataSet>...
7
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
10
by: Michael C# | last post by:
OK, here's the deal. I have a small XML file that represents a small database table. I load it into a System.XML.XMLDocument. So far so good. I run an XPath query against it to retrieve all the...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
6
by: dotnetnoob | last post by:
i would like to know how i can build xpath expression dynamiclly. let's say i have a following xml file: <EventEnrollment InstanceNumber = "675"> <EventSource> <ObjectReference...
6
by: Armel Asselin | last post by:
Hello, I'm searching for a simple command line tool to manipulate XML files. The idea would be commands such as that: xmanip-tool set /document/xpath/@name="value" remove //wrong-nodes add...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
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.