473,395 Members | 1,537 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,395 software developers and data experts.

Should Xpath select nodes containing default values??

hello all

Consider this xml file:

<root>
<body>
<ElementX id="X1" Xproperty="X_Default_Value" />
<ElementX id="X2" />
</body>
</root>

Here for the element of type 'ElementX' the attribute 'Xproperty' has
default value as 'X_Default_Value'.

Now the question is whether the following Xpath Expression
"//ElementX[@Xproperty='X_Default_Value']" would select a single node
ie ElementX with id as 'X1' or 2 ElementX nodes.

Thanx in advance.

Oct 21 '05 #1
2 1334


am******@gmail.com wrote:

<root>
<body>
<ElementX id="X1" Xproperty="X_Default_Value" />
<ElementX id="X2" />
</body>
</root>

Here for the element of type 'ElementX' the attribute 'Xproperty' has
default value as 'X_Default_Value'.
Where is the DOCTYPE declaration then?
Now the question is whether the following Xpath Expression
"//ElementX[@Xproperty='X_Default_Value']" would select a single node
ie ElementX with id as 'X1' or 2 ElementX nodes.


It will depend on the parser or implemention settings whether it reads a
DTD or schema and adds default values defined there. If those are added
then the XPath expression will select two element nodes.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 21 '05 #2
Thanks for your time.

Aman

Martin Honnen wrote:
am******@gmail.com wrote:

<root>
<body>
<ElementX id="X1" Xproperty="X_Default_Value" />
<ElementX id="X2" />
</body>
</root>

Here for the element of type 'ElementX' the attribute 'Xproperty' has
default value as 'X_Default_Value'.


Where is the DOCTYPE declaration then?
Now the question is whether the following Xpath Expression
"//ElementX[@Xproperty='X_Default_Value']" would select a single node
ie ElementX with id as 'X1' or 2 ElementX nodes.


It will depend on the parser or implemention settings whether it reads a
DTD or schema and adds default values defined there. If those are added
then the XPath expression will select two element nodes.

--

Martin Honnen
http://JavaScript.FAQTs.com/


Oct 22 '05 #3

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
3
by: Kevin | last post by:
I know this has probably been discussed many times before (I found answers when I searched yesterday), but I still can't get it to work... I have an attribute @OID that can contain any...
1
by: Keith Davies | last post by:
Hi All, I've got a document containing a internal lookups (I want to show a relationship hierarchy, starting at an arbitrary point, or series of points). It's easy if I know what item IDs I...
3
by: Andy Fish | last post by:
Hi, I just found this template in someone else's xslt (it's Microsoft's "word2html" stylesheet to convert WordProcessingML to HTML) <xsl:template match="WX:sect"> <xsl:variable...
1
by: Seong-Tae Jeong | last post by:
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list...
2
by: sprungli | last post by:
My goal is to select some XPath nodes based on whether their values (text) contain a string passed as argument. To achieve this I use the contains() function of XPath in an XpathExpression. For...
1
by: Don | last post by:
Hi: I have the following web service object serialized into my XML DOM. With XPath, I am able to select '//document/Info/ID' from the XML. Adding the namespace is where I get a problem(see...
5
by: David Thielen | last post by:
Hi; I set up my xml as follows: XmlDocument xml = new XmlDocument(); xml.Load(File.Open("data.xml", FileMode.Open, FileAccess.Read)); XmlNamespaceManager context = new...
2
by: nick_tucker | last post by:
Hi, I am very new to XML and XPATH. I have made a sample XML fileto ask my question. <?xml version="1.0" encoding="utf-8"?> <Test> <A> <B> <C> <D>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.