Package org.castor.xmlctf.xmldiff.xml.nodes

Examples of org.castor.xmlctf.xmldiff.xml.nodes.Attribute


                idx = attName.indexOf(':');
                if (idx > 0) {
                    ns = element.getNamespaceURI(attName.substring(0, idx));
                    attName = attName.substring(idx + 1);
                }
                element.addAttribute(new Attribute(ns, attName, atts.getValue(i)));
            }
        }

        // Set the namespace on this Element, if one is explicit or defaulted
        if (prefix != null && prefix.length() > 0) {
View Full Code Here


     */
    private int compareAttributes(final Element node1, final Element node2) {
        int diffCount = 0;

        for (Iterator i = node1.getAttributeIterator(); i.hasNext(); ) {
            Attribute attr1 = (Attribute) i.next();

            // Does node2 have this attribute at all?
            String attValue2 = node2.getAttribute(attr1.getNamespaceURI(), attr1.getLocalName());
            if (attValue2 == null) {
                // Is this an attribute that is allowed to be missing sometimes?
                if (missingattributeIsIgnorable(attr1)) {
                    continue;
                }

                // If not, complain
                printElementChangeBlock(node1, node2, "Attribute '"
                                        + attr1.getNodeLocation()
                                        + "' does not exist in the second document.");
                diffCount++;
                continue;
            }

            // If it does, does it have the same value?
            String attValue1 = attr1.getStringValue();
            if (!compareTextLikeQName(node1, node2, attValue1, attValue2)) {
                printElementChangeBlock(node1, node2, "Attribute '"
                                        + attr1.getNodeLocation()
                                        + "' values are different.");
                diffCount++;
            }
        }

        // Look for attributes on node 2 that are not on node 1
        for (Iterator i = node2.getAttributeIterator(); i.hasNext(); ) {
            Attribute attr2 = (Attribute) i.next();
            if (node1.getAttribute(attr2.getNamespaceURI(), attr2.getLocalName()) == null) {
                // Is this an attribute that is allowed to be missing sometimes?
                if (missingattributeIsIgnorable(attr2)) {
                    continue;
                }

                // If not, complain
                printElementChangeBlock(node1, node2, "Attribute '"
                                        + attr2.getNodeLocation()
                                        + "' does not exist in the first document.");
                diffCount++;
            }
        }

View Full Code Here

    private void printElement(final Element node) {
        _pw.print('<' + node.getLocalName());

        for (Iterator i = node.getAttributeIterator(); i.hasNext(); ) {
            Attribute attr = (Attribute) i.next();
            _pw.print(' ');
            _pw.print(attr.getLocalName());
            _pw.print("=\"");
            _pw.print(attr.getStringValue());
            _pw.print("\"");
        }

        _pw.println('>');
    }
View Full Code Here

TOP

Related Classes of org.castor.xmlctf.xmldiff.xml.nodes.Attribute

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.