Package org.dom4j

Examples of org.dom4j.Namespace


              .getTargetURI())));
    }

    // Create a content
    Document doc = DocumentHelper.createDocument();
    Namespace nsWordprocessinML = new Namespace("w",
        "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
    Element elDocument = doc.addElement(new QName("document",
        nsWordprocessinML));
    Element elBody = elDocument.addElement(new QName("body",
        nsWordprocessinML));
View Full Code Here


      throws InvalidFormatException {
    // Check the current element
    List declaredNamespaces = el.declaredNamespaces();
    Iterator itNS = declaredNamespaces.iterator();
    while (itNS.hasNext()) {
      Namespace ns = (Namespace) itNS.next();

      // Rule M4.2
      if (ns.getURI().equals(PackageNamespaces.MARKUP_COMPATIBILITY))
        throw new InvalidFormatException(
            "OPC Compliance error [M4.2]: A format consumer shall consider the use of the Markup Compatibility namespace to be an error.");
    }

    // Rule M4.3
View Full Code Here

      ZipOutputStream zos) {
    // Building xml
    Document xmlOutDoc = DocumentHelper.createDocument();
    // make something like <Relationships
    // xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    Namespace dfNs = Namespace.get("", PackageNamespaces.RELATIONSHIPS);
    Element root = xmlOutDoc.addElement(new QName(
        PackageRelationship.RELATIONSHIPS_TAG_NAME, dfNs));

    // <Relationship
    // TargetMode="External"
View Full Code Here

    public static boolean isElementInNamespace(Element element, String namespace)
    {
        Asserts.assertNotNull(element, "element parameter can not be null");
        Asserts.assertNotNull(namespace, "namespace parameter can not be null");

        Namespace ns = element.getNamespace();
        if (!Namespace.NO_NAMESPACE.equals(ns))
        {
            if (ns.getURI().equals(namespace))
            {
                return true;
            }
        }
View Full Code Here

    public static String getElementNameSpace(Element element)
    {
        nullCheckForElement(element);

        Namespace ns = element.getNamespace();
        if (!Namespace.NO_NAMESPACE.equals(ns))
        {
            return ns.getURI();
        }

        return null;
    }
View Full Code Here

//        </feed>

        Document doc = DocumentFactory.getInstance().createDocument();
        Element root = doc.addElement("feed");
        String NS = "http://www.w3.org/2005/Atom";
        root.add(new Namespace("", NS));

        root.addElement("title", NS).setText("Speakeasy Extensions");
        root.addElement("subtitle", NS).setText("Via " + serverName);
        root.addElement("link", NS).addAttribute("href", serverBaseUrl + profilePath);
        root.addElement("link", NS)
View Full Code Here

        HashSet prefixes = new HashSet();
        for ( Element context = element; context != null; context = context.getParent() ) {
            List declaredNS = context.declaredNamespaces();
            for ( Iterator iter = declaredNS.iterator(); iter.hasNext(); )
            {
                Namespace namespace = (Namespace) iter.next();
                String prefix = namespace.getPrefix();
                if ( ! prefixes.contains( prefix ) ) {
                    prefixes.add( prefix );
                    nsList.add( namespace.asXPathResult( element ) );
                }
            }
        }
        nsList.add( Namespace.XML_NAMESPACE.asXPathResult( element ) );
        return nsList.iterator();
View Full Code Here

        return node.getStringValue();
    }

    public String getNamespaceStringValue(Object obj)
    {
        Namespace ns = (Namespace) obj;

        return ns.getURI();
    }
View Full Code Here

        return ns.getURI();
    }

    public String getNamespacePrefix(Object obj)
    {
        Namespace ns = (Namespace) obj;

        return ns.getPrefix();
    }
View Full Code Here

            Node node = (Node) context;
            element = node.getParent();
        }
        if ( element != null )
        {
            Namespace namespace = element.getNamespaceForPrefix( prefix );

            if ( namespace != null )
            {
                return namespace.getURI();
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.dom4j.Namespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.