@Override public boolean startElementHandler(String tag, ZLStringMap xmlattributes, String[] tagStack) { tag = tag.toLowerCase(); if (myOPFSchemePrefix != null && tag.startsWith(myOPFSchemePrefix)) { tag = tag.substring(myOPFSchemePrefix.length()); } tag = tag.intern(); if (MANIFEST == tag) { myState = READ_MANIFEST; } else if (SPINE == tag) { myNCXTOCFileName = myIdToHref.get(xmlattributes.getValue("toc")); myState = READ_SPINE; } else if (GUIDE == tag) { myState = READ_GUIDE; } else if (TOUR == tag) { myState = READ_TOUR; } else if (myState == READ_MANIFEST && ITEM == tag) { final String id = xmlattributes.getValue("id"); String href = xmlattributes.getValue("href"); if ((id != null) && (href != null)) { href = MiscUtil.decodeHtmlReference(href); myIdToHref.put(id, href); } } else if (myState == READ_SPINE && ITEMREF == tag) { final String id = xmlattributes.getValue("idref"); if (id != null) { final String fileName = myIdToHref.get(id); if (fileName != null) { myHtmlFileNames.add(fileName); } } } else if (myState == READ_GUIDE && REFERENCE == tag) { final String type = xmlattributes.getValue("type"); final String title = xmlattributes.getValue("title"); String href = xmlattributes.getValue("href"); if (href != null) { href = MiscUtil.decodeHtmlReference(href); if (title != null) { myGuideTOC.add(new Reference(title, href)); } if (COVER.equals(type)) { final ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href); myCoverFileName = imageFile.getPath(); final String imageName = imageFile.getLongName(); final ZLFileImage image = XHTMLImageFinder.getCoverImage(imageFile); if (image != null) { myModelReader.setMainTextModel(); myModelReader.addImageReference(imageName, (short) 0, true); myModelReader.addImage(imageName, image); myModelReader.insertEndOfSectionParagraph(); } } else if (COVER_IMAGE.equals(type)) { final ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href); myCoverFileName = imageFile.getPath(); final String imageName = imageFile.getLongName(); myModelReader.setMainTextModel(); myModelReader.addImageReference(imageName, (short) 0, true); myModelReader.addImage(imageName, new ZLFileImage(MimeType.IMAGE_AUTO, imageFile)); myModelReader.insertEndOfSectionParagraph(); } } } else if (myState == READ_TOUR && SITE == tag) { final String title = xmlattributes.getValue("title"); String href = xmlattributes.getValue("href"); if ((title != null) && (href != null)) { href = MiscUtil.decodeHtmlReference(href); myTourTOC.add(new Reference(title, href)); } } return false; }