org.hl7.fhir.utilities.xhtml.XhtmlNode.getChildNodes()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(18.4k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.hl7.fhir.utilities.xhtml.XhtmlNode.getChildNodes()方法的一些代码示例,展示了XhtmlNode.getChildNodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XhtmlNode.getChildNodes()方法的具体详情如下:
包路径:org.hl7.fhir.utilities.xhtml.XhtmlNode
类名称:XhtmlNode
方法名:getChildNodes

XhtmlNode.getChildNodes介绍

暂无

代码示例

代码示例来源:origin: jamesagnew/hapi-fhir

public void compose(Element div, XhtmlNode x) {
 for (XhtmlNode child : x.getChildNodes()) {
  appendChild(div, child);
 }
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void writeDocument(String indent, XhtmlNode node) throws IOException  {
 indent = "";
 for (XhtmlNode c : node.getChildNodes())
  writeNode(indent, c, false);
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void processChildren(IXMLWriter xml, XhtmlNode x) throws IOException, FHIRException {
 for (XhtmlNode n : x.getChildNodes()) 
  processChildNode(xml, n);
}

代码示例来源:origin: jamesagnew/hapi-fhir

private List<Piece> htmlFormattingToPieces(String html) throws IOException, FHIRException {
 List<Piece> myPieces = new ArrayList<Piece>();
 if (html.contains(("<"))) {
  XhtmlNode node = new XhtmlParser().parseFragment("<p>"+html+"</p>");
  for (XhtmlNode c : node.getChildNodes()) {
   addNode(myPieces, c);
  }
 } else
  myPieces.add(new Piece(null, html, null));        
 return myPieces;
}
private void addNode(List<Piece> list, XhtmlNode c) {

代码示例来源:origin: jamesagnew/hapi-fhir

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;
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void appendChild(Element e, XhtmlNode node) {
 if (node.getNodeType() == NodeType.Comment)
  e.appendChild(e.getOwnerDocument().createComment(node.getContent()));
 else if (node.getNodeType() == NodeType.DocType)
  throw new Error("not done yet");
 else if (node.getNodeType() == NodeType.Instruction)
  e.appendChild(e.getOwnerDocument().createProcessingInstruction("", node.getContent()));
 else if (node.getNodeType() == NodeType.Text)
  e.appendChild(e.getOwnerDocument().createTextNode(node.getContent()));
 else if (node.getNodeType() == NodeType.Element) {
  Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName());
  e.appendChild(child);
  for (XhtmlNode c : node.getChildNodes()) {
   appendChild(child, c);
  }
 } else
  throw new Error("Unknown node type: "+node.getNodeType().toString());
}

代码示例来源:origin: jamesagnew/hapi-fhir

for (XhtmlNode n : x.getChildNodes()) {
 lastWS = composePlainText(n, b, lastWS);

代码示例来源:origin: jamesagnew/hapi-fhir

private void writeElement(String indent, XhtmlNode node, boolean noPrettyOverride) throws IOException  {
 if (!pretty || noPrettyOverride)
  indent = "";
 // html self closing tags: http://xahlee.info/js/html5_non-closing_tag.html 
 if (node.getChildNodes().size() == 0 && (xml || Utilities.existsInList(node.getName(), "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr")))
  dst.append(indent + "<" + node.getName() + attributes(node) + "/>" + (pretty && !noPrettyOverride ? "\r\n" : ""));
 else {
 boolean act = node.allChildrenAreText();
 if (act || !pretty ||  noPrettyOverride)
  dst.append(indent + "<" + node.getName() + attributes(node)+">");
 else
  dst.append(indent + "<" + node.getName() + attributes(node) + ">\r\n");
 if (node.getName() == "head" && node.getElement("meta") == null)
  dst.append(indent + "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + (pretty && !noPrettyOverride ? "\r\n" : ""));
 for (XhtmlNode c : node.getChildNodes())
  writeNode(indent + "  ", c, noPrettyOverride || node.isNoPretty());
 if (act)
  dst.append("</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : ""));
 else if (node.getChildNodes().get(node.getChildNodes().size() - 1).getNodeType() == NodeType.Text)
  dst.append((pretty && !noPrettyOverride ? "\r\n"+ indent : "")  + "</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : ""));
 else
  dst.append(indent + "</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : ""));
 }
}

代码示例来源:origin: jamesagnew/hapi-fhir

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());
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void checkInnerNS(List<ValidationMessage> errors, Element e, String path, List<XhtmlNode> list) {
 for (XhtmlNode node : list) {
  if (node.getNodeType() == NodeType.Element) {
   String ns = node.getNsDecl();
   rule(errors, IssueType.INVALID, e.line(), e.col(), path, ns == null || FormatUtilities.XHTML_NS.equals(ns), "Wrong namespace on the XHTML ('"+ns+"')");
   checkInnerNS(errors, e, path, node.getChildNodes());
  }
 }    
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void checkInnerNS(List<ValidationMessage> errors, Element e, String path, List<XhtmlNode> list) {
  for (XhtmlNode node : list) {
    if (node.getNodeType() == NodeType.Element) {
      String ns = node.getNsDecl();
      rule(errors, IssueType.INVALID, e.line(), e.col(), path, ns == null || FormatUtilities.XHTML_NS.equals(ns), "Wrong namespace on the XHTML ('"+ns+"')");
      checkInnerNS(errors, e, path, node.getChildNodes());
    }
  }    
}

代码示例来源:origin: jamesagnew/hapi-fhir

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;
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void checkInnerNS(List<ValidationMessage> errors, Element e, String path, List<XhtmlNode> list) {
 for (XhtmlNode node : list) {
  if (node.getNodeType() == NodeType.Element) {
   String ns = node.getNsDecl();
   rule(errors, IssueType.INVALID, e.line(), e.col(), path, ns == null || FormatUtilities.XHTML_NS.equals(ns), "Wrong namespace on the XHTML ('"+ns+"')");
   checkInnerNS(errors, e, path, node.getChildNodes());
  }
 }
}

代码示例来源:origin: jamesagnew/hapi-fhir

if (i == parents.size())
 parents.get(i - 1).getChildNodes().addAll(node.getChildNodes());
 node.getChildNodes().clear();
 parents.get(i - 1).getChildNodes().addAll(parents.get(i).getChildNodes());
 parents.get(i).getChildNodes().clear();

代码示例来源:origin: jamesagnew/hapi-fhir

Piece p = new Piece(c.getName()).setStyle("white-space: pre; font-family: courier");
 list.add(p);
 p.getChildren().addAll(c.getChildNodes());
} else if (c.getName().equals("ul") || c.getName().equals("ol")) {
 Piece p = new Piece(c.getName());
 list.add(p);
 p.getChildren().addAll(c.getChildNodes());
} else if (c.getName().equals("i")) {
 list.add(new Piece(null, c.allText(), null).setStyle("font-style: italic"));                    
 Piece p = new Piece(c.getName());
 list.add(p);
 p.getChildren().addAll(c.getChildNodes());
} else if (c.getName().equals("br")) {
 list.add(new Piece(c.getName()));

代码示例来源:origin: jamesagnew/hapi-fhir

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());
    }
  }    
}

代码示例来源:origin: jamesagnew/hapi-fhir

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());
  }
 }
}

代码示例来源:origin: jamesagnew/hapi-fhir

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());
  }
 }    
}

代码示例来源:origin: jamesagnew/hapi-fhir

rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.XHTML_NS.equals(ns), "Wrong namespace on the XHTML ('"+ns+"')");
checkInnerNS(errors, e, path, xhtml.getChildNodes());
rule(errors, IssueType.INVALID, e.line(), e.col(), path, "div".equals(xhtml.getName()), "Wrong name on the XHTML ('"+ns+"') - must start with div");
checkInnerNames(errors, e, path, xhtml.getChildNodes());

代码示例来源:origin: jamesagnew/hapi-fhir

rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.XHTML_NS.equals(ns), "Wrong namespace on the XHTML ('"+ns+"')");
checkInnerNS(errors, e, path, xhtml.getChildNodes());
rule(errors, IssueType.INVALID, e.line(), e.col(), path, "div".equals(xhtml.getName()), "Wrong name on the XHTML ('"+ns+"') - must start with div");
checkInnerNames(errors, e, path, xhtml.getChildNodes());

相关文章