|
Re: [xml-dev] An approach to let XML 2.n resources hold multiple entitie
|
[
Lists Home |
Date Index |
Thread Index
]
In a message dated 19/03/2003 09:46:17 GMT Standard Time, bill.dehora@propylon.com writes:
> At the moment, count(/*) always is 1. I am suggesting redefining /
> away from being the "document" to being the "resource", and then
> using indexing to get other entities.
I believe it can be > 1. In the XPath model, the root node declares
the prolog as one of its children as well as the document element
and any other processing instructions. So there might not be as much
impact there as you expect.
Bill,
I think you may be conflating a couple of ideas here.
Yes it is possible to have processing instructions or comments in the prolog before the start tag of the document element. However XPath 1.0 treats each such processing instruction or comment as a node, rather than treating the prolog as a child of the root node.
The location path count(/*) will return all child nodes of the principal node type for the default (child) axis. The element node is the principal node type, so the location path count(/*) returns 1 since there is only ever one child element node of the root node in a well-formed XML document.
However, count(/node()) returns all child nodes of the root node (not just those of the principal node type). If, as in the following example document, there are non-element child nodes of the root node then count(/node()) will return a value greater than 1. In this case 3.
<?xml version="1.0"?>
<?arbitrary processing instruction ?>
<!-- Some comment which is a child of the root node -->
<document>
<child>
</child>
</document>
Andrew Watt
|
|
|
|
|