Package de.pdark.decentxml

Examples of de.pdark.decentxml.Namespace


    }
  }

  private String getDomName() {
    String domName = domElement.getName();
    Namespace ns = domElement.getNamespace();
    if (ns!=null) {
      String prefix = ns.getPrefix();
      if (!prefix.isEmpty()) {
        domName = prefix + ":" + domName;
      }
    }
    return domName;
View Full Code Here


    protected Node replaceNamespace(Node node, String oldNS, String newNS) {
        if (node instanceof Element) {
            String ns = getNamespaceURI(node);
            if (ns != null && ns.equals(oldNS)) {
                Namespace namespace = ((Element) node).getNamespace();
                if (namespace != null) {
                    if (namespace.getURI() != null && namespace.getURI().equals(oldNS)) {
                        ((Element) node).setNamespace(new Namespace(namespace.getPrefix(), newNS));
                    }
                }

                for (Attribute attr : ((Element) node).getAttributes()) {
                    if (attr.getName().startsWith("xmlns")) {
View Full Code Here

    public static List<Node> nodesByNamespace(Document doc, final String namespaceUri, final String localName) {
        NodeFilter<Node> filter = new NodeFilter<Node>() {
            @Override
            public boolean matches(Node n) {
                if (n instanceof Element) {
                    Namespace ns = ((Element) n).getNamespace();
                    // TODO this doesn't work with empty prefixes!
                    if (!((Element) n).getName().equals(localName)) {
                        return false;
                    } else {
                        String uri = getNamespaceURI(n);
View Full Code Here

        return buffer.toString();
    }

    public static String getNamespaceURI(Node node) {
        if (node instanceof Element) {
            Namespace ns = ((Element) node).getNamespace();
            if (ns != null) {
                String uri = ns.getURI();
                if (uri == null || uri.length() == 0) {
                    String uriAttr = ns.getPrefix().equals("") ? ((Element) node).getAttributeValue("xmlns") : null;
                    if (uriAttr != null) {
                        return uriAttr;
                    } else {
                        return getNamespaceURI(((Element) node).getParent());
                    }
View Full Code Here

    public static List<Node> nodesByNamespace(Document doc, final String namespaceUri, final String localName) {
        NodeFilter<Node> filter = new NodeFilter<Node>() {
            @Override
            public boolean matches(Node n) {
                if (n instanceof Element) {
                    Namespace ns = ((Element) n).getNamespace();
                    // TODO this doesn't work with empty prefixes!
                    if (!((Element) n).getName().equals(localName)) {
                        return false;
                    } else {
                        String uri = getNamespaceURI(n);
View Full Code Here

        return buffer.toString();
    }

    public static String getNamespaceURI(Node node) {
        if (node instanceof Element) {
            Namespace ns = ((Element) node).getNamespace();
            if (ns != null) {
                String uri = ns.getURI();
                if (uri == null || uri.length() == 0) {
                    String uriAttr = ns.getPrefix().equals("") ? ((Element) node).getAttributeValue("xmlns") : null;
                    if (uriAttr != null) {
                        return uriAttr;
                    } else {
                        return getNamespaceURI(((Element) node).getParent());
                    }
View Full Code Here

    protected Node replaceNamespace(Node node, String oldNS, String newNS) {
        if (node instanceof Element) {
            String ns = getNamespaceURI(node);
            if (ns != null && ns.equals(oldNS)) {
                Namespace namespace = ((Element) node).getNamespace();
                if (namespace != null) {
                    if (namespace.getURI() != null && namespace.getURI().equals(oldNS)) {
                        ((Element) node).setNamespace(new Namespace(namespace.getPrefix(), newNS));
                    }
                }

                for (Attribute attr : ((Element) node).getAttributes()) {
                    if (attr.getName().startsWith("xmlns")) {
View Full Code Here

TOP

Related Classes of de.pdark.decentxml.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.