Class SplitStep
- java.lang.Object
-
- com.xmlmind.w2x.processor.ProcessStep
-
- com.xmlmind.w2x.processor.SplitStep
-
- Direct Known Subclasses:
EpubStep,WebHelpStep
public class SplitStep extends ProcessStep
This processing step is used to split input XHTML+CSS document (typically created using aConvertStep) or input semantic XHTML document (typically created using aEditSteprunning "w2x:xed/main.xed") into several parts and to save to disk the corresponding frameset.The outline level used to split the input XHTML+CSS document is specified by parameter
step_name.split-before-level. This outline level is an integer between 0 and 8 inclusive.For an input semantic XHTML document, this outline level is an integer between 0 (
h1) and 5 (h6) inclusive.Default outline level is 0.
The save file of the frameset is specified by parameter
step_name.out-file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSplitStep.Part
-
Field Summary
Fields Modifier and Type Field Description protected static NameCOLS_ATTRprotected static NameFRAME_ELEMprotected static NameFRAMESET_ELEMprotected static NameSCROLLING_ATTRprotected static StringTOC_CSS-
Fields inherited from class com.xmlmind.w2x.processor.ProcessStep
stepName
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SplitStep.PartaddPart(int level, int splitBeforeLevel, Set<String> idUsedAsFilename, boolean allowLonelyHeading, Element p, Element dstBody, File outFile, Document partTemplate, List<SplitStep.Part> parts)protected static voidcollectCounters(Element tree, Map<String,Integer> counterMap, Map<String,Integer> resetCounterMap)protected static voidcollectIds(Element tree, String docHref, Map<String,String[]> idMap)protected voidcollectNotes(Element tree, Map<String,Element> idToNote)protected voidcopyNotes(String role, Element tree, Element srcNotes, Element dstNotes)protected voidcopyNotes2(Element tree, Map<String,Element> idToNote, int[] noteCount, Element dstBody)protected static ElementcreateCharsetMeta(String charset)protected DocumentcreateFrameset(Document xhtmlDoc, String charset, String tocHref, String contentHref)protected DocumentcreatePartTemplate(Document xhtmlDoc)protected ElementcreateTOCStyle(List<SplitStep.Part> parts)protected static voidcreatingFile(File file, ProgressMonitor monitor)protected voiddeleteNotes(Element tree)protected static ElementfindById(Element tree, String id)protected static StringfindCharset(Document doc)protected static ElementfindCharsetMeta(Element head, String[] foundCharset)protected static ElementfindNotes(String role, Element body)protected static SplitStep.PartfindParentPart(List<SplitStep.Part> parts)protected static ElementfindTitle(Document doc)protected static voidfixLinks(Element tree, String docHref, Map<String,String[]> idMap)protected static StringgetAllText(Element tree, boolean collapseWhiteSpace)protected static ElementgetBoxFirstChildElement(Element element)protected static intgetOutlineLevel(Element element)protected static booleanisNote(Element element)protected static booleanisNoteRef(Element element)protected static booleanisNoteSeparator(Element element)protected FilenewOutFile(File file, int partNum)protected static FilenewOutFile(File file, String suffix)protected static Object[]parseCounterPI(Element p, ProcessingInstruction[] counterPI)protected static voidparseCounterReset(String prop, Map<String,Integer> counterMap)voidprocess(Object[] state, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor)Execute this processing step.protected voidprocessCounters(List<SplitStep.Part> parts)protected voidprocessLinks(List<SplitStep.Part> parts)protected voidprocessNotes(List<SplitStep.Part> parts, Document htmlDoc)protected voidprocessNotes2(Element srcBody, List<SplitStep.Part> parts, Document htmlDoc)protected voidprocessParts(List<SplitStep.Part> parts, Document htmlDoc)protected static StringresetCounters(Map<String,Integer> counterMap, Map<String,Integer> resetCounterMap)protected voidsaveDocument(Document doc, boolean indent, String encoding, File file, ProgressMonitor monitor)protected voidsaveParts(List<SplitStep.Part> parts, boolean indent, String encoding, File outFile, ProgressMonitor monitor)protected static voidsetNotes(String role, Element newNotes, Element body)protected voidsplitDocument(Document xhtmlDoc, int splitBeforeLevel, Set<String> idUsedAsFilename, boolean allowLonelyHeading, File outFile, List<SplitStep.Part> parts, ProgressMonitor monitor)protected DocumenttoTOC(List<SplitStep.Part> parts, String charset)protected booleanuseSameChunk(boolean allowLonelyHeading, Element dstBody)-
Methods inherited from class com.xmlmind.w2x.processor.ProcessStep
debugParameters, equals, getAllParameters, getBooleanParameter, getFileParameter, getIntParameter, getParameter, getURLParameter, hashCode, illegalState, joinAllParameters, missingParameter, parameterName, progress, toString, urlOrFile
-
-
-
-
Field Detail
-
FRAMESET_ELEM
protected static final Name FRAMESET_ELEM
-
FRAME_ELEM
protected static final Name FRAME_ELEM
-
COLS_ATTR
protected static final Name COLS_ATTR
-
SCROLLING_ATTR
protected static final Name SCROLLING_ATTR
-
TOC_CSS
protected static final String TOC_CSS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SplitStep
public SplitStep(String stepName)
Constructs a SplitStep having specified name.
-
-
Method Detail
-
process
public void process(Object[] state, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor) throws Exception
Execute this processing step.state[0]contains:- Before this method is executed: an XHTML+CSS document
(typically created using a
ConvertStep). - After this method is executed: the save file containing the frameset.
- Specified by:
processin classProcessStep- Parameters:
state- contains the current state of processing: aDocumentor aFile.This object is used as the input of this step and thus, is processed by this step.
After its execution, this method generally updates the
statearray with a newDocumentorFileto pass the result/output of this step to the next step.parameters- all the parameters passed to theProcessorowning and thus executing this process step.Parameters which are relevant to this processing step are prefixed with "
".ProcessStep.stepName.stepCounter- contains the rank of previously executed processing step. Must be incremented by this method.monitor- used to monitor the progress of the processing stepsInvoking convenience method
ProcessStep.progress(java.lang.String, int[], com.xmlmind.util.ProgressMonitor)suffices to make good use of bothmonitorandstepCounter.- Throws:
Exception- if for any reason, this method fails
- Before this method is executed: an XHTML+CSS document
(typically created using a
-
findCharsetMeta
protected static final Element findCharsetMeta(Element head, String[] foundCharset)
-
splitDocument
protected void splitDocument(Document xhtmlDoc, int splitBeforeLevel, Set<String> idUsedAsFilename, boolean allowLonelyHeading, File outFile, List<SplitStep.Part> parts, ProgressMonitor monitor) throws Exception
- Throws:
Exception
-
getOutlineLevel
protected static final int getOutlineLevel(Element element)
-
createPartTemplate
protected Document createPartTemplate(Document xhtmlDoc) throws Exception
- Throws:
Exception
-
addPart
protected SplitStep.Part addPart(int level, int splitBeforeLevel, Set<String> idUsedAsFilename, boolean allowLonelyHeading, Element p, Element dstBody, File outFile, Document partTemplate, List<SplitStep.Part> parts)
-
parseCounterPI
protected static final Object[] parseCounterPI(Element p, ProcessingInstruction[] counterPI)
-
findParentPart
protected static final SplitStep.Part findParentPart(List<SplitStep.Part> parts)
-
useSameChunk
protected boolean useSameChunk(boolean allowLonelyHeading, Element dstBody)
-
processParts
protected void processParts(List<SplitStep.Part> parts, Document htmlDoc)
-
processCounters
protected void processCounters(List<SplitStep.Part> parts)
-
parseCounterReset
protected static final void parseCounterReset(String prop, Map<String,Integer> counterMap)
-
collectCounters
protected static final void collectCounters(Element tree, Map<String,Integer> counterMap, Map<String,Integer> resetCounterMap)
-
resetCounters
protected static final String resetCounters(Map<String,Integer> counterMap, Map<String,Integer> resetCounterMap)
-
processNotes
protected void processNotes(List<SplitStep.Part> parts, Document htmlDoc)
-
processNotes2
protected void processNotes2(Element srcBody, List<SplitStep.Part> parts, Document htmlDoc)
-
deleteNotes
protected void deleteNotes(Element tree)
-
isNote
protected static final boolean isNote(Element element)
-
isNoteSeparator
protected static final boolean isNoteSeparator(Element element)
-
copyNotes2
protected void copyNotes2(Element tree, Map<String,Element> idToNote, int[] noteCount, Element dstBody)
-
isNoteRef
protected static final boolean isNoteRef(Element element)
-
processLinks
protected void processLinks(List<SplitStep.Part> parts)
-
collectIds
protected static final void collectIds(Element tree, String docHref, Map<String,String[]> idMap)
-
fixLinks
protected static final void fixLinks(Element tree, String docHref, Map<String,String[]> idMap)
-
saveParts
protected void saveParts(List<SplitStep.Part> parts, boolean indent, String encoding, File outFile, ProgressMonitor monitor) throws Exception
- Throws:
Exception
-
saveDocument
protected void saveDocument(Document doc, boolean indent, String encoding, File file, ProgressMonitor monitor) throws CanceledException, IOException
- Throws:
CanceledExceptionIOException
-
creatingFile
protected static final void creatingFile(File file, ProgressMonitor monitor) throws CanceledException, IOException
- Throws:
CanceledExceptionIOException
-
toTOC
protected Document toTOC(List<SplitStep.Part> parts, String charset)
-
createTOCStyle
protected Element createTOCStyle(List<SplitStep.Part> parts)
-
createFrameset
protected Document createFrameset(Document xhtmlDoc, String charset, String tocHref, String contentHref)
-
-