Buggy code:
public class Test implements DOMErrorHandler , LSResourceResolver { static int errorCounter = 0 ; static DOMErrorHandler errorHandler = new Test ( ) ; static LSResourceResolver resolver = new Test ( ) ; public static void main ( String [ ] argv ) { try { boolean namespaces = true ; System . out . println ( "Running<seq2seq4repair_space>dom.dom3.Test..." ) ; <START_BUG> System . setProperty ( PROPERTY , "org.apache.xerces.dom.DOMImplementationSourceImpl" ) ; <END_BUG> DOMImplementationLS impl = ( ( DOMImplementationLS ) ( DOMImplementationRegistry . newInstance ( ) . getDOMImplementation ( "LS" ) ) ) ; Assertion . verify ( ( impl != null ) , "domImplementation<seq2seq4repair_space>!=<seq2seq4repair_space>null" ) ; LSParser builder = impl . createLSParser ( DOMImplementationLS . MODE_SYNCHRONOUS , null ) ; LSSerializer writer = impl . createLSSerializer ( ) ; DOMConfiguration config = writer . getConfig ( ) ; config . setParameter ( "namespaces" , ( namespaces ? Boolean . TRUE : Boolean . FALSE ) ) ; config . setParameter ( "validate" , Boolean . FALSE ) ; { Document doc = builder . parseURI ( "tests//dom//dom3//input.xml" ) ; NodeList ls = doc . getElementsByTagName ( "a:elem_a" ) ; NodeImpl elem = ( ( NodeImpl ) ( ls . item ( 0 ) ) ) ; if ( namespaces ) { Assertion . verify ( elem . lookupPrefix ( "http:////www.example.com" ) . equals ( "ns1" ) , "[a:elem_a].lookupPrefix(http:////www.example.com)==null" ) ; Assertion . verify ( ( ( elem . isDefaultNamespace ( "http:////www.example.com" ) ) == true ) , "[a:elem_a].isDefaultNamespace(http:////www.example.com)==true" ) ; Assertion . verify ( elem . lookupPrefix ( "http:////www.example.com" ) . equals ( "ns1" ) , "[a:elem_a].lookupPrefix(http:////www.example.com)==ns1" ) ; Assertion . verify ( elem . lookupNamespaceURI ( "xsi" ) . equals ( "http:////www.w3.org//2001//XMLSchema-instance" ) , "[a:elem_a].lookupNamespaceURI('xsi')<seq2seq4repair_space>==<seq2seq4repair_space>'http:////www.w3.org//2001//XMLSchema-instance'" ) ; } else { Assertion . verify ( ( ( elem . lookupPrefix ( "http:////www.example.com" ) ) == null ) , "lookupPrefix(http:////www.example.com)==null" ) ; } ls = doc . getElementsByTagName ( "bar:leaf" ) ; elem = ( ( NodeImpl ) ( ls . item ( 0 ) ) ) ; Assertion . verify ( elem . lookupPrefix ( "url1:" ) . equals ( "foo" ) , "[bar:leaf].lookupPrefix('url1:',<seq2seq4repair_space>false)<seq2seq4repair_space>==<seq2seq4repair_space>foo" ) ; ls = doc . getElementsByTagName ( "baz" ) ; elem = ( ( NodeImpl ) ( ls . item ( 0 ) ) ) ; ls = doc . getElementsByTagName ( "elem8" ) ; elem = ( ( NodeImpl ) ( ls . item ( 0 ) ) ) ; Element e1 = doc . createElementNS ( "b:" , "p:baz" ) ; e1 . setAttributeNS ( "http:////www.w3.org//2000//xmlns//" , "xmlns:x" , "b:" ) ; elem . appendChild ( e1 ) ; Assertion . verify ( ( ( NodeImpl ) ( e1 ) ) . lookupPrefix ( "b:" ) . equals ( "p" ) , "[p:baz].lookupPrefix('b:',<seq2seq4repair_space>false)<seq2seq4repair_space>==<seq2seq4repair_space>p" ) ; Assertion . verify ( elem . lookupNamespaceURI ( "xsi" ) . equals ( "http:////www.w3.org//2001//XMLSchema-instance" ) , "[bar:leaf].lookupNamespaceURI('xsi')<seq2seq4repair_space>==<seq2seq4repair_space>'http:////www.w3.org//2001//XMLSchema-instance'" ) ; } { Test . errorCounter = 0 ; config = builder . getConfig ( ) ; config . setParameter ( "error-handler" , Test . errorHandler ) ; config . setParameter ( "validate" , Boolean . TRUE ) ; DocumentImpl core = ( ( DocumentImpl ) ( builder . parseURI ( "tests//dom//dom3//schema.xml" ) ) ) ; Assertion . verify ( ( ( Test . errorCounter ) == 0 ) , "No<seq2seq4repair_space>errors<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>reported" ) ; Test . errorCounter = 0 ; NodeList ls2 = core . getElementsByTagName ( "decVal" ) ; Element testElem = ( ( Element ) ( ls2 . item ( 0 ) ) ) ; testElem . removeAttributeNS ( "http:////www.w3.org//2000//xmlns//" , "xmlns" ) ; ls2 = core . getElementsByTagName ( "v02:decVal" ) ; testElem = ( ( Element ) ( ls2 . item ( 0 ) ) ) ; testElem . setPrefix ( "myPrefix" ) ; Element root = core . getDocumentElement ( ) ; Element newElem = core . createElementNS ( null , "decVal" ) ; String data = "4.5" ; if ( true ) { data = "string" ; } newElem . appendChild ( core . createTextNode ( data ) ) ; root . insertBefore ( newElem , testElem ) ; newElem = core . createElementNS ( null , "notInSchema" ) ; newElem . appendChild ( core . createTextNode ( "added<seq2seq4repair_space>new<seq2seq4repair_space>element" ) ) ; root . insertBefore ( newElem , testElem ) ; root . appendChild ( core . createElementNS ( "UndefinedNamespace" , "NS1:foo" ) ) ; config = core . getDomConfig ( ) ; config . setParameter ( "error-handler" , Test . errorHandler ) ; config . setParameter ( "validate" , Boolean . TRUE ) ; core . normalizeDocument ( ) ; Assertion . verify ( ( ( Test . errorCounter ) == 3 ) , "3<seq2seq4repair_space>errors<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>reported" ) ; Test . errorCounter = 0 ; config . setParameter ( "validate" , Boolean . FALSE ) ; config . setParameter ( "comments" , Boolean . FALSE ) ; core . normalizeDocument ( ) ; Assertion . verify ( ( ( Test . errorCounter ) == 0 ) , "No<seq2seq4repair_space>errors<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>reported" ) ; config = builder . getConfig ( ) ; config . setParameter ( "validate" , Boolean . FALSE ) ; } { Test . errorCounter = 0 ; config = builder . getConfig ( ) ; config . setParameter ( "error-handler" , Test . errorHandler ) ; config . setParameter ( "validate" , Boolean . TRUE ) ; config . setParameter ( "psvi" , Boolean . TRUE ) ; DocumentImpl core = ( ( DocumentImpl ) ( builder . parseURI ( "data//personal-schema.xml" ) ) ) ; Assertion . verify ( ( ( Test . errorCounter ) == 0 ) , "No<seq2seq4repair_space>errors<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>reported" ) ; NodeList ls2 = core . getElementsByTagName ( "person" ) ; Element testElem = ( ( Element ) ( ls2 . item ( 0 ) ) ) ; Assertion . verify ( ( ( org . apache . xerces . xs . ElementPSVI ) ( testElem ) ) . getElementDeclaration ( ) . getName ( ) . equals ( "person" ) , "testElem<seq2seq4repair_space>decl" ) ;

Fix:
System . setProperty ( PROPERTY , "org.apache.xerces.dom.DOMImplementationSourceImpl<seq2seq4repair_space>org.apache.xerces.dom.DOMXSImplementationSourceImpl" ) ;