List of usage examples for org.w3c.dom NamedNodeMap getLength
public int getLength();
From source file:spec.schema.SchemaCurrent_TO_2008_02_Test.java
/** * Checks if the <code>Image</code> tag was correctly transformed. * /* w w w .j av a 2 s . com*/ * @param destNode The node from the transformed file. * @param srcNode The Image node from the source file */ private void checkBinDataNode(Node destNode, Node srcNode) { assertNotNull(destNode); assertNotNull(srcNode); // store the values for Compression attribute on the input node NamedNodeMap attributesSrc = srcNode.getAttributes(); String compression = ""; Node n; String name; for (int i = 0; i < attributesSrc.getLength(); i++) { n = attributesSrc.item(i); name = n.getNodeName(); if (name.equals(XMLWriter.COMPRESSION_ATTRIBUTE)) compression = n.getNodeValue(); } // compare the stored value for the Compression attribute // to that on the output node NamedNodeMap attributes = destNode.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { n = attributes.item(i); if (n != null) { name = n.getNodeName(); if (name.equals(XMLWriter.COMPRESSION_ATTRIBUTE)) { assertEquals(n.getNodeValue(), compression); } } } // compare the contents of the BinData node assertEquals(destNode.getTextContent(), srcNode.getTextContent()); }
From source file:net.sf.jclal.experiment.ExperimentBuilder.java
private int expandElementsIterateAttributes(Element element) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node attribute = attributes.item(i); if (attribute.getNodeName().equals("multi")) { combinationBase.add(element.getElementsByTagName(element.getNodeName()).getLength()); return 1; }//from ww w .j av a 2 s . co m } return 0; }
From source file:net.sf.jclal.experiment.ExperimentBuilder.java
private int expandAttributesIterateAttributes(Element element) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node attribute = attributes.item(i); if (attribute.getNodeValue().equals("multi")) { combinationBase.add(element.getElementsByTagName(attribute.getNodeName()).getLength()); return 1; }/*from ww w .j a va2 s. c o m*/ } return 0; }
From source file:com.evolveum.midpoint.util.DOMUtil.java
private static void showDomNode(Node node, StringBuilder sb, int level) { if (sb == null) { // buffer not provided, return immediately return;// w ww .j av a 2 s. co m } // indent for (int i = 0; i < level; i++) { sb.append(" "); } if (node == null) { sb.append("null\n"); } else { sb.append(node.getNodeName()); sb.append(" ("); NamedNodeMap attributes = node.getAttributes(); boolean broken = false; if (attributes != null) { for (int ii = 0; ii < attributes.getLength(); ii++) { Node attribute = attributes.item(ii); sb.append(attribute.getPrefix()); sb.append(":"); sb.append(attribute.getLocalName()); sb.append("='"); sb.append(attribute.getNodeValue()); sb.append("',"); if (attribute.getPrefix() == null && attribute.getLocalName().equals("xmlns") && (attribute.getNodeValue() == null || attribute.getNodeValue().isEmpty())) { broken = true; } } } sb.append(")"); if (broken) { sb.append(" *** WARNING: empty default namespace"); } sb.append("\n"); NodeList childNodes = node.getChildNodes(); for (int ii = 0; ii < childNodes.getLength(); ii++) { Node subnode = childNodes.item(ii); showDomNode(subnode, sb, level + 1); } } }
From source file:net.sf.jclal.experiment.ExperimentBuilder.java
private int expandAttributesIterateAtributes(Element element, int[] configurationSchema) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node attribute = attributes.item(i); if (attribute.getNodeValue().equals("multi")) { NodeList list = element.getElementsByTagName(attribute.getNodeName()); for (int j = 0; j < configurationSchema.length; j++) { if (configurationSchema[j] != -1) { attribute.setNodeValue(list.item(configurationSchema[j]).getFirstChild().getNodeValue()); configurationSchema[j] = -1; break; }//from w w w. j a v a2s. co m } list = element.getChildNodes(); for (int j = 0; j < list.getLength(); j++) { if (list.item(j).getNodeName().equals(attribute.getNodeName())) { element.removeChild(list.item(j)); } } return 1; } } return 0; }
From source file:com.amalto.workbench.widgets.SchematronExpressBuilder.java
private void parseFunxml() throws Exception { InputStream in = null;//from w ww .j a v a 2 s . com try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); org.w3c.dom.Document document; if (isSchematron) { in = SchematronExpressBuilder.class.getResourceAsStream("XPathFunc.xml");//$NON-NLS-1$ } else { in = SchematronExpressBuilder.class.getResourceAsStream("StandardXPathFunc.xml");//$NON-NLS-1$ } document = builder.parse(in); NodeList list = document.getElementsByTagName("category");//$NON-NLS-1$ categories = new ArrayList<XPathFunc>(); for (int i = 0; i < list.getLength(); i++) { XPathFunc xpathFunc = new XPathFunc(); Node node = list.item(i);// get the number i node NamedNodeMap map = node.getAttributes(); Node nameNode = map.getNamedItem("name");//$NON-NLS-1$ xpathFunc.setCategory(nameNode.getTextContent()); java.util.List<KeyValue> keylist = new ArrayList<KeyValue>(); for (int j = 0; j < node.getChildNodes().getLength(); j++) { Node n = node.getChildNodes().item(j); NamedNodeMap fmap = n.getAttributes(); if (fmap != null && fmap.getLength() > 0) { Node n1 = fmap.getNamedItem("name");//$NON-NLS-1$ Node n2 = fmap.getNamedItem("help");//$NON-NLS-1$ String help = n2.getTextContent(); help = help.replaceAll("\\n", "\n");//$NON-NLS-1$//$NON-NLS-2$ KeyValue kv = new KeyValue(n1.getTextContent(), help); keylist.add(kv); } } Collections.sort(keylist, new Comparator<KeyValue>() { public int compare(KeyValue o1, KeyValue o2) { if (o1 != null && o2 != null) { return o1.key.compareTo(o2.key); } return 0; } }); xpathFunc.setFuncs(keylist); categories.add(xpathFunc); } } finally { if (in != null) { in.close(); } } }
From source file:net.sf.jclal.experiment.ExperimentBuilder.java
private int expandElementsIterateAtributes(Element element, int[] configurationSchema) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node attribute = attributes.item(i); if (attribute.getNodeName().equals("multi")) { NodeList list = element.getElementsByTagName(element.getNodeName()); for (int j = 0; j < configurationSchema.length; j++) { if (configurationSchema[j] != -1) { element.getParentNode().replaceChild(list.item(configurationSchema[j]), element); configurationSchema[j] = -1; break; }/* w w w .ja v a 2 s. c o m*/ } list = element.getChildNodes(); for (int j = 0; j < list.getLength(); j++) { if (list.item(j).getNodeName().equals(attribute.getNodeName())) { element.removeChild(list.item(j)); } } return 1; } } return 0; }
From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAXMapping.java
public static SRelationSourceTypeMatchCondition parseSRelationSourceTypeMatchCondition(Node node) { NamedNodeMap attributes = node.getAttributes(); Node sourceTypeAttributeNode = attributes.getNamedItem(SREL_SOURCE_TYPE_REGEXP); String sourceTypeRegExp = null; if (sourceTypeAttributeNode != null) { sourceTypeRegExp = sourceTypeAttributeNode.getNodeValue(); attributes.removeNamedItem(SREL_SOURCE_TYPE_REGEXP); } else {/* www . java2s . c om*/ throw new PepperModuleException("'" + SREL_SOURCE_TYPE_REGEXP + " attribute not found on SRelation SourceType Match Condition '" + node + "'"); } if (attributes.getLength() != 0) { throw new PepperModuleException( "Additional unexpected attributes found on SRelation SourceType Match Condition '" + node + "'"); } return new SRelationSourceTypeMatchCondition(Pattern.compile(sourceTypeRegExp)); }
From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAXMapping.java
public static SRelationTargetTypeMatchCondition parseSRelationTargetTypeMatchCondition(Node node) { NamedNodeMap attributes = node.getAttributes(); Node targetTypeAttributeNode = attributes.getNamedItem(SREL_TARGET_TYPE_REGEXP); String targetTypeRegExp = null; if (targetTypeAttributeNode != null) { targetTypeRegExp = targetTypeAttributeNode.getNodeValue(); attributes.removeNamedItem(SREL_TARGET_TYPE_REGEXP); } else {// w ww . j ava 2 s . c om throw new PepperModuleException("'" + SREL_TARGET_TYPE_REGEXP + " attribute not found on SRelation TargetType Match Condition '" + node + "'"); } if (attributes.getLength() != 0) { throw new PepperModuleException( "Additional unexpected attributes found on SRelation TargetType Match Condition '" + node + "'"); } return new SRelationTargetTypeMatchCondition(Pattern.compile(targetTypeRegExp)); }
From source file:com.qcadoo.view.internal.xml.ViewDefinitionParserImpl.java
@Override public ComponentOption parseOption(final Node optionNode) { Map<String, String> attributes = new HashMap<String, String>(); NamedNodeMap attributesNodes = optionNode.getAttributes(); for (int i = 0; i < attributesNodes.getLength(); i++) { attributes.put(attributesNodes.item(i).getNodeName(), attributesNodes.item(i).getNodeValue()); }//from w w w . j a v a 2s .co m String type = getStringAttribute(optionNode, "type"); if (type == null) { type = getStringAttribute(optionNode, "xsi:type"); } return new ComponentOption(type, attributes); }