Ben Bangert wrote:
> Unfortunately XMLObject or something like that which would somehow
> obfuscate XQuery/XPath beneath it isn't really possible. The XPath is
> always going to be necessary, though having a layer in between that
> could translate some XPath parts to use extensions for optimization
> that are in the various XML db's would be awesome.
However unfortunate, it is also irrelevent, the topic of XQuery/XPath is
really a tangent, and has nothing to do which this topic
> I think Amara is a great starting point, with some minor extensions to
> query a doc going through the XMLObject interface to have XPath's
> translated to use the best extensions for whichever database is being
> used.
I've just been looking at Amara, and for parsing it seems wonderful.
>
> Having looked over Amara, I don't see much use for a "XML Model" like
> Sean proposed, since Amara makes it so Pythonic to make, parse, and
> manipulate XML nodes.
Amara still doesn't do what I'm talking about. Sure it will parse an XML
document into a python object tree. But it doesn't create XML from a
Python they way I am doing it.
To generate XML, Amara does:
doc.startElement/endElement, doc.appendElement, etc that everything else
does
what I'm doing is:
class people( XMLModel )
class person( XMLNodeList )
name = XMLValue()
age = XMLValue()
birthday = XMLDateTime( format="%a, %d %b %Y %H:%M:%S EST" )
doc = people()
for rec in db:
p = doc.person.new()
p.name = rec.get('name')
p.age = rec.get('age')
p.birthday = rec.get('birthday')
print doc
in Amara, this would look like:
|writer = MarkupWriter()
writer.startDocuement()
writer.startElement( 'people' )
for rec in db:
writer.startElement( 'person' )
writer.simpleElement( 'name', content=rec.get('name') )
|| writer.simpleElement( 'age', content=rec.get('age') )
birthday = datetime.fromtimestamp( rec.get( 'birthday' ) )
|| writer.simpleElement( 'birthday', content=birthday.strftime( "%a,
%d %b %Y %H:%M:%S EST" ) )|
writer.endElement( 'person' )
writer.endElement( 'people' )
writer.endDocument()
Now, I've writen libraries to generate XML this, and various similar
ways, in various languages.
But python allows me to do it in a totally different way, which is much
more comfortable to use, and feels more like working with the language
itself, and not some XML generating library, IMHO.
( if I removed "XML" from the class names, you'd probably not even
realize the code was creating XML )
Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---