[e-lang] XML library design: what is XPath self? Or, is this "fragment" idea a good one?

Kevin Reid kpreid at mac.com
Wed Feb 17 04:29:19 PST 2010


On Feb 17, 2010, at 4:11, bryan rasmussen wrote:

> Well the first question is - should this handle malformed XML data -  
> because
>
>> ? xml`<a>xxx</a> yyy <b>zzz</b>`[xpath`a/text()`]
>> # value: [xml`xxx`]
> is malformed  - the XML you give there doesn't have a document node.

You have not understood the premise of my design.

It is intended to make sure that *CONSTRUCTING* XML documents using  
this interface is no more painful than doing it by concatenating  
strings.

As I wrote before:


>> 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:
>> ...
>> 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.

It is true that the example above is not a well-formed *document*, but  
it is not intended to be. It *is* a well-formed *subsequence of  
element content* -- it corresponds to the grammar production "content"  
in the XML specification.

Note that the restriction of this to having only one element makes it  
a well-formed XML document, except that the prolog is not represented.

-- 
Kevin Reid                                  <http://switchb.org/kpreid/>






More information about the e-lang mailing list