[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: An approach to let XML 2.n resources hold multiple entitie


xml entitie
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.

Neat.

[snip]
> 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]
[snip]
> 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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.