Java Code Examples for org.w3c.dom.Node#toString()
The following examples show how to use
org.w3c.dom.Node#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: W3CDomHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 2
Source File: W3CDomHandler.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 3
Source File: W3CDomHandler.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 4
Source File: W3CDomHandler.java From JDKSourceCode1.8 with MIT License | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 5
Source File: W3CDomHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 6
Source File: W3CDomHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 7
Source File: W3CDomHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 8
Source File: W3CDomHandler.java From Java8CN with Apache License 2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 9
Source File: W3CDomHandler.java From hottub with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 10
Source File: W3CDomHandler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 11
Source File: W3CDomHandler.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public Element getElement(DOMResult r) { // JAXP spec is ambiguous about what really happens in this case, // so work defensively Node n = r.getNode(); if( n instanceof Document ) { return ((Document)n).getDocumentElement(); } if( n instanceof Element ) return (Element)n; if( n instanceof DocumentFragment ) return (Element)n.getChildNodes().item(0); // if the result object contains something strange, // it is not a user problem, but it is a JAXB provider's problem. // That's why we throw a runtime exception. throw new IllegalStateException(n.toString()); }
Example 12
Source File: XMLUtil.java From OpenAs2App with BSD 2-Clause "Simplified" License | 5 votes |
public static Map<String, String> mapAttributeNodes(NodeList nodes, String nodeName, String nodeKeyName, String nodeValueName) throws OpenAS2Exception { Map<String, String> attributes = new HashMap<String, String>(); int nodeCount = nodes.getLength(); Node attrNode; NamedNodeMap nodeAttributes; Node tmpNode; String attrName; String attrValue; for (int i = 0; i < nodeCount; i++) { attrNode = nodes.item(i); if (attrNode.getNodeName().equals(nodeName)) { nodeAttributes = attrNode.getAttributes(); tmpNode = nodeAttributes.getNamedItem(nodeKeyName); if (tmpNode == null) { throw new OpenAS2Exception(attrNode.toString() + " does not have key attribute: " + nodeKeyName); } attrName = tmpNode.getNodeValue(); tmpNode = nodeAttributes.getNamedItem(nodeValueName); if (tmpNode == null) { throw new OpenAS2Exception(attrNode.toString() + " does not have value attribute: " + nodeValueName); } attrValue = tmpNode.getNodeValue(); attributes.put(attrName, attrValue); } } return attributes; }
Example 13
Source File: XMLUtil.java From OpenAs2App with BSD 2-Clause "Simplified" License | 5 votes |
public static Map<String, String> mapAttributes(Node node, String[] requiredAttributes) throws OpenAS2Exception { Map<String, String> attributes = mapAttributes(node); String attrName; for (String requiredAttribute : requiredAttributes) { attrName = requiredAttribute; if (attributes.get(attrName) == null) { throw new OpenAS2Exception(node.toString() + " is missing required attribute: " + attrName); } } return attributes; }
Example 14
Source File: XmlUtils.java From cs-actions with Apache License 2.0 | 5 votes |
public static String nodeToString(Node node) throws TransformerException { if (node == null) { return EMPTY; } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { return node.toString(); } else { return transformElementNode(node); } }
Example 15
Source File: MiniAapt.java From buck with Apache License 2.0 | 5 votes |
private Node verifyNodeHasTypeAttribute(Path valuesFile, Node node) throws ResourceParseException { Node typeNode = node.getAttributes().getNamedItem("type"); if (typeNode == null || typeNode.getNodeValue().isEmpty()) { throw new ResourceParseException( "Error parsing file '%s', expected a 'type' attribute in: \n'%s'\n", valuesFile, node.toString()); } return typeNode; }
Example 16
Source File: LoggingPSValidationHandler.java From ph-schematron with Apache License 2.0 | 4 votes |
@Nonnull public static String getAsString (@Nonnull final Node aNode) { return XMLDebug.getNodeTypeAsString (aNode.getNodeType ()) + ": " + aNode.toString (); }