xml_set_attribute equivalent in Amara 2?

4 views
Skip to first unread message

Werner

unread,
Feb 14, 2013, 1:58:07 PM2/14/13
to ak...@googlegroups.com
Hi,

With Amara I would have done the following to write an attribute
"source" to the element refc:

refc.xml_set_attribute(u'source', dbbottle.inetrefsource.strip())

Can someone give me a tip on how I translate this to Amara 2 as I can't
find an xml_set_attribute, there is the xml_attribute_factory but I am
not clear on how to use it.

Thanks
Werner

Luis Miguel Morillas

unread,
Feb 14, 2013, 2:13:17 PM2/14/13
to ak...@googlegroups.com
Saludos,

-- luismiguel (@lmorillas)


2013/2/14 Werner <werner...@sfr.fr>:
I remember xml_attributes,

i.e.

refc.xml_attributes[(None, u'source)] = unicode(dbbottle.inetrefsource.strip())

lm

> --
> You received this message because you are subscribed to the Google Groups
> "akara" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akara+un...@googlegroups.com.
> To post to this group, send email to ak...@googlegroups.com.
> Visit this group at http://groups.google.com/group/akara?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Uche Ogbuji

unread,
Feb 14, 2013, 11:00:59 PM2/14/13
to ak...@googlegroups.com
On Thu, Feb 14, 2013 at 12:13 PM, Luis Miguel Morillas <mori...@gmail.com> wrote:
2013/2/14 Werner <werner...@sfr.fr>:

> With Amara I would have done the following to write an attribute "source" to
> the element refc:
>
> refc.xml_set_attribute(u'source', dbbottle.inetrefsource.strip())
>
> Can someone give me a tip on how I translate this to Amara 2 as I can't find
> an xml_set_attribute, there is the xml_attribute_factory but I am not clear
> on how to use it.

I remember xml_attributes,

i.e.

refc.xml_attributes[(None, u'source)] = unicode(dbbottle.inetrefsource.strip())


Yep, and don't forget the handy "what's new" guide to Amara 2


--
Uche Ogbuji                       http://uche.ogbuji.net
Founding Partner, Zepheira        http://zepheira.com
http://wearekin.org
http://www.thenervousbreakdown.com/author/uogbuji/
http://copia.ogbuji.net
http://www.linkedin.com/in/ucheogbuji
http://twitter.com/uogbuji

Werner

unread,
Feb 15, 2013, 7:36:39 AM2/15/13
to ak...@googlegroups.com
Luis Miguel and Uche,

Looked at the QuickRef but forgot about the whatsnew:-[ .

Thanks a lot for your pointers, that got me going again.

I have one more thing (at least for the moment:-) ) which I don't know
how to translate. When sending a vinoXML doc using urllib/2 to Global
Wine Stocks I had to do the following:

docstring =
doc.xml(force_nsdecls=xmlcreation.vinoxml_NSS).replace('xmlns=""', '')

vinoxml_NSS = {u'xsd': u'http://www.w3.org/2001/XMLSchema',
u'xsi': u'http://www.w3.org/2001/XMLSchema-instance'}

I vaguely remember that they had an issue with the namespace definitions.

The doc is created like this:

def createXMLquery():
"""
Create a bindery instance, to be used for e.g. GWS vinoXML query"""
doc_header = """<query
xmlns="http://www.vinoxml.org/XMLschema"></query>"""

doc = xmlu.bindery.parse(doc_header)

return doc

then elements etc are added and just before sending it I did the
"force_nsdecls" trick which I got from Uche a long time ago.

Sorry to bug you all with these things.
Werner

Reply all
Reply to author
Forward
0 new messages