You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Luca Manganelli <ma...@itc.it> on 2004/10/21 14:20:22 UTC

Problem reading XML with XPath

Hi, I tried this command on the WSDL in attach:

java ApplyXPath customerProcess.wsdl "//message"

and the output is:

Loading classes, parsing customerProcess.wsdl, and setting up serializer
Querying DOM using //message
<output>
</output>

But if I remove the 4th row:

xmlns="http://schemas.xmlsoap.org/wsdl/"

the above example works.
I've tried it with Xerces 2.6.0 and 2.6.2 and none works without that 
modification.

Any idea?

Thank you,
Luca

Re: Problem reading XML with XPath

Posted by George Cristian Bina <ge...@sync.ro>.
Hi Luca,

XPath expressions do not make use of default namespace, as you want to 
match all the message elements from the http://schemas.xmlsoap.org/wsdl/ 
namespace you need a prefix to refer to these elements in your XPath 
expression:

//wsdl:message

and

you have to tell your XPath processor that wsdl maps to 
http://schemas.xmlsoap.org/wsdl/ namespace.

When you remove the xmlns="http://schemas.xmlsoap.org/wsdl/" then you 
put the message elements in no namespace and //message matches them.

Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Luca Manganelli wrote:
> Hi, I tried this command on the WSDL in attach:
> 
> java ApplyXPath customerProcess.wsdl "//message"
> 
> and the output is:
> 
> Loading classes, parsing customerProcess.wsdl, and setting up serializer
> Querying DOM using //message
> <output>
> </output>
> 
> But if I remove the 4th row:
> 
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> 
> the above example works.
> I've tried it with Xerces 2.6.0 and 2.6.2 and none works without that 
> modification.
> 
> Any idea?
> 
> Thank you,
> Luca
> 
> 
> ------------------------------------------------------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <definitions 
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
> xmlns="http://schemas.xmlsoap.org/wsdl/" 
> xmlns:tns="http://sra.itc.it/projects/astro/BC_Biella/customer" 
> xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" 
> xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> xmlns:tdns="http://sra.itc.it/projects/astro/BC_Biella/Typedef" 
> xmlns:cor="http://sra.itc.it/projects/astro/BC_Biella/Typedef" 
> targetNamespace="http://sra.itc.it/projects/astro/BC_Biella/customer" 
> name="customer">
> 
> 	<import namespace="http://sra.itc.it/projects/astro/BC_Biella/Typedef" location="Typedef.wsdl"/>
> 	<message name="conclusionProvision">
> 		<part name="customerRequest" type="tdns:customerRequest"/>
> 		<part name="conclusions" type="tdns:Conclus"/>
> 	</message>
> 	<message name="conferenceConvocation">
> 		<part name="customerRequest" type="tdns:customerRequest"/>
> 		<part name="conferenceDate" type="xsd:date"/>
> 	</message>
> 	<message name="notification">
> 		<part name="customerRequest" type="tdns:customerRequest"/>
> 		<part name="integrationRequired" type="xsd:boolean"/>
> 	</message>
> 	<message name="request">
> 		<part name="customerRequest" type="tdns:customerRequest"/>
> 	</message>
> 	<message name="reply">
> 		<part name="conclusions" type="tdns:Conclus"/>
> 	</message>
> 	
> 	<portType name="incomingPT">
> 		<operation name="sendClientRequest">
> 			<input message="tns:request"/>
> 			<output message="tns:reply"/>
> 		</operation>
> 		<operation name="sendNotification">
> 			<input message="tns:notification"/>
> 		</operation>
> 		<operation name="sendConclusionProvision">
> 			<input message="tns:conclusionProvision"/>
> 		</operation>
> 		<operation name="sendConvocation">
> 			<input message="tns:conferenceConvocation"/>
> 		</operation>
> 	</portType>
> 
> 	<service name="customerService"/>
> 
> 	<bpws:propertyAlias propertyName="cor:customerInfo" messageType="tns:request" part="customerRequest" query="/customerRequest/customerInfo"/>
> 	<bpws:propertyAlias propertyName="cor:requestDesc" messageType="tns:request" part="customerRequest" query="/customerRequest/requestDesc"/>
> 	<bpws:propertyAlias propertyName="cor:customerInfo" messageType="tns:notification" part="customerRequest" query="/customerRequest/customerInfo"/>
> 	<bpws:propertyAlias propertyName="cor:requestDesc" messageType="tns:notification" part="customerRequest" query="/customerRequest/requestDesc"/>
> 	<bpws:propertyAlias propertyName="cor:customerInfo" messageType="tns:conferenceConvocation" part="customerRequest" query="/customerRequest/customerInfo"/>
> 	<bpws:propertyAlias propertyName="cor:requestDesc" messageType="tns:conferenceConvocation" part="customerRequest" query="/customerRequest/requestDesc"/>
> 	<bpws:propertyAlias propertyName="cor:customerInfo" messageType="tns:conclusionProvision" part="customerRequest" query="/customerRequest/customerInfo"/>
> 	<bpws:propertyAlias propertyName="cor:requestDesc" messageType="tns:conclusionProvision" part="customerRequest" query="/customerRequest/requestDesc"/>
> 
> 	<plnk:partnerLinkType name="RISTnotifiesCustomer_LT">
> 		<plnk:role name="customerNotificationService">
> 			<plnk:portType name="tns:incomingPT"/>
> 		</plnk:role>
> 	</plnk:partnerLinkType>
> 	<plnk:partnerLinkType name="CustomerRPRO_LT">
> 		<plnk:role name="CustomerConfConvocationService">
> 			<plnk:portType name="tns:incomingPT"/>
> 		</plnk:role>
> 	</plnk:partnerLinkType>
> 
> 	<plnk:partnerLinkType name="PBSendsConclusionsCustomer_LT">
> 		<plnk:role name="customerConclusionService">
> 			<plnk:portType name="tns:incomingPT"/>
> 		</plnk:role>
> 	</plnk:partnerLinkType>
> 
> 	<plnk:partnerLinkType name="client">
> 		<plnk:role name="customerService">
> 			<plnk:portType name="tns:incomingPT"/>
> 		</plnk:role>
> 	</plnk:partnerLinkType>
> </definitions>
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Problem reading XML with XPath

Posted by Joseph Kesselman <ke...@us.ibm.com>.



XPath is namespace-sensitive. If you don't provide prefixes in your XPath,
bound to namespaces via a PrefixResolver, it will not match namespaced
nodes.

(XPath 2.0 is planning to add support for default namespaces in XPath
syntax, but that isn't available yet.)

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Problem reading XML with XPath

Posted by Luca Manganelli <ma...@itc.it>.
Suresh Babu Koya wrote:

> Try using //*[local-name(.)='message']
>  
> This neutralizes the effects of namespaces.

You're GREAT! ;-)


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: Problem reading XML with XPath

Posted by Suresh Babu Koya <sk...@in-reality.com>.
Try using //*[local-name(.)='message']

This neutralizes the effects of namespaces.

/Suresh
  -----Original Message-----
  From: Phil Weighill-Smith [mailto:phil.weighill-smith@volantis.com]
  Sent: Thursday, October 21, 2004 6:27 PM
  To: xerces-j-user@xml.apache.org
  Subject: Re: Problem reading XML with XPath


  Don't know if I've got the wrong end of the stick but XPath doesn't work like XML with respect to default namespaces: XPath doesn't support default namespaces (no prefix == no namespace). You must ensure that any XPath is specified with a prefix that maps to the XML's default namespace (the prefix can be any prefix string you like).

  E.g.

  <myxml xmlns="blah">
      <something>
          text
      </something>
  </myxml>

  can be queried thus:

  //prefix:myxml/prefix:something/text()

  with "prefix" mapped to "blah".

  hth.

  Phil :n.

  On Thu, 2004-10-21 at 13:51, Luca Manganelli wrote: 
Yanbin Ma wrote:

>If you change it to :
>Xmlns:mytag=http://schemas.xmlsoap.org/wsdl/
>
>It will work for you. -- Yanbin
>  
>
I cannot modify wsdl -- there are "fixed" ;)

But two questions:

1) why the Xpath doesn't work without above modification;
2) if there is another way to resolve the problem (without wsdl 
modification)

Thank you in advance ;)
Luca


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
-- Phil Weighill-Smith <ph...@volantis.com>Volantis Systems  



Re: Problem reading XML with XPath

Posted by Phil Weighill-Smith <ph...@volantis.com>.
Don't know if I've got the wrong end of the stick but XPath doesn't work
like XML with respect to default namespaces: XPath doesn't support
default namespaces (no prefix == no namespace). You must ensure that any
XPath is specified with a prefix that maps to the XML's default
namespace (the prefix can be any prefix string you like).

E.g.

<myxml xmlns="blah">
    <something>
        text
    </something>
</myxml>

can be queried thus:

//prefix:myxml/prefix:something/text()

with "prefix" mapped to "blah".

hth.

Phil :n.

On Thu, 2004-10-21 at 13:51, Luca Manganelli wrote:

> Yanbin Ma wrote:
> 
> >If you change it to :
> >Xmlns:mytag=http://schemas.xmlsoap.org/wsdl/
> >
> >It will work for you. -- Yanbin
> >  
> >
> I cannot modify wsdl -- there are "fixed" ;)
> 
> But two questions:
> 
> 1) why the Xpath doesn't work without above modification;
> 2) if there is another way to resolve the problem (without wsdl 
> modification)
> 
> Thank you in advance ;)
> Luca
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

-- 
Phil Weighill-Smith <ph...@volantis.com>
Volantis Systems

Re: Problem reading XML with XPath

Posted by Luca Manganelli <ma...@itc.it>.
Yanbin Ma wrote:

>If you change it to :
>Xmlns:mytag=http://schemas.xmlsoap.org/wsdl/
>
>It will work for you. -- Yanbin
>  
>
I cannot modify wsdl -- there are "fixed" ;)

But two questions:

1) why the Xpath doesn't work without above modification;
2) if there is another way to resolve the problem (without wsdl 
modification)

Thank you in advance ;)
Luca


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: Problem reading XML with XPath

Posted by Yanbin Ma <ym...@competitrack.com>.
If you change it to :
Xmlns:mytag=http://schemas.xmlsoap.org/wsdl/

It will work for you. -- Yanbin

-----Original Message-----
From: Luca Manganelli [mailto:manganelli@itc.it] 
Sent: Thursday, October 21, 2004 8:20 AM
To: xerces-j-user@xml.apache.org
Subject: Problem reading XML with XPath

Hi, I tried this command on the WSDL in attach:

java ApplyXPath customerProcess.wsdl "//message"

and the output is:

Loading classes, parsing customerProcess.wsdl, and setting up serializer
Querying DOM using //message
<output>
</output>

But if I remove the 4th row:

xmlns="http://schemas.xmlsoap.org/wsdl/"

the above example works.
I've tried it with Xerces 2.6.0 and 2.6.2 and none works without that 
modification.

Any idea?

Thank you,
Luca



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org