[4suite] [Amara] attribute names that contain hypens
Uche Ogbuji
uche at ogbuji.net
Tue Dec 12 10:57:13 MST 2006
Greg wrote:
> Hi,
>
> I've run into an issue with attribute names that are hyphenated. I hope
> I'm making a noobie mistake.
>
> Whenever I try to use an attibute that has a hyphenated name, I get an
> error message:
>
> SyntaxError: can't assign to operator
>
> But when I remove the hyphen from my source XML so that the att name in
> the data matches option #2, everything works OK.
>
> What am I doing wrong?
The manual explains that characters that are illegal in Python names are
turned to underscores:
> Option #1
> titles = data.doc.xml_xpath (u'//title')
>
> for titleeach in titles:
> del titleeach.title-type
That would be
del titleeach.title_type
You can always use
del titleeach.xml_remove_child(xml_xpath(u'title-type'))
if you want to use the proper XML name.
--
Uche Ogbuji Work: The Kadomo Group, Inc.
http://uche.ogbuji.net http://kadomo.com
http://copia.ogbuji.net Lead dev at http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/
More information about the 4suite
mailing list