Class EpubStep
- java.lang.Object
-
- com.xmlmind.w2x.processor.ProcessStep
-
- com.xmlmind.w2x.processor.SplitStep
-
- com.xmlmind.w2x.processor.EpubStep
-
public class EpubStep extends SplitStep
This processing step is used to convert input XHTML+CSS document (typically created using aConvertStep) or input semantic XHTML document (typically created using aEditSteprunning "w2x:xed/main.xed") to an EPUB 2 file.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. Default outline level is 0.The save file of the EPUB document is specified by parameter
step_name.out-file.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.xmlmind.w2x.processor.SplitStep
SplitStep.Part
-
-
Field Summary
Fields Modifier and Type Field Description protected static NameCASE_NAMEprotected static NameCONTENT_NAMEprotected static StringCOVER_HTMLprotected static NamespaceDC_NSprotected static NamespaceDCTERMS_NSprotected static NameDEFAULT_NAMEprotected static NameDOC_TITLE_NAMEprotected static NameGUIDE_NAMEprotected static NameHEAD_NAMEprotected static NameIDREF_NAMEprotected static NameITEM_NAMEprotected static NameITEMREF_NAMEprotected static NameLINEAR_NAMEprotected static NameMANIFEST_NAMEprotected static NameMEDIA_TYPE_NAMEprotected static NameMETA_NAMEprotected static NameMETADATA_NAMEprotected static NameNAV_LABEL_NAMEprotected static NameNAV_MAP_NAMEprotected static NameNAV_POINT_NAMEprotected static NameNCX_NAMEprotected static NamespaceNCX_NSprotected static PrefixEntry[]NCX_PREFIX_ENTRIESprotected static NameOPF_META_NAMEprotected static NamespaceOPF_NSprotected static PrefixEntry[]OPF_PREFIX_ENTRIESprotected static NamespaceOPS_NSprotected static NamePACKAGE_NAMEprotected static NamePLAY_ORDER_NAMEprotected static NameREFERENCE_NAMEprotected static NameREQUIRED_NAMESPACE_NAMEprotected static NameSPINE_NAMEprotected static NameSWITCH_NAMEprotected static NameTEXT_NAMEprotected static NameTOC_NAMEprotected static NameUNIQUE_IDENTIFIER_NAMEprotected static NameVERSION_NAME-
Fields inherited from class com.xmlmind.w2x.processor.SplitStep
COLS_ATTR, FRAME_ELEM, FRAMESET_ELEM, SCROLLING_ATTR, TOC_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 voidaddItems(File dir, int urlPrefixLength, Map<File,String> fileToId, Element manifest)protected voidaddMeta(Document xhtmlDoc, Element metadata)protected voidcreateEpub(File tempDir, File outFile, ProgressMonitor monitor)protected FiledoProcess(Document xhtmlDoc, File tempFile, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor)protected StringmediaType(String ext)protected static ElementnewItem(String id, String href, String mediaType)protected static ElementnewItemref(String id)protected static ElementnewMeta(String name, String content)protected static ElementnewSimpleElement(Namespace ns, String localPart, String text)protected static ElementnewText(String textContent)voidprocess(Object[] state, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor)Execute this processing step.protected voidsaveContent(List<SplitStep.Part> parts, String coverName, String coverImageName, String epubIdent, String defaultLang, Document xhtmlDoc, File file, ProgressMonitor monitor)protected StringsaveCover(URL imageURL, File file, ProgressMonitor monitor)protected voidsaveDocument(Document doc, boolean indent, String encoding, File file, ProgressMonitor monitor)protected voidsaveTOC(List<SplitStep.Part> parts, String epubIdent, boolean omitTOCRoot, File file, ProgressMonitor monitor)protected DocumenttoContent(List<SplitStep.Part> parts, String coverName, String coverImageName, String epubIdent, String defaultLang, Document xhtmlDoc, File tempDir)protected DocumenttoTOC(List<SplitStep.Part> parts, String epubIdent, boolean omitTOCRoot)protected static voidzipEpub(File srcDir, File zipFile)-
Methods inherited from class com.xmlmind.w2x.processor.SplitStep
addPart, collectCounters, collectIds, collectNotes, copyNotes, copyNotes2, createCharsetMeta, createFrameset, createPartTemplate, createTOCStyle, creatingFile, deleteNotes, findById, findCharset, findCharsetMeta, findNotes, findParentPart, findTitle, fixLinks, getAllText, getBoxFirstChildElement, getOutlineLevel, isNote, isNoteRef, isNoteSeparator, newOutFile, newOutFile, parseCounterPI, parseCounterReset, processCounters, processLinks, processNotes, processNotes2, processParts, resetCounters, saveParts, setNotes, splitDocument, toTOC, useSameChunk
-
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
-
OPS_NS
protected static final Namespace OPS_NS
-
SWITCH_NAME
protected static final Name SWITCH_NAME
-
CASE_NAME
protected static final Name CASE_NAME
-
DEFAULT_NAME
protected static final Name DEFAULT_NAME
-
REQUIRED_NAMESPACE_NAME
protected static final Name REQUIRED_NAMESPACE_NAME
-
NCX_NS
protected static final Namespace NCX_NS
-
NCX_PREFIX_ENTRIES
protected static final PrefixEntry[] NCX_PREFIX_ENTRIES
-
NCX_NAME
protected static final Name NCX_NAME
-
HEAD_NAME
protected static final Name HEAD_NAME
-
META_NAME
protected static final Name META_NAME
-
DOC_TITLE_NAME
protected static final Name DOC_TITLE_NAME
-
TEXT_NAME
protected static final Name TEXT_NAME
-
NAV_MAP_NAME
protected static final Name NAV_MAP_NAME
-
NAV_POINT_NAME
protected static final Name NAV_POINT_NAME
-
NAV_LABEL_NAME
protected static final Name NAV_LABEL_NAME
-
CONTENT_NAME
protected static final Name CONTENT_NAME
-
VERSION_NAME
protected static final Name VERSION_NAME
-
PLAY_ORDER_NAME
protected static final Name PLAY_ORDER_NAME
-
OPF_NS
protected static final Namespace OPF_NS
-
DC_NS
protected static final Namespace DC_NS
-
DCTERMS_NS
protected static final Namespace DCTERMS_NS
-
OPF_PREFIX_ENTRIES
protected static final PrefixEntry[] OPF_PREFIX_ENTRIES
-
PACKAGE_NAME
protected static final Name PACKAGE_NAME
-
METADATA_NAME
protected static final Name METADATA_NAME
-
OPF_META_NAME
protected static final Name OPF_META_NAME
-
MANIFEST_NAME
protected static final Name MANIFEST_NAME
-
ITEM_NAME
protected static final Name ITEM_NAME
-
SPINE_NAME
protected static final Name SPINE_NAME
-
ITEMREF_NAME
protected static final Name ITEMREF_NAME
-
GUIDE_NAME
protected static final Name GUIDE_NAME
-
REFERENCE_NAME
protected static final Name REFERENCE_NAME
-
UNIQUE_IDENTIFIER_NAME
protected static final Name UNIQUE_IDENTIFIER_NAME
-
MEDIA_TYPE_NAME
protected static final Name MEDIA_TYPE_NAME
-
TOC_NAME
protected static final Name TOC_NAME
-
IDREF_NAME
protected static final Name IDREF_NAME
-
LINEAR_NAME
protected static final Name LINEAR_NAME
-
COVER_HTML
protected static final String COVER_HTML
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EpubStep
public EpubStep(String stepName)
Constructs a EpubStep having specified name.
-
-
Method Detail
-
process
public void process(Object[] state, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor) throws Exception
Description copied from class:SplitStepExecute 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.
- Overrides:
processin classSplitStep- 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
-
doProcess
protected File doProcess(Document xhtmlDoc, File tempFile, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor) throws Exception
- Throws:
Exception
-
saveDocument
protected void saveDocument(Document doc, boolean indent, String encoding, File file, ProgressMonitor monitor) throws CanceledException, IOException
- Overrides:
saveDocumentin classSplitStep- Throws:
CanceledExceptionIOException
-
saveTOC
protected void saveTOC(List<SplitStep.Part> parts, String epubIdent, boolean omitTOCRoot, File file, ProgressMonitor monitor) throws CanceledException, IOException
- Throws:
CanceledExceptionIOException
-
toTOC
protected Document toTOC(List<SplitStep.Part> parts, String epubIdent, boolean omitTOCRoot)
-
saveCover
protected String saveCover(URL imageURL, File file, ProgressMonitor monitor) throws CanceledException, IOException
- Throws:
CanceledExceptionIOException
-
saveContent
protected void saveContent(List<SplitStep.Part> parts, String coverName, String coverImageName, String epubIdent, String defaultLang, Document xhtmlDoc, File file, ProgressMonitor monitor) throws CanceledException, IOException
- Throws:
CanceledExceptionIOException
-
toContent
protected Document toContent(List<SplitStep.Part> parts, String coverName, String coverImageName, String epubIdent, String defaultLang, Document xhtmlDoc, File tempDir) throws IOException
- Throws:
IOException
-
newSimpleElement
protected static final Element newSimpleElement(Namespace ns, String localPart, String text)
-
addItems
protected void addItems(File dir, int urlPrefixLength, Map<File,String> fileToId, Element manifest) throws IOException
- Throws:
IOException
-
createEpub
protected void createEpub(File tempDir, File outFile, ProgressMonitor monitor) throws CanceledException, IOException
- Throws:
CanceledExceptionIOException
-
zipEpub
protected static final void zipEpub(File srcDir, File zipFile) throws IOException
- Throws:
IOException
-
-