[e-lang] XML library design: what is XPath self? Or, is this "fragment" idea a good one?
Thomas Leonard
tal at it-innovation.soton.ac.uk
Wed Feb 17 02:10:01 PST 2010
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:tal at it-innovation.soton.ac.uk
http://www.it-innovation.soton.ac.uk
More information about the e-lang
mailing list