Should Xpath select nodes containing default values??

A

aman.coe

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.
 
M

Martin Honnen

<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.
 
A

aman.coe

Thanks for your time.

Aman

Martin said:
<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.
 

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

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top