}
// Create NodeIterators for both the "empty" and "input" instance documents
// NOTE: must have DOM level 2 to allow DocumentTraversal.
DocumentTraversal traversableS = (DocumentTraversal) instanceS;
NodeIterator iteratorS = traversableS.createNodeIterator(instanceS, NodeFilter.SHOW_ALL, null, true);
// Iterate over the input instance data
Node nodeS;
Node nodeI;
boolean found = false;
while ((nodeS = iteratorS.nextNode()) != null) {
if (nodeS.getNodeName().compareTo(root) != 0) { // ignore root element
DocumentTraversal traversableI = (DocumentTraversal) instanceI;
NodeIterator iteratorI = traversableI.createNodeIterator(instanceI, NodeFilter.SHOW_ELEMENT, null, true);
// reset flag
if (found == true) {
found = false;
}
while (((nodeI = iteratorI.nextNode()) != null) && (found == false)) {
// if the nodeName for this instance node matches an elements attribute in the schema,
// overwrite the text value of that node with the text from this node
// then delete the node from the original instance so that it can't be copied again.
if (nodeI.getNodeName().compareTo(nodeS.getNodeName()) == 0) {