P
Piet
Hello,
Via Xpath, I want to access nodes which have a namespace prefix. THe
document at hand is an Xsl-FO document. I tried the following:
from xml.dom import minidom
from xml.xpath import Evaluate
from xml import sax
parser = sax.make_parser()
parser.setFeature(sax.handler.feature_namespaces,1)
parser.setFeature(sax.handler.feature_namespace_prefixes,1)
doc = minidom.parse("fo-file.xml",parser)
#everything ok up to here
outlines = Evaluate("//foxutline",doc.documentElement)
I get a RuntimeException in
[pythonpath]\Lib\site-packages\_xmlplus\xpath\ParsedNodeTest.py, line
168 because of an undefined namespace "fox"
In the xml document, the namespace "fox" is defined, e.g. it has been
assigned an URL via xmlns:fox. I have installed pyxml 0.83 and 4suite
1.0a3.
Since I never had to deal with namespaces before, I have no real idea
what to try next. I don't like to use the DOM functions like
getElementsByTagNameNS, because xpath is more flexible. Is this error
above caused by the employed xml tools, or have I missed something
basic about xpath and namespaces in general?
Many thanks in advance
Piet
Via Xpath, I want to access nodes which have a namespace prefix. THe
document at hand is an Xsl-FO document. I tried the following:
from xml.dom import minidom
from xml.xpath import Evaluate
from xml import sax
parser = sax.make_parser()
parser.setFeature(sax.handler.feature_namespaces,1)
parser.setFeature(sax.handler.feature_namespace_prefixes,1)
doc = minidom.parse("fo-file.xml",parser)
#everything ok up to here
outlines = Evaluate("//foxutline",doc.documentElement)
I get a RuntimeException in
[pythonpath]\Lib\site-packages\_xmlplus\xpath\ParsedNodeTest.py, line
168 because of an undefined namespace "fox"
In the xml document, the namespace "fox" is defined, e.g. it has been
assigned an URL via xmlns:fox. I have installed pyxml 0.83 and 4suite
1.0a3.
Since I never had to deal with namespaces before, I have no real idea
what to try next. I don't like to use the DOM functions like
getElementsByTagNameNS, because xpath is more flexible. Is this error
above caused by the employed xml tools, or have I missed something
basic about xpath and namespaces in general?
Many thanks in advance
Piet