OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] An approach to let XML 2.n resources hold multiple entitie

[ Lists Home | Date Index | Thread Index ]

Hi Rick,

> A couple of times people have suggested that XML should allow
> multiple top-level elements. Thinking about it, here is one possible
> approach that might fit in with existing systems with fairly minimal
> changes.


> How does this fit in with XPath?
> ----------------------------------------
> At the moment, count(/*) always is 1.

That's not technically true: a document node in XPath can have
multiple element and text children -- it's able to represent any
well-formed external general parsed entity. It is true when you're
parsing a well-formed XML document, however.

> I am suggesting redefining / away from being the "document" to being
> the "resource", and then using indexing to get other entities. Two
> ways for this spring to mind:
> 1) Use existing XPaths, so that in the first example above the
> address of the y element is document("first example")/*[2] The XPath
> of the document element is document("first example")/*[1]
> 2) Use a new axis on XPath, for example
>    /entity::*[2]  is the y element
>    /entity::*[1] is the document element,
>   /x is shorthand for /entity::*[1]/x  and 
>   //x is shorthand for /entity::*[1]//x

Here's a third possibility: in XPath 2.0, the collection() function
returns a sequence of nodes from a particular URL. In the case of a
file that contains multiple documents, collection("first example")
could return multiple document nodes, so you would use
collection("first example")[2]/* to get the <y> element.

Such a document could also act as the input to a transformation. In
XSLT 2.0, the input() function returns a sequence of nodes as an
input, and in the case of a "resource"/"collection document" in the
format you suggest, this could be a sequence of document nodes. So if
your document was acting as the input to a transformation then
input()[2]/* would return the <y> element.



Jeni Tennison


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS