Java Code Examples for org.dom4j.Namespace.get()

The following are Jave code examples for showing how to use get() of the org.dom4j.Namespace class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jaxen   File: DOM4JXPathTest.java   Source Code and License Vote up 6 votes
public void testNamespaceNodesAreInherited() throws JaxenException
{
        Namespace ns0 = Namespace.get("p0", "www.acme0.org");
        Namespace ns1 = Namespace.get("p1", "www.acme1.org");
        Namespace ns2 = Namespace.get("p2", "www.acme2.org");
        Element element = new DefaultElement("test", ns1);
        Attribute attribute = new DefaultAttribute("pre:foo", "bar", ns2);
        element.add(attribute);
        Element root = new DefaultElement("root", ns0);
        root.add(element);
        Document doc = new DefaultDocument(root);
        
        XPath xpath = new Dom4jXPath( "/*/*/namespace::node()" );

        List results = xpath.selectNodes( doc );

        assertEquals( 4,
                      results.size() );
}
 
Example 2
Project: OpenZAL   File: InternalDocumentService.java   Source Code and License Vote up 6 votes
@Override
public void registerHandlers(DocumentDispatcher dispatcher)
{
  mHandlerMapPublisher.receivedHandlerMap( dispatcher.getHandlers() );

  Map<QName, ? extends SoapHandler> services = mSoapService.getServices();
  for (Map.Entry<QName, ? extends SoapHandler> entry : services.entrySet())
  {
    QName qName = entry.getKey();
    org.dom4j.QName zimbraQName = new org.dom4j.QName(
      qName.getName(),
      Namespace.get(qName.getNamespace())
    );

    dispatcher.registerHandler(
      zimbraQName,
      wrapHandler(entry.getValue())
    );
  }
}
 
Example 3
Project: OpenZAL   File: InternalRestoreDocumentService.java   Source Code and License Vote up 6 votes
@Override
public void registerHandlers(@NotNull DocumentDispatcher dispatcher)
{
  Map<QName, ? extends SoapHandler> services = mSoapService.getServices();
  for( QName qName : services.keySet() )
  {
    org.dom4j.QName zimbraQName = new org.dom4j.QName(
      qName.getName(),
      Namespace.get(qName.getNamespace())
    );

    dispatcher.unRegisterHandler(
      zimbraQName
    );

    if( mOriginalHandlersMap.containsKey(zimbraQName) )
    {
      dispatcher.registerHandler(
        zimbraQName,
        mOriginalHandlersMap.get(zimbraQName)
      );
    }
  }
}
 
Example 4
Project: OpenZAL   File: InternalUnregisterDocumentService.java   Source Code and License Vote up 6 votes
@Override
public void registerHandlers(@NotNull DocumentDispatcher dispatcher)
{
  Map<QName, ? extends SoapHandler> services = mSoapService.getServices();
  for( QName qName : services.keySet() )
  {
    org.dom4j.QName zimbraQName = new org.dom4j.QName(
      qName.getName(),
      Namespace.get(qName.getNamespace())
    );

    dispatcher.unRegisterHandler(
      zimbraQName
    );
  }
}
 
Example 5
Project: jaxen   File: DOM4JXPathTest.java   Source Code and License Vote up 5 votes
public void testJaxen20AttributeNamespaceNodes() throws JaxenException
{

    Namespace ns1 = Namespace.get("p1", "www.acme1.org");
    Namespace ns2 = Namespace.get("p2", "www.acme2.org");
    Element element = new DefaultElement("test", ns1);
    Attribute attribute = new DefaultAttribute("pre:foo", "bar", ns2);
    element.add(attribute); 
    Document doc = new DefaultDocument(element);
    
    XPath xpath = new Dom4jXPath( "//namespace::node()" );
    List results = xpath.selectNodes( doc );
    assertEquals( 3, results.size() );

}
 
Example 6
Project: tesb-studio-se   File: RouteJavaScriptOSGIForESBManager.java   Source Code and License Vote up 5 votes
private static void moveNamespace(Element treeRoot, String oldNspURI, String newNspURI) {
    Namespace oldNsp = treeRoot.getNamespace();
    if (oldNspURI.equals(oldNsp.getURI())) {
        Namespace newNsp = Namespace.get(oldNsp.getPrefix(), newNspURI);
        treeRoot.setQName(QName.get(treeRoot.getName(), newNsp));
        treeRoot.remove(oldNsp);
    }
    moveNamespaceInChildren(treeRoot, oldNspURI, newNspURI);
}
 
Example 7
Project: tesb-studio-se   File: RouteJavaScriptOSGIForESBManager.java   Source Code and License Vote up 5 votes
private static void moveNamespaceInChildren(Element treeRoot, String oldNspURI, String newNspURI) {
    for (Iterator<?> i = treeRoot.elementIterator(); i.hasNext();) {
        Element e = (Element) i.next();
        Namespace oldNsp = e.getNamespace();
        if (oldNspURI.equals(oldNsp.getURI())) {
            Namespace newNsp = Namespace.get(oldNsp.getPrefix(), newNspURI);
            e.setQName(QName.get(e.getName(), newNsp));
            e.remove(oldNsp);
        }
        moveNamespaceInChildren(e, oldNspURI, newNspURI);
    }
}
 
Example 8
Project: OpenZAL   File: InternalOverrideDocumentServiceImpl.java   Source Code and License Vote up 5 votes
@Override
public void registerHandlers(DocumentDispatcher dispatcher)
{
  // these are latest original handlers, they may be already overriden
  Map<org.dom4j.QName, DocumentHandler> oringinalHandlers = dispatcher.getHandlers();
  mHandlerMapPublisher.receivedHandlerMap(oringinalHandlers);

  Map<QName, OverridenSoapHandler> services = mSoapService.getServices();
  for (Map.Entry<QName, OverridenSoapHandler> entry : services.entrySet())
  {
    QName qName = entry.getKey();
    org.dom4j.QName zimbraQName = new org.dom4j.QName(
      qName.getName(),
      Namespace.get(qName.getNamespace())
    );

    DocumentHandler originalDocumentHandler = null;
    if (mOriginalHandlers.containsKey(zimbraQName))
    {
      originalDocumentHandler = mOriginalHandlers.get(zimbraQName);
      entry.getValue().setOriginalHandler(
        unWrapHandler(
          originalDocumentHandler
        )
      );
    }

    if( originalDocumentHandler != null )
    {
      dispatcher.registerHandler(
        zimbraQName,
        wrapHandler(entry.getValue(), originalDocumentHandler)
      );
    }
    else
    {
      ZimbraLog.extensions.warn("Unable to proxy SOAP Request: "+zimbraQName.toString());
    }
  }
}
 
Example 9
Project: jamppa   File: SASLMechanism.java   Source Code and License Vote up 5 votes
private static Element createAuthEl(String name, String authenticationText) {
    if (name == null) {
        throw new NullPointerException(
                "SASL mechanism name shouldn't be null.");
    }
    DefaultElement authEl = new DefaultElement("auth",
            Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl"));
    authEl.addAttribute("mechanism", name);
    if (authenticationText != null) {
        authEl.setText(authenticationText);
    }
    return authEl;
}
 
Example 10
Project: jamppa   File: SASLMechanism.java   Source Code and License Vote up 5 votes
private static Element createChallengeEl(String data) {
    DefaultElement authEl = new DefaultElement("challenge",
            Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl"));
    if (data != null) {
        authEl.setText(data);
    }
    return authEl;
}
 
Example 11
Project: jamppa   File: SASLMechanism.java   Source Code and License Vote up 5 votes
private static Element createResponseEl(String authenticationText) {
    DefaultElement authEl = new DefaultElement("response",
            Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl"));
    if (authenticationText != null && !authenticationText.isEmpty()) {
        authEl.setText(authenticationText);
    }
    return authEl;
}
 
Example 12
Project: jamppa   File: SASLMechanism.java   Source Code and License Vote up 5 votes
private static Element createEl(String condition) {
    Element el = new DefaultElement("failure",
            Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl"));
    if (condition != null && condition.trim().length() > 0) {
        el.addElement(condition);
    }
    return el;
}