private void generateCopies ( final Element topicref , final List < FilterUtils > filters ) { final List < FilterUtils > fs = combineFilterUtils ( topicref , filters ) ; final String copyTo = topicref . getAttribute ( BRANCH_COPY_TO ) ; if ( ! copyTo . isEmpty ( ) ) { final URI dstUri = map . resolve ( copyTo ) ; final URI dstAbsUri = job . tempDirURI . resolve ( dstUri ) ; final String href = topicref . getAttribute ( ATTRIBUTE_NAME_HREF ) ; final URI srcUri = map . resolve ( href ) ; final URI srcAbsUri = job . tempDirURI . resolve ( srcUri ) ; final FileInfo srcFileInfo = job . getFileInfo ( srcUri ) ; if ( srcFileInfo != null ) { // final FileInfo fi = new FileInfo.Builder(srcFileInfo).uri(dstUri).build(); // TODO: Maybe Job should be updated earlier? // job.add(fi); logger . info ( "Filtering " + srcAbsUri + " to " + dstAbsUri ) ; final ProfilingFilter writer = new ProfilingFilter ( ) ; writer . setLogger ( logger ) ; writer . setJob ( job ) ; writer . setFilterUtils ( fs ) ; writer . setCurrentFile ( dstAbsUri ) ; final List < XMLFilter > pipe = singletonList ( writer ) ; final File dstDirUri = new File ( dstAbsUri . resolve ( "." ) ) ; if ( ! dstDirUri . exists ( ) && ! dstDirUri . mkdirs ( ) ) { logger . error ( "Failed to create directory " + dstDirUri ) ; } try { xmlUtils . transform ( srcAbsUri , dstAbsUri , pipe ) ; } catch ( final DITAOTException e ) { logger . error ( "Failed to filter " + srcAbsUri + " to " + dstAbsUri + ": " + e . getMessage ( ) , e ) ; } topicref . setAttribute ( ATTRIBUTE_NAME_HREF , copyTo ) ; topicref . removeAttribute ( BRANCH_COPY_TO ) ; // disable filtering again topicref . setAttribute ( SKIP_FILTER , Boolean . TRUE . toString ( ) ) ; } } for ( final Element child : getChildElements ( topicref , MAP_TOPICREF ) ) { if ( DITAVAREF_D_DITAVALREF . matches ( child ) ) { continue ; } generateCopies ( child , fs ) ; } }
Copy and filter topics for branches . These topics have a new name and will be added to job configuration .