Namespaces with XPaths

Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Namespaces with XPaths

 
0
  #1
Mar 17th, 2009
Hi, everyone!

At work, I'm having problems to run a XPath using the selectNodeList() method from Xalan. The XPath I want to execute is:

//pam:message//prism:coverDate

The error message I have is: The prefix 'pam' is not declared.
expression = '//pam:message//prism:startingPage' Remaining tokens are: ('/' '/').

I have searched on the Internet and I think that I should make the XPathEvaluator recognize that namespace. My problem is: I don't know how to do that.

If someone can show me what to do, I will appreciate it.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,440
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1473
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Namespaces with XPaths

 
0
  #2
Mar 18th, 2009
Is this c++ ??? Never heard of XPath.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 960
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: Namespaces with XPaths

 
0
  #3
Mar 18th, 2009
Try the XML section.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Re: Namespaces with XPaths

 
0
  #4
Mar 18th, 2009
I'm sorry, I'm using Xalan in C++ and I'm looking for a solution.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 96
Reputation: fpmurphy is an unknown quantity at this point 
Solved Threads: 5
fpmurphy fpmurphy is offline Offline
Junior Poster in Training

Re: Namespaces with XPaths

 
0
  #5
Mar 18th, 2009
Add the pam namspace declaration in where the prism namespace is declared.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Re: Namespaces with XPaths

 
0
  #6
Mar 20th, 2009
I found a solution for my problem. I designed a class that derivates from PrefixResolver, a class that solves prefixes and namespaces. All I needed to do is to implement some methods, like setAPrefixAndAUri, getPrefix and getURI. I passed a PrefixResolver object to the XPathEvaluator with the correct prefix/uri pairs and the XPathEvaluator can recognize the prefix. I'm happy, now!

Thanks for your attention!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the XML, XSLT and XPATH Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC