473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error on xpath-ing a DOM with namespaces

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_pr efixes,1)
doc = minidom.parse("fo-file.xml",parser)
#everything ok up to here
outlines = Evaluate("//fox:outline",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
Jul 18 '05 #1
2 2031
From http://uche.ogbuji.net/tech/akara/no...01/basic-xpath

"""
NSS = {u'wsdl': u'http://schemas.xmlsoap.org/wsdl/'}
#""processorNss" = "namespace bindings to be used by the processor"
ctx = Context(wsdl_doc, processorNss=NSS)
Evaluate(u'wsdl:description/wsdl:documentation', context=ctx)
"""

Should give you a start.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
> NSS = {u'wsdl': u'http://schemas.xmlsoap.org/wsdl/'}
#""processorNss" = "namespace bindings to be used by the processor"
ctx = Context(wsdl_doc, processorNss=NSS)
Evaluate(u'wsdl:description/wsdl:documentation', context=ctx)
"""

Should give you a start.

Thanks a lot. I found a solution for my problem and lots of food for
thought for improving my XML handling in general.
Best regards
Piet
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Loudin | last post by:
Hello, I`ve got Problems with Xpath and xsltproc/libxslt. I have got a variable with tags in my Style sheet and later in the same Style sheet i want to work with this tags using a...
5
by: Galen Harris | last post by:
I'm getting weird errors during transformations -- "System.Net.WebException. The remote server returned an error: (500) Internal Server Error." I'm on the 1.0 Framework. I've looked through...
2
by: tschulken | last post by:
I am trying to get certain nodes within an xml doc that contain certain text (similar to a SQL LIKE). In doing so I am using the XPATH Contains function and have not been successful. When I run I...
44
by: MadCrazyNewbie | last post by:
Hey Group, I keep getting a error saying "No Value Given For One Or More Parameters". Unfortunatly I don`t know where this error is coming from:(. Can I run through my code line by line, so I...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
8
by: Alpha | last post by:
I created the following code in my C# program but it's giving me error message at run time of : XML.XPATH.XPATHEXCEPTION : Namespace Manager or XSLTContext needed. This query has a prefix,...
4
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
2
by: Emily | last post by:
Hi all, I have the following simplified version of xml file: <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'> <s:Schema id='RowsetSchema'> <s:ElementType name='row'>...
0
by: jacqueharper | last post by:
I am having a problem with an Excel ListObject in my C# .NET application. I am trying to map an XML schema to a ListObject, and continue to get the error "The XPath is not valid because either the...
3
by: moralbarometer | last post by:
Please i intend to make an XML document from a string using tranformer as shown below. It returns an error which trace is given below as well. please help. public org.w3c.dom.Node getTextXML()...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.