@Test public void testAppendZone() throws Exception { assertXpath("count(/Document/Page[1]/Zone[1]/ZoneCorners)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/Classification)", 1); assertXpathNoCase("string(/Document/Page[1]/Zone[1]/Classification/Category/@Value)", "Author"); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneID)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneInsets)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneInsets/@Left)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneInsets/@Right)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneInsets/@Top)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneInsets/@Bottom)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneNext)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/ZoneLines)", 1); assertXpath("count(/Document/Page[1]/Zone[1]/Line)", 1); assertXpathNoCase("string(/Document/Page[2]/Zone[1]/Classification/Category/@Value)", "abstract"); assertXpathNoCase("string(/Document/Page[2]/Zone[2]/Classification/Category/@Value)", "affiliation"); assertXpathNoCase("string(/Document/Page[2]/Zone[3]/Classification/Category/@Value)", "author"); assertXpathNoCase("string(/Document/Page[2]/Zone[4]/Classification/Category/@Value)", "body_content"); assertXpathNoCase("string(/Document/Page[2]/Zone[5]/Classification/Category/@Value)", "heading"); assertXpathNoCase("string(/Document/Page[2]/Zone[6]/Classification/Category/@Value)", "title"); assertXpathNoCase("string(/Document/Page[2]/Zone[7]/Classification/Category/@Value)", "unknown"); assertXpathNoCase("count(/Document/Page[2]/Zone[8]/Classification)", "0"); }
private void appendZone(Document doc, Element parent, BxZone zone, Object... hints) throws TransformationException { Element node = doc.createElement("Zone"); appendPropertyIfNotNull(doc, node, "ZoneID", zone.getId()); appendBounds(doc, node, "ZoneCorners", zone.getBounds(), hints); appendPropertyIfNotNull(doc, node, "ZoneNext", zone.getNextId()); Element insetsNode = doc.createElement("ZoneInsets"); insetsNode.setAttribute("Top", ""); insetsNode.setAttribute("Bottom", ""); insetsNode.setAttribute("Left", ""); insetsNode.setAttribute("Right", ""); node.appendChild(insetsNode); appendProperty(doc, node, "ZoneLines", ""); if (zone.getLabel() != null) { if (ZONE_LABEL_MAP.get(zone.getLabel()) != null && !ZONE_LABEL_MAP.get(zone.getLabel()).isEmpty()) { appendClassification(doc, node, ZONE_LABEL_MAP.get(zone.getLabel()).toUpperCase(Locale.ENGLISH), ""); } else { throw new TransformationException("Writing down an unknown zone label: " + zone.getLabel()); } } for (BxLine line : zone) { appendLine(doc, node, line, hints); } parent.appendChild(node); }
BxDocumentToTrueVizWriter { private void appendZone(Document doc, Element parent, BxZone zone, Object... hints) throws TransformationException { Element node = doc.createElement("Zone"); appendPropertyIfNotNull(doc, node, "ZoneID", zone.getId()); appendBounds(doc, node, "ZoneCorners", zone.getBounds(), hints); appendPropertyIfNotNull(doc, node, "ZoneNext", zone.getNextId()); Element insetsNode = doc.createElement("ZoneInsets"); insetsNode.setAttribute("Top", ""); insetsNode.setAttribute("Bottom", ""); insetsNode.setAttribute("Left", ""); insetsNode.setAttribute("Right", ""); node.appendChild(insetsNode); appendProperty(doc, node, "ZoneLines", ""); if (zone.getLabel() != null) { if (ZONE_LABEL_MAP.get(zone.getLabel()) != null && !ZONE_LABEL_MAP.get(zone.getLabel()).isEmpty()) { appendClassification(doc, node, ZONE_LABEL_MAP.get(zone.getLabel()).toUpperCase(Locale.ENGLISH), ""); } else { throw new TransformationException("Writing down an unknown zone label: " + zone.getLabel()); } } for (BxLine line : zone) { appendLine(doc, node, line, hints); } parent.appendChild(node); } }
BxDocumentToTrueVizWriter { private void appendZone(Document doc, Element parent, BxZone zone, Object... hints) throws TransformationException { Element node = doc.createElement("Zone"); appendPropertyIfNotNull(doc, node, "ZoneID", zone.getId()); appendBounds(doc, node, "ZoneCorners", zone.getBounds(), hints); appendPropertyIfNotNull(doc, node, "ZoneNext", zone.getNextId()); Element insetsNode = doc.createElement("ZoneInsets"); insetsNode.setAttribute("Top", ""); insetsNode.setAttribute("Bottom", ""); insetsNode.setAttribute("Left", ""); insetsNode.setAttribute("Right", ""); node.appendChild(insetsNode); appendProperty(doc, node, "ZoneLines", ""); if (zone.getLabel() != null) { if (ZONE_LABEL_MAP.get(zone.getLabel()) != null && !ZONE_LABEL_MAP.get(zone.getLabel()).isEmpty()) { appendClassification(doc, node, ZONE_LABEL_MAP.get(zone.getLabel()).toUpperCase(Locale.ENGLISH), ""); } else { throw new TransformationException("Writing down an unknown zone label: " + zone.getLabel()); } } for (BxLine line : zone) { appendLine(doc, node, line, hints); } parent.appendChild(node); }  }
BxDocumentToTrueVizWriter { private void appendZone(Document doc, Element parent, BxZone zone, Object... hints) throws TransformationException { Element node = doc.createElement("Zone"); appendPropertyIfNotNull(doc, node, "ZoneID", zone.getId()); appendBounds(doc, node, "ZoneCorners", zone.getBounds(), hints); appendPropertyIfNotNull(doc, node, "ZoneNext", zone.getNextId()); Element insetsNode = doc.createElement("ZoneInsets"); insetsNode.setAttribute("Top", ""); insetsNode.setAttribute("Bottom", ""); insetsNode.setAttribute("Left", ""); insetsNode.setAttribute("Right", ""); node.appendChild(insetsNode); appendProperty(doc, node, "ZoneLines", ""); if (zone.getLabel() != null) { if (ZONE_LABEL_MAP.get(zone.getLabel()) != null && !ZONE_LABEL_MAP.get(zone.getLabel()).isEmpty()) { appendClassification(doc, node, ZONE_LABEL_MAP.get(zone.getLabel()).toUpperCase(Locale.ENGLISH), ""); } else { throw new TransformationException("Writing down an unknown zone label: " + zone.getLabel()); } } for (BxLine line : zone) { appendLine(doc, node, line, hints); } parent.appendChild(node); }  String write(List<BxPage> objects, Object... hints); void write(Writer writer, List<BxPage> objects, Object... hints); }
BxDocumentToTrueVizWriter { private void appendZone(Document doc, Element parent, BxZone zone, Object... hints) throws TransformationException { Element node = doc.createElement("Zone"); appendPropertyIfNotNull(doc, node, "ZoneID", zone.getId()); appendBounds(doc, node, "ZoneCorners", zone.getBounds(), hints); appendPropertyIfNotNull(doc, node, "ZoneNext", zone.getNextId()); Element insetsNode = doc.createElement("ZoneInsets"); insetsNode.setAttribute("Top", ""); insetsNode.setAttribute("Bottom", ""); insetsNode.setAttribute("Left", ""); insetsNode.setAttribute("Right", ""); node.appendChild(insetsNode); appendProperty(doc, node, "ZoneLines", ""); if (zone.getLabel() != null) { if (ZONE_LABEL_MAP.get(zone.getLabel()) != null && !ZONE_LABEL_MAP.get(zone.getLabel()).isEmpty()) { appendClassification(doc, node, ZONE_LABEL_MAP.get(zone.getLabel()).toUpperCase(Locale.ENGLISH), ""); } else { throw new TransformationException("Writing down an unknown zone label: " + zone.getLabel()); } } for (BxLine line : zone) { appendLine(doc, node, line, hints); } parent.appendChild(node); }  String write(List<BxPage> objects, Object... hints); void write(Writer writer, List<BxPage> objects, Object... hints); static final String MINIMAL_OUTPUT_SIZE; static final Map<BxZoneLabel, String> ZONE_LABEL_MAP; }