private void checkItem ( Element root , Deque < Element > parents ) throws SAXException { Deque < Element > pending = new ArrayDeque < Element > ( ) ; Set < Element > memory = new HashSet < Element > ( ) ; memory . add ( root ) ; for ( Element child : root . children ) { pending . push ( child ) ; } if ( root . itemRef != null ) { for ( String id : root . itemRef ) { Element refElm = idmap . get ( id ) ; if ( refElm != null ) { pending . push ( refElm ) ; } else { err ( "The \u201Citemref\u201D attribute referenced \u201C" + id + "\u201D, but there is no element with an \u201Cid\u201D attribute with that value." , root . locator ) ; } } } boolean memoryError = false ; while ( pending . size ( ) > 0 ) { Element current = pending . pop ( ) ; if ( memory . contains ( current ) ) { memoryError = true ; continue ; } memory . add ( current ) ; if ( ! current . itemScope ) { for ( Element child : current . children ) { pending . push ( child ) ; } } if ( current . itemProp != null ) { properties . remove ( current ) ; if ( current . itemScope ) { if ( ! parents . contains ( current ) ) { parents . push ( root ) ; checkItem ( current , parents ) ; parents . pop ( ) ; } else { err ( "The \u201Citemref\u201D attribute created a circular reference with another item." , current . locator ) ; } } } } if ( memoryError ) { err ( "The \u201Citemref\u201D attribute contained redundant references." , root . locator ) ; } }
Check itemref constraints .