cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

xpath_nodeset with namespaces question

ChrisWestern
7-Bedrock

xpath_nodeset with namespaces question

Hello Arbx Experts!


I have an acl script that uses an XML location path to get an objectID in editor.


This works no problem with regular XML trees. But with XML containing namespaces it does work the same.


The first full NS local name path shown below does not return the oid.


But the second path example changed and simplified through a regex does.


So my question:
Why does this first full explicit path type not work in Editor?
(it is a valid XML path as produced by get-path() in APP)


If anyone has an idea it would be good to understand why this is the case.


Many thanks
Chris



FULL PATH NOT WORKING


xpath_nodeset($nodeSet,"/node()[local-name()='BGTDOC' and namespace-uri()='http://www.senato.it/static/xml/def/1.0/bgt.html'][1]/node()[local-name()='dl:DDLMESS' and namespace-uri()='http://www.senato.it/static/xml/def/1.0/ddl.html'][1]/node()[local-name()='a:Articolato' and namespace-uri()='http://www.senato.it/static/xml/def/1.0/articolato.html'][1]/node()[local-name()='a:Articolo' and namespace-uri()='http://www.senato.it/static/xml/def/1.0/articolato.html'][1]/node()[local-name()='a:Num' and namespace-uri()='http://www.senato.it/static/xml/def/1.0/articolato.html'][1]/text()[1]");


MODIFIED PATH THAT IS WORKING


xpath_nodeset($nodeSet,"/*[local-name()='BGTDOC']/*[local-name()='DDLMESS']/*[local-name()='Articolato']/*[local-name()='Articolo']/*[local-name()='Num']/text()");



2 REPLIES 2

Hi Chris-

I think you need to remove the prefixes from your local-name strings in the first expression. Try something like this:

xpath_nodeset($nodeSet,"/node()[local-name()='BGTDOC' and namespace-uri()='

If APP is generating path strings containing comparisons like [local-name()='x:yyyy'], then it's doing it wrong. XPath doesn't understand anything about namespace prefixes-including how to ignore them. You have to say local-name()='yyyy' without the prefix (and then add in the separate namespace-uri() test, if you want to be specific).

--Clay

Hi Clay,



I will test both points you mention here, I guess the different parsers accept and generate different things in this case.



Many thanks

Chris


Top Tags