[esb-issues] [JBoss JIRA] Commented: (JBESB-1426) CBR XPathDSL should allow namespace aware documents

Daniel Bevenius (JIRA) jira-events at lists.jboss.org
Wed Jul 2 02:40:32 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBESB-1426?page=comments#action_12419562 ] 
            
Daniel Bevenius commented on JBESB-1426:
----------------------------------------

I've added this so that the namespaces that you want to use can be specified as a comma separated list of "prefix=uri" elements, like this:
ule "ProductId1"
	salience 100
	when
		xpathMatchNS "/o:Order/o:OrderLines/o:OrderLine/p:Product/@productId", "o=http://org.jboss.soa.esb/order, p=http://org.jboss.soa.esb/product"
	then
		Destination : "regular1";
end

So the XPathLanguage.dsl has been updated with the following "methods":
# Namespace(NS) aware methods
xpathMatchNS 
xpathEqualsNS 
xpathGreaterThanNS
xpathLessThanNS

Let me know if anyone has any thoughts on this solution.

> CBR XPathDSL should allow namespace aware documents
> ---------------------------------------------------
>
>                 Key: JBESB-1426
>                 URL: http://jira.jboss.com/jira/browse/JBESB-1426
>             Project: JBoss ESB
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>          Components: Content Based Routing
>    Affects Versions: 4.2.1
>            Reporter: Vinicius Carvalho
>         Assigned To: Daniel Bevenius
>            Priority: Optional
>             Fix For: 4.4
>
>
> Current version of DSLHelper, does not allow one to use namespace documents to be routed. For instance, the document
> <acme:bomb xmlns:acme="http://acme.com/schemas">
> <acme:model></acme:model>
> </acme:bomb>
> does not work with the xpath expression : "//acme:model" since the xpath is not namespace-aware.
> The use of a namespace should allow this, the action should support it, for instance:
>  <action name="ContentBasedRouter" class="org.jboss.soa.esb.actions.ContentBasedRouter">
>  <property name="namespaces">
>   <namespace prefix="acme" uri="http://acme.com/schemas"/>
>   <namespace prefix="foo" uri="http://bar.com/schemas"/>
>  </property>
> </action>
> On the configuration of the action (sorry still trying to figure where to put this :( )
> the following namespace could  be used:
> package com.synos.csm.eai.xml;
> import javax.xml.XMLConstants;
> import javax.xml.namespace.NamespaceContext;
> import java.util.Iterator;
> import java.util.Map;
> import java.util.HashMap;
> import java.util.Set;
> import java.util.ArrayList;
> import java.util.List;
>  
> public class CustomNamespaceContext implements NamespaceContext {
>     private Map map;
>  
>     public CustomNamespaceContext() {
>     	map = new HashMap();
>     	map.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
>     	map.put(XMLConstants.XMLNS_ATTRIBUTE, XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
> 	}
>  
>     public void addNamespace(String prefix, String namespaceURI) {
>         map.put(prefix, namespaceURI);
>     }
>  
>     public String getNamespaceURI(String prefix) {
>         return (String) map.get(prefix);
>     }
>  
>     public String getPrefix(String namespaceURI) {
>         Set keys = map.keySet();
>         for (Iterator iterator = keys.iterator(); iterator.hasNext();) 
> {
>             String prefix = (String) iterator.next();
>             String uri = (String) map.get(prefix);
>             if (uri.equals(namespaceURI)) return prefix;
>         }
>         return null;
>     }
>  
>     public Iterator getPrefixes(String namespaceURI) {
>         List prefixes = new ArrayList();
>         Set keys = map.keySet();
>         for (Iterator iterator = keys.iterator(); iterator.hasNext();) 
> {
>             String prefix = (String) iterator.next();
>             String uri = (String) map.get(prefix);
>             if (uri.equals(namespaceURI)) prefixes.add(prefix);
>         }
>         return prefixes.iterator();
>     }
> }
> now, inside the DSLHelper, set the namespace aware xpath:
> //check if user has set the namespace property
> if(namespaceAware)
>    xpath.setNamespaceContext(customNamespaceForThisAction);
> I had to override the DSLHelper in my project, I guess that this approach should help a lot

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the esb-issues mailing list