public static boolean isElement (Node n) { return n == null ? false : isElementType (n.getType ()); }
public static boolean isAttribute (Node n) { return n == null ? false : isAttributeType (n.getType ()); }
public static boolean isText (Node n) { return n == null ? false : isTextType (n.getType ()); }
public DocTypeAttributeList toXML (XMLWriter writer) throws IOException { writer.write (this, "<!ATTLIST"); if (!Character.isWhitespace (elementName.charAt (0))) writer.write (this, " "); writer.write (this, elementName); boolean needsWhitespace = true; if (Character.isWhitespace (elementName.charAt (elementName.length () - 1))) needsWhitespace = false; if (needsWhitespace && !nodes.isEmpty ()) { Node n = nodes.get (0); if (n.getType () == Type.DTD_WHITESPACE) needsWhitespace = false; } if (needsWhitespace) writer.write (this, " "); for (Node n: nodes) n.toXML (writer); writer.write (this, ">"); return this; }
public String getText () { if (!hasNodes ()) return ""; StringBuilder buffer = new StringBuilder (); for (Node n: getNodes ()) { if (isText (n)) buffer.append (((Text)n).getText ()); else if (isElement (n)) buffer.append (((Element)n).getText ()); else if (n.getType () == Type.ENTITY) buffer.append (((Entity)n).getText ()); } return buffer.toString (); }
throw new XMLParseException ("It is not allowed to have content before the XML declaration", this, xmlDeclaration); switch (node.getType ()) //@COBEX throw new XMLParseException (node.getType ()+" node is not allowed here", ((BasicNode)node).getToken ()); throw new XMLParseException (node.getType ()+" node is not allowed here", this, sibling); if (node.getType () == Type.PROCESSING_INSTRUCTION)
if (n.getType () != Type.PROCESSING_INSTRUCTION || n == xmlDeclaration) return;