private void parse(Document doc) { NodeList nodeList = doc.getChildNodes(); for (int count = 0; count < nodeList.getLength(); count++) { Node node = nodeList.item(count); if (node.getNodeType() == Node.ELEMENT_NODE && node.hasChildNodes()) { parseAttrList(node.getChildNodes()); } } }
private void writeDocument(Document document, Writer writer) throws IOException { String v = document.getXmlVersion(); writer.append("<?xml "); writer.append(" version='").append(v == null ? "1.0" : v).append("'"); writer.append(" encoding='").append(encoding.name()).append("'"); if (document.getXmlStandalone()) { writer.append(" standalone='yes'"); } writer.append("?>").append(lineSeparator); NodeList nodes = document.getChildNodes(); for (int i = 0, imax = nodes.getLength(); i < imax; ++i) { write(nodes.item(i), writer, 0); } }
public Object parse() throws XPathExpressionException, InstantiationException, IllegalAccessException, SecurityException, IllegalArgumentException, NoSuchMethodException, InvocationTargetException { Object result = null; NodeList nodes = m_document.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); if (item.getAttributes() != null) { String nodeName = item.getNodeName(); System.out.println("Node name:" + nodeName); Class<?> c = m_tagFactory.getClassForTag(nodeName); if (c == null) { throw new RuntimeException("No class found for tag " + nodeName); } result = c.newInstance(); populateAttributes(item, result); if (ITagSetter.class.isAssignableFrom(result.getClass())) { throw new RuntimeException("TAG SETTER"); } populateChildren(item, result); } } return result; }
public Object parse() throws InstantiationException, IllegalAccessException, SecurityException, IllegalArgumentException, InvocationTargetException { Object result = null; NodeList nodes = m_document.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); if (item.getAttributes() != null) { String nodeName = item.getNodeName(); System.out.println("Node name:" + nodeName); Class<?> c = m_tagFactory.getClassForTag(nodeName); if (c == null) { throw new RuntimeException("No class found for tag " + nodeName); } result = c.newInstance(); populateAttributes(item, result); if (ITagSetter.class.isAssignableFrom(result.getClass())) { throw new RuntimeException("TAG SETTER"); } populateChildren(item, result); } } return result; }
final NodeList tagList = doc.getChildNodes(); if (!tagList.item(0).getNodeName().equals(PROJECT_WHITELIST_TAG)) { throw new RuntimeException("Cannot find tag '" + PROJECT_WHITELIST_TAG + "' in " + xmlFile);
final NodeList tagList = doc.getChildNodes(); final Node azkabanUsers = tagList.item(0);
final NodeList tagList = doc.getChildNodes(); final Node azkabanValidators = tagList.item(0);
public void populate(final XmlSuite xmlSuite) throws XPathExpressionException { NodeList nodes = m_document.getChildNodes(); final Map<String, String> parameters = Maps.newHashMap(); for (int i = 0; i < nodes.getLength(); i++) {
public void populate(final XmlSuite xmlSuite) { NodeList nodes = m_document.getChildNodes(); final Map<String, String> parameters = Maps.newHashMap(); for (int i = 0; i < nodes.getLength(); i++) {
NodeList nl = orig.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i) instanceof DocumentType) {
removeEmptyNodes( data.targetDOM.getChildNodes() );
private String determineResourceName(Document theDocument) { Element root = null; NodeList list = theDocument.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { root = (Element) list.item(i); break; } } root = theDocument.getDocumentElement(); return root.getLocalName(); }
private String determineResourceName(Document theDocument) { NodeList list = theDocument.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { return list.item(i).getLocalName(); } } return theDocument.getDocumentElement().getLocalName(); }
private String determineResourceName(Document theDocument) { Element root = null; NodeList list = theDocument.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { root = (Element) list.item(i); break; } } root = theDocument.getDocumentElement(); return root.getLocalName(); }
private String determineResourceName(Document theDocument) { NodeList list = theDocument.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { return list.item(i).getLocalName(); } } return theDocument.getDocumentElement().getLocalName(); }
private ArrayList<String> determineIfProfilesSpecified(Document theDocument) { ArrayList<String> profileNames = new ArrayList<String>(); NodeList list = theDocument.getChildNodes().item(0).getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).getNodeName().compareToIgnoreCase("meta") == 0) { NodeList metaList = list.item(i).getChildNodes(); for (int j = 0; j < metaList.getLength(); j++) { if (metaList.item(j).getNodeName().compareToIgnoreCase("profile") == 0) { profileNames.add(metaList.item(j).getAttributes().item(0).getNodeValue()); } } break; } } return profileNames; }
private ArrayList<String> determineIfProfilesSpecified(Document theDocument) { ArrayList<String> profileNames = new ArrayList<String>(); NodeList list = theDocument.getChildNodes().item(0).getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).getNodeName().compareToIgnoreCase("meta") == 0) { NodeList metaList = list.item(i).getChildNodes(); for (int j = 0; j < metaList.getLength(); j++) { if (metaList.item(j).getNodeName().compareToIgnoreCase("profile") == 0) { profileNames.add(metaList.item(j).getAttributes().item(0).getNodeValue()); } } break; } } return profileNames; }
public Document read(org.w3c.dom.Document domDocument) { if (domDocument instanceof Document) { return (Document) domDocument; } Document document = createDocument(); clearNamespaceStack(); org.w3c.dom.NodeList nodeList = domDocument.getChildNodes(); for (int i = 0, size = nodeList.getLength(); i < size; i++) { readTree(nodeList.item(i), document); } return document; }
@Test public void testConvertSourceToDocument() { Node element = testDocument.getElementsByTagName("test").item(0); DOMSource domSource = new DOMSource(element); Document doc = converter.convertToDocument(domSource); NodeList childNodes = doc.getChildNodes(); assertThat(childNodes.getLength()).isEqualTo(1); assertThat(childNodes.item(0).getNodeName()).isEqualTo("test"); assertThat(childNodes.item(0).getTextContent()).isEqualTo("hello"); }
@Test public void testConvertNodeToDocument() { Node element = testDocument.getElementsByTagName("test").item(0); Document doc = converter.convertToDocument(element); NodeList childNodes = doc.getChildNodes(); assertThat(childNodes.getLength()).isEqualTo(1); assertThat(childNodes.item(0).getNodeName()).isEqualTo("test"); assertThat(childNodes.item(0).getTextContent()).isEqualTo("hello"); }