public XhtmlNode addInstruction(String content) { if (!(nodeType == NodeType.Document)) throw new Error("Wrong node type"); XhtmlNode node = new XhtmlNode(NodeType.Instruction); node.setContent(content); childNodes.add(node); return node; }
public XhtmlNode addComment(String content) { if (!(nodeType == NodeType.Element || nodeType == NodeType.Document)) throw new Error("Wrong node type"); XhtmlNode node = new XhtmlNode(NodeType.Comment); node.setContent(content); childNodes.add(node); return node; }
public XhtmlNode copy() { XhtmlNode dst = new XhtmlNode(nodeType); dst.name = name; for (String n : attributes.keySet()) { dst.attributes.put(n, attributes.get(n)); } for (XhtmlNode n : childNodes) dst.childNodes.add(n.copy()); dst.content = content; return dst; }
public XhtmlNode addText(String content) { if (!(nodeType == NodeType.Element || nodeType == NodeType.Document)) throw new Error("Wrong node type"); if (content != null) { XhtmlNode node = new XhtmlNode(NodeType.Text); node.setContent(content); childNodes.add(node); return node; } else return null; }
public XhtmlNode addText(int index, String content) { if (!(nodeType == NodeType.Element || nodeType == NodeType.Document)) throw new Error("Wrong node type"); if (content == null) throw new Error("Content cannot be null"); XhtmlNode node = new XhtmlNode(NodeType.Text); node.setContent(content); childNodes.add(index, node); return node; }
public XhtmlNode addDocType(String content) { if (!(nodeType == NodeType.Document)) throw new Error("Wrong node type"); XhtmlNode node = new XhtmlNode(NodeType.DocType); node.setContent(content); childNodes.add(node); return node; }
public XhtmlNode getValue() { return place == null ? new XhtmlNode(NodeType.Element, "div") : place.getDiv(); }
public XhtmlNode addTag(String name) { if (!(nodeType == NodeType.Element || nodeType == NodeType.Document)) throw new Error("Wrong node type. is "+nodeType.toString()); XhtmlNode node = new XhtmlNode(NodeType.Element); node.setName(name); childNodes.add(node); return node; }
public XhtmlNode addTag(int index, String name) { if (!(nodeType == NodeType.Element || nodeType == NodeType.Document)) throw new Error("Wrong node type. is "+nodeType.toString()); XhtmlNode node = new XhtmlNode(NodeType.Element); node.setName(name); childNodes.add(index, node); return node; }
/** * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.) */ public XhtmlNode getDiv() { if (this.div == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create Narrative.div"); else if (Configuration.doAutoCreate()) this.div = new XhtmlNode(); // cc return this.div; }
/** * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.) */ public XhtmlNode getDiv() { if (this.div == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create Narrative.div"); else if (Configuration.doAutoCreate()) this.div = new XhtmlNode(); // cc return this.div; }
/** * @return {@link #div} (The actual narrative content, a stripped down version of XHTML.) */ public XhtmlNode getDiv() { if (this.div == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create Narrative.div"); else if (Configuration.doAutoCreate()) this.div = new XhtmlNode(); // cc return this.div; }
/** * Sets the value of * * @param theString * @throws Exception */ public void setDivAsString(String theString) { XhtmlNode div; if (StringUtils.isNotBlank(theString)) { div = new XhtmlNode(); div.setValueAsString(theString); } else { div = null; } setDiv(div); }
/** * Sets the value of * * @param theString * @throws Exception */ public void setDivAsString(String theString) { XhtmlNode div; if (StringUtils.isNotBlank(theString)) { div = new XhtmlNode(NodeType.Element, "div"); div.setValueAsString(theString); } else { div = null; } setDiv(div); }
/** * Sets the value of * * @param theString * @throws Exception */ public void setDivAsString(String theString) { XhtmlNode div; if (StringUtils.isNotBlank(theString)) { div = new XhtmlNode(); div.setValueAsString(theString); } else { div = null; } setDiv(div); }
/** * for a CDA narrative, return the matching XHTML. * * For further information, see http://wiki.hl7.org/index.php?title=CDA_Narrative_to_html_mapping * * @param ed * @return * @throws FHIRException */ public XhtmlNode convert(Element ed) throws FHIRException { XhtmlNode div = new XhtmlNode(NodeType.Element, "div"); processAttributes(ed, div, "ID", "language", "styleCode"); processChildren(ed, div); return div; }
private XhtmlNode parseNode(Element node, String defaultNS) throws FHIRFormatError { XhtmlNode res = new XhtmlNode(NodeType.Element); res.setName(node.getLocalName()); defaultNS = checkNS(res, node, defaultNS); for (int i = 0; i < node.getAttributes().getLength(); i++) { Attr attr = (Attr) node.getAttributes().item(i); if (attributeIsOk(res.getName(), attr.getName(), attr.getValue()) && !attr.getLocalName().startsWith("xmlns")) res.getAttributes().put(attr.getName(), attr.getValue()); } Node child = node.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.TEXT_NODE) { res.addText(child.getTextContent()); } else if (child.getNodeType() == Node.COMMENT_NODE) { res.addComment(child.getTextContent()); } else if (child.getNodeType() == Node.ELEMENT_NODE) { if (elementIsOk(child.getLocalName())) res.getChildNodes().add(parseNode((Element) child, defaultNS)); } else throw new FHIRFormatError("Unhandled XHTML feature: "+Integer.toString(child.getNodeType())+descLoc()); child = child.getNextSibling(); } return res; }
private XhtmlNode parseNode(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError { XhtmlNode res = new XhtmlNode(NodeType.Element); res.setName(xpp.getName()); for (int i = 0; i < xpp.getAttributeCount(); i++) { if (attributeIsOk(xpp.getName(), xpp.getAttributeName(i), xpp.getAttributeValue(i))) res.getAttributes().put(xpp.getAttributeName(i), xpp.getAttributeValue(i)); } int eventType = xpp.next(); while (eventType != XmlPullParser.END_TAG) { if (eventType == XmlPullParser.TEXT) { res.addText(xpp.getText()); xpp.next(); } else if (eventType == XmlPullParser.COMMENT) { res.addComment(xpp.getText()); xpp.next(); } else if (eventType == XmlPullParser.START_TAG) { if (elementIsOk(xpp.getName())) res.getChildNodes().add(parseNode(xpp)); } else throw new FHIRFormatError("Unhandled XHTML feature: "+Integer.toString(eventType)+descLoc()); eventType = xpp.getEventType(); } xpp.next(); return res; }
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case -892481550: return getStatusElement(); case 99473: /*div*/ if (div == null) div = new XhtmlNode(NodeType.Element, "div"); return new StringType(new org.hl7.fhir.utilities.xhtml.XhtmlComposer(true).composeEx(this.div)); default: return super.makeProperty(hash, name); } }
private XhtmlNode parseFragment() throws IOException, FHIRException { skipWhiteSpace(); if (peekChar() != '<') throw new FHIRException("Unable to Parse HTML - does not start with tag. Found "+peekChar()+descLoc()); readChar(); if (peekChar() == '?') { readToTagEnd(); skipWhiteSpace(); if (peekChar() != '<') throw new FHIRException("Unable to Parse HTML - does not start with tag after processing instruction. Found "+peekChar()+descLoc()); readChar(); } String n = readName().toLowerCase(); readToTagEnd(); XhtmlNode result = new XhtmlNode(NodeType.Element); int colonIndex = n.indexOf(':'); if (colonIndex != -1) { n = n.substring(colonIndex + 1); } result.setName(n); unwindPoint = null; List<XhtmlNode> p = new ArrayList<XhtmlNode>(); parseElementInner(result, p, null, true); return result; }