In that case, the XPath should look like this: //*[local-name()='Message']/*[local-name()='header']/*[local-name()='msgType']
This is ugly, but this is to be expected since you are using an XML anti-pattern, namely defining different XML formats that have similar structure but use different namespaces. Andreas On Fri, Oct 8, 2010 at 20:28, Abid Khan-EXT <[email protected]> wrote: > Hiranya, > > Thanks for the quick response, but I cannot put the URL either since > different messages will have different namespace and or URL. > > Thanks & Regards, > Abid > > > -----Original Message----- > From: Hiranya Jayathilaka [mailto:[email protected]] > Sent: Friday, October 08, 2010 12:25 PM > To: [email protected] > Subject: Re: If the message has name space setting the switch mediator does > not work? > > On Fri, Oct 8, 2010 at 9:42 PM, Abid Khan-EXT <[email protected]> wrote: >> Hello Andreas, >> >> I understand that, but what if the message has no-prefix namespace something >> like: > > That's fine. As far as the functionality is concerned, URL is he > important part in the namespace. Prefix could be anything. The prefix > used in your XPath doesn't have to match to the prefix in the message. > In fact message doesn't have to have a prefix at all. > > Thanks, > Hiranya > > >> >> <Message xmlns="http://www.company.com/test"/> >> .... >> ... >> </Message> >> >> This what I have most of the messages that I am processing with Synapse, >> have not prefix name space or default namespace declaration. Which is the >> problem I am facing. >> >> >> >> Thanks & Regards, >> Abid >> >> >> -----Original Message----- >> From: Andreas Veithen [mailto:[email protected]] >> Sent: Friday, October 08, 2010 10:07 AM >> To: [email protected] >> Subject: Re: If the message has name space setting the switch mediator does >> not work? >> >> Try with something like this: >> >> <switch source="//p:Message/p:header/p:msgType" >> xmlns:p="http://www.company.com/test"> >> >> Note that XPath expressions in Synapse configuration files are >> supposed to work the same way as XPath expressions in XSLT, so if you >> have a colleague who is familiar with XSLT, he may help you to figure >> out the details. >> >> Andreas >> >> On Fri, Oct 8, 2010 at 17:46, Abid Khan-EXT <[email protected]> wrote: >>> I am not sure what is the difference in both ways here is how I am creating >>> the switch: >>> >>> <switch source="//Message/header/msgType"> >>> <case regex="RequesResponse"> >>> <validate> >>> <schema key="Message01"/> >>> <on-fail> >>> <sequence key="ValidationFaultSequence" /> >>> </on-fail> >>> </validate> >>> </case> >>> <case regex="Publish"> >>> <validate> >>> <schema key=" Message02"/> >>> <on-fail> >>> <sequence key="ValidationFaultSequence" /> >>> </on-fail> >>> </validate>^M >>> </case> >>> </switch> >>> >>> This exact switch works if the name space of the document is removed, and >>> does not work otherwise. >>> >>> Please advise. >>> >>> Thanks & Regards, >>> Abid >>> >>> -----Original Message----- >>> From: Supun Kamburugamuva [mailto:[email protected]] >>> Sent: Thursday, October 07, 2010 8:29 PM >>> To: [email protected] >>> Subject: Re: If the message has name space setting the switch mediator does >>> not work? >>> >>> I believe you are using XPath to get a value of a element. You can write a >>> Xpath in such a way that it works both with namespace qualified elements as >>> well as normal elements. >>> >>> Thanks, >>> Supun.. >>> >>> On Tue, Sep 28, 2010 at 9:12 PM, Abid Khan-EXT >>> <[email protected]>wrote: >>> >>>> Hello all, >>>> >>>> I am receiving a message and the switch works if I take the namespace >>>> string out of the message, but I cannot tell the sender to remove it. Is >>>> there anything I can do that synapse can handle the name space. >>>> >>>> Message that starts with something like this is not handled properly, by >>>> "switch" mediator. >>>> >>>> <Request xmlns="http://www.company.com/test" xmlns:xsi=" >>>> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" >>>> http://www.company.com/test ../test/Request.xsd"> >>>> >>>> >>>> Thanks & Regards, >>>> >>>> Abid Khan >>>> Java Consultant >>>> >>>> >>>> >>> >>> >>> -- >>> Tech Lead, WSO2 Inc >>> http://wso2.org >>> supunk.blogspot.com >>> >> > > > > -- > Hiranya Jayathilaka > Senior Software Engineer; > WSO2 Inc.; http://wso2.org > E-mail: [email protected]; Mobile: +94 77 633 3491 > Blog: http://techfeast-hiranya.blogspot.com >
