private void outputSubjectScheme ( ) throws DITAOTException { try { final Map < URI , Set < URI > > graph = SubjectSchemeReader . readMapFromXML ( new File ( job . tempDir , FILE_NAME_SUBJECT_RELATION ) ) ; final Queue < URI > queue = new LinkedList <> ( graph . keySet ( ) ) ; final Set < URI > visitedSet = new HashSet <> ( ) ; final DocumentBuilder builder = XMLUtils . getDocumentBuilder ( ) ; builder . setEntityResolver ( CatalogUtils . getCatalogResolver ( ) ) ; while ( ! queue . isEmpty ( ) ) { final URI parent = queue . poll ( ) ; final Set < URI > children = graph . get ( parent ) ; if ( children != null ) { queue . addAll ( children ) ; } if ( ROOT_URI . equals ( parent ) || visitedSet . contains ( parent ) ) { continue ; } visitedSet . add ( parent ) ; final File tmprel = new File ( FileUtils . resolve ( job . tempDir , parent ) + SUBJECT_SCHEME_EXTENSION ) ; final Document parentRoot ; if ( ! tmprel . exists ( ) ) { final URI src = job . getFileInfo ( parent ) . src ; parentRoot = builder . parse ( src . toString ( ) ) ; } else { parentRoot = builder . parse ( tmprel ) ; } if ( children != null ) { for ( final URI childpath : children ) { final Document childRoot = builder . parse ( job . getInputFile ( ) . resolve ( childpath . getPath ( ) ) . toString ( ) ) ; mergeScheme ( parentRoot , childRoot ) ; generateScheme ( new File ( job . tempDir , childpath . getPath ( ) + SUBJECT_SCHEME_EXTENSION ) , childRoot ) ; } } //Output parent scheme generateScheme ( new File ( job . tempDir , parent . getPath ( ) + SUBJECT_SCHEME_EXTENSION ) , parentRoot ) ; } } catch ( final RuntimeException e ) { throw e ; } catch ( final Exception e ) { logger . error ( e . getMessage ( ) , e ) ; throw new DITAOTException ( e ) ; } }
Output subject schema file .