Package org.apache.axiom.c14n.omwrapper.interfaces

Examples of org.apache.axiom.c14n.omwrapper.interfaces.Attr


        }
        return n;
    }

    public Attr getAttribute(Object o, OMElement parent){
        Attr at = (Attr)map.get(o);
        if (at == null){
            if (o instanceof OMAttribute || o instanceof OMNamespace) {
                at = new AttrImpl(o, parent, this);
            }
            map.put(o, at);
View Full Code Here


     * @return returns a negative integer, zero, or a positive integer as
     *         obj0 is less than, equal to, or greater than obj1
     */
    public int compare(Object obj0, Object obj1) {

        Attr attr0 = (Attr) obj0;
        Attr attr1 = (Attr) obj1;
        String namespaceURI0 = attr0.getNamespaceURI();
        String namespaceURI1 = attr1.getNamespaceURI();

        boolean isNamespaceAttr0 = XMLNS == namespaceURI0;
        boolean isNamespaceAttr1 = XMLNS == namespaceURI1;

        if (isNamespaceAttr0) {
            if (isNamespaceAttr1) {
                // both are namespaces
                String localname0 = attr0.getLocalName();
                String localname1 = attr1.getLocalName();

                if (localname0.equals("xmlns")) {
                    localname0 = "";
                }

                if (localname1.equals("xmlns")) {
                    localname1 = "";
                }

                return localname0.compareTo(localname1);
            }
            // attr0 is a namespace, attr1 is not
            return ATTR0_BEFORE_ATTR1;
        }

        if (isNamespaceAttr1) {
            // attr1 is a namespace, attr0 is not
            return ATTR1_BEFORE_ATTR0;
        }

        // none is a namespace
        if (namespaceURI0 == null) {
            if (namespaceURI1 == null) {
                String name0 = attr0.getName();
                String name1 = attr1.getName();
                return name0.compareTo(name1);
            }
            return ATTR0_BEFORE_ATTR1;
        }

        if (namespaceURI1 == null) {
            return ATTR1_BEFORE_ATTR0;
        }

        int a = namespaceURI0.compareTo(namespaceURI1);
        if (a != 0) {
            return a;
        }

        return (attr0.getLocalName()).compareTo(attr1.getLocalName());
    }
View Full Code Here

        }
        //The prefix visibly utilized(in the attribute or in the name) in the element
        SortedSet visiblyUtilized = (SortedSet) _inclusiveNSSet.clone();

        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);

            if (XMLNS_URI != N.getNamespaceURI()) {
                //Not a namespace definition.
                //The Element is output element, add his prefix(if used) to visibyUtilized
                String prefix = N.getPrefix();
                if ((prefix != null) && (!prefix.equals(XML) && !prefix.equals(XMLNS))) {
                    visiblyUtilized.add(prefix);
                }
                //Add to the result.
                result.add(N);
                continue;
            }
            String NName = N.getLocalName();
            String NNodeValue = N.getNodeValue();

            if (ns.addMapping(NName, NNodeValue, N)) {
                //New definition check if it is relative.
                if (C14nHelper.namespaceIsRelative(NNodeValue)) {
                    Object exArgs[] = {E.getTagName(), NName,
                            N.getNodeValue()};
                    throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
                }
            }
        }
        String prefix;
        if (E.getNamespaceURI() != null) {
            prefix = E.getPrefix();
            if ((prefix == null) || (prefix.length() == 0)) {
                prefix = XMLNS;
            }

        } else {
            prefix = XMLNS;
        }
        visiblyUtilized.add(prefix);

        Iterator it = visiblyUtilized.iterator();
        while (it.hasNext()) {
            String s = (String) it.next();
            Attr key = ns.getMapping(s);
            if (key == null) {
                continue;
            }
            result.add(key);
        }
View Full Code Here

        result.clear();
        NamedNodeMap attrs = E.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);
            String NUri = N.getNamespaceURI();

            if (XMLNS_URI != NUri) {
                //It's not a namespace attr node. Add to the result and continue.
                result.add(N);
                continue;
            }

            String NName = N.getLocalName();
            String NValue = N.getValue();
            if (XML.equals(NName)
                    && XML_LANG_URI.equals(NValue)) {
                //The default mapping for xml must not be output.
                continue;
            }

            Node n = ns.addMappingAndRender(NName, NValue, N);

            if (n != null) {
                //Render the ns definition
                result.add(n);
                if (C14nHelper.namespaceIsRelative(N)) {
                    Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
                    throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
                }
            }
        }
View Full Code Here

        }
        xmlattrStack.push(-1);
        NamedNodeMap attrs = e.getAttributes();
        int attrsLength = attrs.getLength();
        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);
            if (Constants.NamespaceSpecNS != N.getNamespaceURI()) {
                //Not a namespace definition, ignore.
                if (XML_LANG_URI == N.getNamespaceURI()) {
                    xmlattrStack.addXmlnsAttr(N);
                }
                continue;
            }

            String NName = N.getLocalName();
            String NValue = N.getNodeValue();
            if (XML.equals(NName)
                    && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
                continue;
            }
            ns.addMapping(NName, NValue, N);
View Full Code Here

            Map loa = new HashMap();
            for (; size >= 0; size--) {
                e = (XmlsStackElement) levels.get(size);
                Iterator it = e.nodes.iterator();
                while (it.hasNext()) {
                    Attr n = (Attr) it.next();
                    if (!loa.containsKey(n.getName()))
                        loa.put(n.getName(), n);
                }

            }
            ;
            cur.rendered = true;
View Full Code Here

     * @return returns a negative integer, zero, or a positive integer as
     *         obj0 is less than, equal to, or greater than obj1
     */
    public int compare(Object obj0, Object obj1) {

        Attr attr0 = (Attr) obj0;
        Attr attr1 = (Attr) obj1;
        String namespaceURI0 = attr0.getNamespaceURI();
        String namespaceURI1 = attr1.getNamespaceURI();

        boolean isNamespaceAttr0 = XMLNS == namespaceURI0;
        boolean isNamespaceAttr1 = XMLNS == namespaceURI1;

        if (isNamespaceAttr0) {
            if (isNamespaceAttr1) {
                // both are namespaces
                String localname0 = attr0.getLocalName();
                String localname1 = attr1.getLocalName();

                if (localname0.equals("xmlns")) {
                    localname0 = "";
                }

                if (localname1.equals("xmlns")) {
                    localname1 = "";
                }

                return localname0.compareTo(localname1);
            }
            // attr0 is a namespace, attr1 is not
            return ATTR0_BEFORE_ATTR1;
        }

        if (isNamespaceAttr1) {
            // attr1 is a namespace, attr0 is not
            return ATTR1_BEFORE_ATTR0;
        }

        // none is a namespace
        if (namespaceURI0 == null) {
            if (namespaceURI1 == null) {
                String name0 = attr0.getName();
                String name1 = attr1.getName();
                return name0.compareTo(name1);
            }
            return ATTR0_BEFORE_ATTR1;
        }

        if (namespaceURI1 == null) {
            return ATTR1_BEFORE_ATTR0;
        }

        int a = namespaceURI0.compareTo(namespaceURI1);
        if (a != 0) {
            return a;
        }

        return (attr0.getLocalName()).compareTo(attr1.getLocalName());
    }
View Full Code Here

        }
        //The prefix visibly utilized(in the attribute or in the name) in the element
        SortedSet visiblyUtilized = (SortedSet) _inclusiveNSSet.clone();

        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);

            if (XMLNS_URI != N.getNamespaceURI()) {
                //Not a namespace definition.
                //The Element is output element, add his prefix(if used) to visibyUtilized
                String prefix = N.getPrefix();
                if ((prefix != null) && (!prefix.equals(XML) && !prefix.equals(XMLNS))) {
                    visiblyUtilized.add(prefix);
                }
                //Add to the result.
                result.add(N);
                continue;
            }
            String NName = N.getLocalName();
            String NNodeValue = N.getNodeValue();

            if (ns.addMapping(NName, NNodeValue, N)) {
                //New definition check if it is relative.
                if (C14nHelper.namespaceIsRelative(NNodeValue)) {
                    Object exArgs[] = {E.getTagName(), NName,
                            N.getNodeValue()};
                    throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
                }
            }
        }
        String prefix;
        if (E.getNamespaceURI() != null) {
            prefix = E.getPrefix();
            if ((prefix == null) || (prefix.length() == 0)) {
                prefix = XMLNS;
            }

        } else {
            prefix = XMLNS;
        }
        visiblyUtilized.add(prefix);

        Iterator it = visiblyUtilized.iterator();
        while (it.hasNext()) {
            String s = (String) it.next();
            Attr key = ns.getMapping(s);
            if (key == null) {
                continue;
            }
            result.add(key);
        }
View Full Code Here

        result.clear();
        NamedNodeMap attrs = E.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);
            String NUri = N.getNamespaceURI();

            if (XMLNS_URI != NUri) {
                //It's not a namespace attr node. Add to the result and continue.
                result.add(N);
                continue;
            }

            String NName = N.getLocalName();
            String NValue = N.getValue();
            if (XML.equals(NName)
                    && XML_LANG_URI.equals(NValue)) {
                //The default mapping for xml must not be output.
                continue;
            }

            Node n = ns.addMappingAndRender(NName, NValue, N);

            if (n != null) {
                //Render the ns definition
                result.add(n);
                if (C14nHelper.namespaceIsRelative(N)) {
                    Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
                    throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
                }
            }
        }
View Full Code Here

        }
        xmlattrStack.push(-1);
        NamedNodeMap attrs = e.getAttributes();
        int attrsLength = attrs.getLength();
        for (int i = 0; i < attrsLength; i++) {
            Attr N = (Attr) attrs.item(i);
            if (Constants.NamespaceSpecNS != N.getNamespaceURI()) {
                //Not a namespace definition, ignore.
                if (XML_LANG_URI == N.getNamespaceURI()) {
                    xmlattrStack.addXmlnsAttr(N);
                }
                continue;
            }

            String NName = N.getLocalName();
            String NValue = N.getNodeValue();
            if (XML.equals(NName)
                    && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
                continue;
            }
            ns.addMapping(NName, NValue, N);
View Full Code Here

TOP

Related Classes of org.apache.axiom.c14n.omwrapper.interfaces.Attr

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.