From 8982c06e5463aa8ca00e08f466f8863d0c56c843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Thu, 10 Nov 2005 01:06:19 +0000 Subject: [PATCH] * trying to solve the damn thing, use XML namespace for attribute access * we got an attribute related error, no wonder... --- pisi/xml/autoxml.py | 4 ++-- pisi/xml/xmlextcdom.py | 8 ++++++-- pisi/xml/xmlfilecdom.py | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pisi/xml/autoxml.py b/pisi/xml/autoxml.py index d1bc58dc..f80d9040 100644 --- a/pisi/xml/autoxml.py +++ b/pisi/xml/autoxml.py @@ -101,7 +101,7 @@ class LocalText(dict): assert self.tag != '' for key in self.iterkeys(): newnode = newNode(node, self.tag) - newnode.setAttributeNS(None, 'xml:lang', key) + newnode.setAttributeNS(XML_NS, 'xml:lang', key) newtext = newTextNode(node, self[key]) newnode.appendChild(newtext) node.appendChild(newnode) @@ -423,7 +423,7 @@ class autoxml(oo.autosuper, oo.autoprop): return getNodeAttribute(node, attr) def writetext(node, attr, text): #print 'write attr', attr, text - node.setAttributeNS(None, attr, text) + node.setAttributeNS(XML_NS, attr, text) anonfuns = cls.gen_anon_basic(attr, spec, readtext, writetext) return cls.gen_named_comp(attr, spec, anonfuns) diff --git a/pisi/xml/xmlextcdom.py b/pisi/xml/xmlextcdom.py index 15219b49..a8ac5f02 100644 --- a/pisi/xml/xmlextcdom.py +++ b/pisi/xml/xmlextcdom.py @@ -35,6 +35,10 @@ import Ft from Ft.Xml.Domlette import implementation from Ft.Xml import ParsePath from Ft.Xml.Domlette import NonvalidatingReader +from xml.dom import XHTML_NAMESPACE, XML_NAMESPACE + +XHTML_NS = unicode(XHTML_NAMESPACE) +XML_NS = unicode(XML_NAMESPACE) import pisi @@ -67,10 +71,10 @@ def newTextNode(node, text): def getNodeAttribute(node, attrname): """get named attribute from DOM node""" - if not node.hasAttributeNS(None, attrname): + if not node.hasAttributeNS(XML_NS, attrname): return None else: - return node.getAttributeNS(None, attrname) + return node.getAttributeNS(XML_NS, attrname) def getChildElts(node): """get only child elements""" diff --git a/pisi/xml/xmlfilecdom.py b/pisi/xml/xmlfilecdom.py index aca65eed..fdea5b6e 100644 --- a/pisi/xml/xmlfilecdom.py +++ b/pisi/xml/xmlfilecdom.py @@ -36,6 +36,10 @@ from Ft.Xml.Domlette import implementation from Ft.Xml.Domlette import NonvalidatingReader from Ft.Xml import Parse, ParsePath from Ft.Xml.Domlette import Print, PrettyPrint +from xml.dom import XHTML_NAMESPACE, XML_NAMESPACE + +XHTML_NS = unicode(XHTML_NAMESPACE) +XML_NS = unicode(XML_NAMESPACE) import pisi