public String getAttribute(String name) { return getAttributes().get(name); }
public XhtmlNode setAttribute(String name, String value) { getAttributes().put(name, value); return this; }
public boolean hasAttribute(String name) { return getAttributes().containsKey(name); }
private String checkNS(XhtmlNode res, Element node, String defaultNS) { if (!validatorMode) return null; String ns = node.getNamespaceURI(); if (ns == null) return null; if (!ns.equals(defaultNS)) { res.getAttributes().put("xmlns", ns); return ns; } return defaultNS; }
private String attributes(XhtmlNode node) { StringBuilder s = new StringBuilder(); for (String n : node.getAttributes().keySet()) s.append(" " + n + "=\"" + escapeHtml(node.getAttributes().get(n)) + "\""); return s.toString(); }
public XhtmlNode parseHtmlNode(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError { XhtmlNode res = parseNode(xpp); if (res.getNsDecl() == null) res.getAttributes().put("xmlns", XHTML_NS); return res; } private XhtmlNode parseNode(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError {
public XhtmlNode parseHtmlNode(Element node, String defaultNS) throws FHIRFormatError { XhtmlNode res = parseNode(node, defaultNS); if (res.getNsDecl() == null) res.getAttributes().put("xmlns", XHTML_NS); return res; }
private void composeElement(IXMLWriter xml, XhtmlNode node, boolean noPrettyOverride) throws IOException { for (String n : node.getAttributes().keySet()) { if (n.equals("xmlns")) xml.setDefaultNamespace(node.getAttributes().get(n)); else if (n.startsWith("xmlns:")) xml.namespace(n.substring(6), node.getAttributes().get(n)); else xml.attribute(n, node.getAttributes().get(n)); } xml.enter(XHTML_NS, node.getName()); for (XhtmlNode n : node.getChildNodes()) compose(xml, n, noPrettyOverride || node.isNoPretty()); xml.exit(XHTML_NS, node.getName()); }
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; }
NSMap result = new NSMap(nsm); List<String> nsattrs = new ArrayList<String>(); for (String an : node.getAttributes().keySet()) { if (an.equals("xmlns")) { result.def(node.getAttribute(an)); node.getAttributes().remove(s); if (n.hasNs()) { String nns = result.get(n.getNs()); if (!nns.equals(result.def())) { node.getAttributes().put("xmlns", nns); result.def(nns); node.getAttributes().put("xmlns", result.def());
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; }
node.getAttributes().put(name, null); else if (peekChar() != '=') readChar(); if (peekChar() == '"' || peekChar() == '\'') node.getAttributes().put(name, parseAttributeValue(readChar())); else node.getAttributes().put(name, parseAttributeValue('\0'));
private void checkInnerNames(List<ValidationMessage> errors, Element e, String path, List<XhtmlNode> list) { for (XhtmlNode node : list) { if (node.getNodeType() == NodeType.Element) { rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.existsInList(node.getName(), "p", "br", "div", "h1", "h2", "h3", "h4", "h5", "h6", "a", "span", "b", "em", "i", "strong", "small", "big", "tt", "small", "dfn", "q", "var", "abbr", "acronym", "cite", "blockquote", "hr", "address", "bdo", "kbd", "q", "sub", "sup", "ul", "ol", "li", "dl", "dt", "dd", "pre", "table", "caption", "colgroup", "col", "thead", "tr", "tfoot", "tbody", "th", "td", "code", "samp", "img", "map", "area" ), "Illegal element name in the XHTML ('"+node.getName()+"')"); for (String an : node.getAttributes().keySet()) { boolean ok = an.startsWith("xmlns") || Utilities.existsInList(an, "title", "style", "class", "id", "lang", "xml:lang", "dir", "accesskey", "tabindex", // tables "span", "width", "align", "valign", "char", "charoff", "abbr", "axis", "headers", "scope", "rowspan", "colspan") || Utilities.existsInList(node.getName()+"."+an, "a.href", "a.name", "img.src", "img.border", "div.xmlns", "blockquote.cite", "q.cite", "a.charset", "a.type", "a.name", "a.href", "a.hreflang", "a.rel", "a.rev", "a.shape", "a.coords", "img.src", "img.alt", "img.longdesc", "img.height", "img.width", "img.usemap", "img.ismap", "map.name", "area.shape", "area.coords", "area.href", "area.nohref", "area.alt", "table.summary", "table.width", "table.border", "table.frame", "table.rules", "table.cellspacing", "table.cellpadding", "pre.space" ); if (!ok) rule(errors, IssueType.INVALID, e.line(), e.col(), path, false, "Illegal attribute name in the XHTML ('"+an+"' on '"+node.getName()+"')"); } checkInnerNames(errors, e, path, node.getChildNodes()); } } }
private void checkInnerNames(List<ValidationMessage> errors, Element e, String path, List<XhtmlNode> list) { for (XhtmlNode node : list) { if (node.getNodeType() == NodeType.Element) { rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.existsInList(node.getName(), "p", "br", "div", "h1", "h2", "h3", "h4", "h5", "h6", "a", "span", "b", "em", "i", "strong", "small", "big", "tt", "small", "dfn", "q", "var", "abbr", "acronym", "cite", "blockquote", "hr", "address", "bdo", "kbd", "q", "sub", "sup", "ul", "ol", "li", "dl", "dt", "dd", "pre", "table", "caption", "colgroup", "col", "thead", "tr", "tfoot", "tbody", "th", "td", "code", "samp", "img", "map", "area" ), "Illegal element name in the XHTML ('"+node.getName()+"')"); for (String an : node.getAttributes().keySet()) { boolean ok = an.startsWith("xmlns") || Utilities.existsInList(an, "title", "style", "class", "id", "lang", "xml:lang", "dir", "accesskey", "tabindex", // tables "span", "width", "align", "valign", "char", "charoff", "abbr", "axis", "headers", "scope", "rowspan", "colspan") || Utilities.existsInList(node.getName()+"."+an, "a.href", "a.name", "img.src", "img.border", "div.xmlns", "blockquote.cite", "q.cite", "a.charset", "a.type", "a.name", "a.href", "a.hreflang", "a.rel", "a.rev", "a.shape", "a.coords", "img.src", "img.alt", "img.longdesc", "img.height", "img.width", "img.usemap", "img.ismap", "map.name", "area.shape", "area.coords", "area.href", "area.nohref", "area.alt", "table.summary", "table.width", "table.border", "table.frame", "table.rules", "table.cellspacing", "table.cellpadding", "pre.space" ); if (!ok) rule(errors, IssueType.INVALID, e.line(), e.col(), path, false, "Illegal attribute name in the XHTML ('"+an+"' on '"+node.getName()+"')"); } checkInnerNames(errors, e, path, node.getChildNodes()); } } }
private void checkInnerNames(List<ValidationMessage> errors, Element e, String path, List<XhtmlNode> list) { for (XhtmlNode node : list) { if (node.getNodeType() == NodeType.Element) { rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.existsInList(node.getName(), "p", "br", "div", "h1", "h2", "h3", "h4", "h5", "h6", "a", "span", "b", "em", "i", "strong", "small", "big", "tt", "small", "dfn", "q", "var", "abbr", "acronym", "cite", "blockquote", "hr", "address", "bdo", "kbd", "q", "sub", "sup", "ul", "ol", "li", "dl", "dt", "dd", "pre", "table", "caption", "colgroup", "col", "thead", "tr", "tfoot", "tbody", "th", "td", "code", "samp", "img", "map", "area" ), "Illegal element name in the XHTML ('"+node.getName()+"')"); for (String an : node.getAttributes().keySet()) { boolean ok = an.startsWith("xmlns") || Utilities.existsInList(an, "title", "style", "class", "id", "lang", "xml:lang", "dir", "accesskey", "tabindex", // tables "span", "width", "align", "valign", "char", "charoff", "abbr", "axis", "headers", "scope", "rowspan", "colspan") || Utilities.existsInList(node.getName()+"."+an, "a.href", "a.name", "img.src", "img.border", "div.xmlns", "blockquote.cite", "q.cite", "a.charset", "a.type", "a.name", "a.href", "a.hreflang", "a.rel", "a.rev", "a.shape", "a.coords", "img.src", "img.alt", "img.longdesc", "img.height", "img.width", "img.usemap", "img.ismap", "map.name", "area.shape", "area.coords", "area.href", "area.nohref", "area.alt", "table.summary", "table.width", "table.border", "table.frame", "table.rules", "table.cellspacing", "table.cellpadding", "pre.space", "td.nowrap" ); if (!ok) rule(errors, IssueType.INVALID, e.line(), e.col(), path, false, "Illegal attribute name in the XHTML ('"+an+"' on '"+node.getName()+"')"); } checkInnerNames(errors, e, path, node.getChildNodes()); } } }
public XhtmlNode setAttribute(String name, String value) { getAttributes().put(name, value); return this; }
private String checkNS(XhtmlNode res, Element node, String defaultNS) { if (!validatorMode) return null; String ns = node.getNamespaceURI(); if (ns == null) return null; if (!ns.equals(defaultNS)) { res.getAttributes().put("xmlns", ns); return ns; } return defaultNS; }
private String attributes(XhtmlNode node) { StringBuilder s = new StringBuilder(); for (String n : node.getAttributes().keySet()) s.append(" " + n + "=\"" + escapeHtml(node.getAttributes().get(n)) + "\""); return s.toString(); }
public XhtmlNode parseHtmlNode(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError { XhtmlNode res = parseNode(xpp); if (res.getNsDecl() == null) res.getAttributes().put("xmlns", XHTML_NS); return res; } private XhtmlNode parseNode(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError {
public XhtmlNode parseHtmlNode(Element node, String defaultNS) throws FHIRFormatError { XhtmlNode res = parseNode(node, defaultNS); if (res.getNsDecl() == null) res.getAttributes().put("xmlns", XHTML_NS); return res; }