[esb-issues] [JBoss JIRA] Updated: (JBESB-1426) CBR XPathDSL should allow namespace aware documents
Daniel Bevenius (JIRA)
jira-events at lists.jboss.org
Wed Jul 2 04:41:31 EDT 2008
[ http://jira.jboss.com/jira/browse/JBESB-1426?page=all ]
Daniel Bevenius updated JBESB-1426:
-----------------------------------
Component/s: Documentation
Need to update documentation to describe how to use namespaces with XPathLanguage.dsl.
> 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: Documentation, 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