@Override protected void checkItem(OPFItem item, OPFHandler opfHandler) { String mimeType = item.getMimeType(); String fallback = item.getFallback(); if (mimeType == null || mimeType.equals("")) { // report.error(path, item.getLineNumber(), item.getColumnNumber(), // "empty media-type attribute"); return; } if (!mimeType.matches("[a-zA-Z0-9!#$&+-^_]+/[a-zA-Z0-9!#$&+-^_]+")) { // report.error(path, item.getLineNumber(), item.getColumnNumber(), // "invalid content for media-type attribute"); return; } if ("application/xhtml+xml".equals(mimeType) && !"xhtml".equals(Files.getFileExtension(item.getPath()))) { report.message( MessageId.HTM_014a, new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()), item.getPath()); } if (fallback != null) { OPFItem fallbackItem = opfHandler.getItemById(fallback); if (fallbackItem == null) { report.message( MessageId.OPF_040, new MessageLocation(path, item.getLineNumber(), item.getColumnNumber())); } } }
public void startElement() { super.startElement(); XMLElement e = parser.getCurrentElement(); String name = e.getName(); if (name.equals("package")) { HandlerUtil.processPrefixes( e.getAttribute("prefix"), prefixSet, report, path, parser.getLineNumber(), parser.getColumnNumber()); } else if (name.equals("meta")) { processMeta(e); } else if (name.equals("link")) { processLink(e); } else if (name.equals("item")) { processItemProperties(e.getAttribute("properties"), e.getAttribute("media-type")); } else if (name.equals("itemref")) { processItemrefProperties(e.getAttribute("properties")); } else if (name.equals("mediaType")) { processBinding(e); } }