Re: XML library design: what is XPath self? Or, is this "fragment" idea a good one?

Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]>
Newsgroups gmane.comp.lang.e.general
Organization IT Innovation
Message-ID <[email protected]>
On Tue, 2010-02-16 at 21:31 -0500, Kevin Reid wrote:
> Running into a bit of a problem with the XML library design.
> 
> My starting premise has been that XML values are not single elements/ 
> spans of text/etc (like DOM nodes) but rather arbitrary sequences of  
> XML data; that is, they can contain arbitrary concatenations:
> 
> ? xml`<a>xxx</a> yyy <b>zzz</b>`[xpath`a/text()`]
> # value: [xml`xxx`]
> 
> My notion was that this is more the right thing when one is working  
> with constructing an XML tree in code; being able to carry arbitrary  
> fragments around as single objects means that you can do natural  
> things such as xml`this <html:em>simple</html:em> example` without  
> contortions such as the DOM DocumentFragment objects.
> 
> So, for XPath semantics, the above sample implies that the “a” element  
> is a child of the context node.
> 
> But what about xml`<a b="c">xxx</a>`?
>
> Given that one *has* an object which is a single element, one would  
> imagine it to be natural to want to refer to its attributes directly:
> 
> ? xml`<a b="c">xxx</a>`[xpath`@@b`]
> # value: [xmlattr`b="c"`]

I'd be happy having the context be the document (or document fragment)
containing <a>, rather than <a> itself.

Even if xml`<foo/><bar/>` isn't a well-formed document,
xml`<foo/><!--comment-->` is, and you still need to be able to refer to
the comment.


-- 
Dr Thomas Leonard
IT Innovation Centre
2 Venture Road
Southampton
Hampshire SO16 7NP

Tel: +44 0 23 8076 0834
Fax: +44 0 23 8076 0833
mailto:[email protected]
http://www.it-innovation.soton.ac.uk 

_______________________________________________
e-lang mailing list
[email protected]
http://www.eros-os.org/mailman/listinfo/e-lang
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.