private static void writeGuideReference(GuideReference reference, XmlSerializer serializer) throws IOException { if (reference != null) { serializer.startTag(NAMESPACE_OPF, OPFElements.REFERENCE); serializer.attribute(PREFIX_EMPTY, OPFAttributes.TYPE, reference.getType()); serializer.attribute(PREFIX_EMPTY, OPFAttributes.HREF, reference.getCompleteHref()); if (StringUtil.isNotBlank(reference.getTitle())) { serializer.attribute(PREFIX_EMPTY, OPFAttributes.TITLE, reference.getTitle()); } serializer.endTag(NAMESPACE_OPF, OPFElements.REFERENCE); } }
/** * Write a resource as an item element. * * @param serializer the XML serialiser to write the item element to * @param book the book to write the resource for * @param resource the resource to write as an item element * @throws IOException if an I/O error occurs */ private static void writeItem( final XmlSerializer serializer, final Book book, final Resource resource) throws IOException { if (!isValidResource(book, resource)) { return; } serializer.startTag(NAMESPACE_OPF, OPFElements.ITEM); serializer.attribute(PREFIX_EMPTY, OPFAttributes.ID, resource.getId()); serializer.attribute(PREFIX_EMPTY, OPFAttributes.HREF, resource.getHref()); serializer.attribute(PREFIX_EMPTY, OPFAttributes.MEDIA_TYPE, resource.getMediaType().getName()); if (StringUtil.isNotBlank(resource.getProperties())) { serializer.attribute(PREFIX_EMPTY, OPFAttributes.PROPERTIES, resource.getProperties()); } serializer.endTag(NAMESPACE_OPF, OPFElements.ITEM); }