Hi Norbert,
thanks a lot for your extensive reply.
I don't know the simpleXO stuff.
If you like, please load it from Cincom public repository and play a bit. The Pharo port will take some additional time.
Cdata is associated with primitive types. But then in your "width" mapping you map an element to a native type. That makes only sense if this a convenient way of writing it.
My idea behind the name 'cdata' was to hint that these types use the string-value (see XPath) of an XML node to build objects. I had in mind that these types should not be restricted to simple (schema) types. E.g. a use case requires to extract the text from an html paragraph element:
<p>This is an <em>emphasized text</em>.</p> <div><p>And this a text as well.</p></div>
"Consider the mapping"
doc := (builder defineElement: 'Document' class: 'OrderedCollection'). doc mapPath: (RootStep // 'p') toType: 'Paragraph') setter: #add:. (builder defineCData: 'Paragraph' class: 'Text') constructor: #fromString:.
"Which gives us" (OrderedCollection new) add: (Text fromString: 'This is an emph ...'); add: (Text fromString: 'And this is ...')
What's your opinion on that example? Are 'element' and 'cdata' still misleading? I am not sure whether 'simple' and 'complex' reflect the nature of the types well, since a cdata type my have it's own mappings as well:
text := (builder defineCData: 'Paragraph' class: 'Text') constructor: #fromString:. (text mapPath: (AttributeAxis ? 'id') toType: 'String') key: 'p-ids'.
This example uses the value of @id as key to allow referencing the created object elsewhere. A more sophisticated example could use a parser that parses a given string-value and the fields of the result are set by SimpleXO later.
I am looking forward to your (and anyone else's) thoughts!
Regards, Steffen