List of usage examples for org.w3c.dom NamedNodeMap removeNamedItem
public Node removeNamedItem(String name) throws DOMException;
From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAXMapping.java
public static SRelationSLayerMatchCondition parseSRelationSLayerMatchCondition(Node node) { NamedNodeMap attributes = node.getAttributes(); Node slayerAttributeNode = attributes.getNamedItem(SREL_SLAYER_REGEXP); String slayerRegExp = null;//from ww w. ja v a 2 s. com if (slayerAttributeNode != null) { slayerRegExp = slayerAttributeNode.getNodeValue(); attributes.removeNamedItem(SREL_SLAYER_REGEXP); } else { throw new PepperModuleException("'" + SREL_SLAYER_REGEXP + " attribute not found on SRelation SLayer Match Condition '" + node + "'"); } if (attributes.getLength() != 0) { throw new PepperModuleException( "Additional unexpected attributes found on SRelation SLayer Match Condition '" + node + "'"); } return new SRelationSLayerMatchCondition(Pattern.compile(slayerRegExp)); }
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 {//from ww w. j a v a 2s .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 {/*from w ww .ja v a 2 s .c o m*/ 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:edu.eurac.commul.pepperModules.mmax2.Salt2MMAXMapping.java
public static SAnnotationStringValueMatchCondition parseSAnnotationStringValueMatchCondition(Node node) { NamedNodeMap attributes = node.getAttributes(); Node stringValueAttributeNode = attributes.getNamedItem(SANN_STRING_VALUE_REGEXP); String stringValueRegExp = null; if (stringValueAttributeNode != null) { stringValueRegExp = stringValueAttributeNode.getNodeValue(); attributes.removeNamedItem(SANN_STRING_VALUE_REGEXP); } else {//from www . ja v a 2 s. c om throw new PepperModuleException("'" + SANN_STRING_VALUE_REGEXP + "' attribute not found on SAnnotation String Value Match Condition '" + node + "'"); } if (attributes.getLength() != 0) { throw new PepperModuleException( "Additional unexpected attributes found on SAnnotation String Value Match Condition '" + node + "'"); } return new SAnnotationStringValueMatchCondition(Pattern.compile(stringValueRegExp)); }
From source file:com.amalto.core.history.accessor.UnaryFieldAccessor.java
@Override public void markUnmodified() { Node parentNode = getElement(); NamedNodeMap attributes = parentNode.getAttributes(); if (attributes.getNamedItem(MODIFIED_MARKER_ATTRIBUTE) != null) { attributes.removeNamedItem(MODIFIED_MARKER_ATTRIBUTE); }//from w w w .ja v a2 s .co m }
From source file:com.amalto.core.history.accessor.AttributeAccessor.java
public void markUnmodified() { Node parentNode = parent.getNode(); NamedNodeMap attributes = parentNode.getAttributes(); if (attributes.getNamedItem(MODIFIED_MARKER_ATTRIBUTE) != null) { attributes.removeNamedItem(MODIFIED_MARKER_ATTRIBUTE); }// w w w . j a v a 2 s . com }
From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAXMapping.java
public static ArrayList<SRelationMapping> getSRelationMappingsFromFile(MMAX2ExporterProperties props) { ArrayList<SRelationMapping> mappings = new ArrayList<SRelationMapping>(); if (props.getSRelationMappingsFilePath() != null) { DocumentBuilder documentBuilder; try {/* w w w . ja v a2 s . c o m*/ documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new PepperModuleException(e.getMessage(), e); } File configurationFile = new File(props.getSRelationMappingsFilePath()); NodeList nodes = null; try { nodes = documentBuilder.parse(configurationFile).getDocumentElement().getChildNodes(); } catch (SAXException e) { throw new PepperModuleException(e.getMessage(), e); } catch (IOException e) { throw new PepperModuleException(e.getMessage(), e); } for (int i = 0; i < nodes.getLength(); i++) { Node xmlNode = nodes.item(i); if (xmlNode.getNodeType() != Node.ELEMENT_NODE) { continue; } String nodeName = xmlNode.getNodeName(); if (nodeName.equals(MAPPING_NODE_NAME)) { Node mapping_infos = null; Node condition_infos = null; NodeList sub_nodes = xmlNode.getChildNodes(); for (int j = 0; j < sub_nodes.getLength(); j++) { Node sub_xmlNode = sub_nodes.item(j); if (sub_xmlNode.getNodeType() != Node.ELEMENT_NODE) { continue; } String sub_nodeName = sub_xmlNode.getNodeName(); if (sub_nodeName.equals(MAPPING_INFOS_NODE_NAME)) { if (mapping_infos == null) { mapping_infos = sub_xmlNode; } else { throw new PepperModuleException( "More than one mapping infos defined on SRelation Mapping '" + xmlNode + "'"); } } else if (sub_nodeName.equals(CONDITION_NODE_NAME)) { if (condition_infos == null) { condition_infos = sub_xmlNode; } else { throw new PepperModuleException( "More than one match condition defined on SRelation Mapping '" + xmlNode + "'"); } } else if (!sub_nodeName.equals("")) { throw new PepperModuleException("Unknown type of Node '" + sub_xmlNode + "' with name '" + sub_nodeName + "' on SRelation Mapping '" + xmlNode + "'"); } } NamedNodeMap mapping_attributes = mapping_infos.getAttributes(); Node sourceDestSchemeNode = mapping_attributes.getNamedItem(SREL_MAPP_SOURCE_SCHEME_NAME); if (sourceDestSchemeNode == null) { throw new PepperModuleException("Source destination scheme '" + SREL_MAPP_SOURCE_SCHEME_NAME + "' on SRelation Mapping infos Node '" + mapping_infos + "' is not defined..."); } mapping_attributes.removeNamedItem(SREL_MAPP_SOURCE_SCHEME_NAME); String sourceSchemeName = sourceDestSchemeNode.getNodeValue(); Node targetDestSchemeNode = mapping_attributes.getNamedItem(SREL_MAPP_TARGET_SCHEME_NAME); if (targetDestSchemeNode == null) { throw new PepperModuleException("Target destination scheme '" + SREL_MAPP_TARGET_SCHEME_NAME + "' on SRelation Mapping infos Node '" + mapping_infos + "' is not defined..."); } mapping_attributes.removeNamedItem(SREL_MAPP_TARGET_SCHEME_NAME); String targetSchemeName = targetDestSchemeNode.getNodeValue(); Node destAttrNode = mapping_attributes.getNamedItem(SREL_MAPP_POINTER_ATTR_NAME); if (destAttrNode == null) { throw new PepperModuleException("Source attribute '" + SREL_MAPP_POINTER_ATTR_NAME + "' on SRelation Mapping infos Node '" + mapping_infos + "' is not defined..."); } mapping_attributes.removeNamedItem(SREL_MAPP_POINTER_ATTR_NAME); String attrName = destAttrNode.getNodeValue(); SRelationMatchCondition condition = parseSRelationMatchCondition(condition_infos); if (mapping_attributes.getLength() != 0) { ArrayList<String> unknownAttributes = new ArrayList<String>(); for (int j = 0; j < mapping_attributes.getLength(); j++) { unknownAttributes.add(mapping_attributes.item(j).getNodeName()); } throw new PepperModuleException( "Unknown attributes '" + StringUtils.join(unknownAttributes, ",") + "' on SRelation Mapping infos Node '" + mapping_infos + "'"); } mappings.add(new SRelationMapping(condition, sourceSchemeName, targetSchemeName, attrName)); } else { throw new PepperModuleException("Unknown type of Node among Mapping nodes '" + xmlNode + "' with name '" + nodeName + "'"); } } } return mappings; }
From source file:com.rest4j.generator.Generator.java
private void cleanupFinal(Element element) { if ("http://www.w3.org/1999/xhtml".equals(element.getNamespaceURI())) { element.getOwnerDocument().renameNode(element, null, element.getLocalName()); }//from w ww.j a v a 2s . c o m NamedNodeMap attrs = element.getAttributes(); if (attrs.getNamedItem("xmlns") != null) { attrs.removeNamedItem("xmlns"); } if (attrs.getNamedItem("xmlns:html") != null) { attrs.removeNamedItem("xmlns:html"); } for (Node child : Util.it(element.getChildNodes())) { if (child instanceof Element) { cleanupFinal((Element) child); } } }
From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAXMapping.java
public static ArrayList<SAnnotationMapping> getSAnnotationMappingsFromFile(MMAX2ExporterProperties props) { ArrayList<SAnnotationMapping> mappings = new ArrayList<SAnnotationMapping>(); if (props.getSAnnotationMappingsFilePath() != null) { DocumentBuilder documentBuilder; try {/*from ww w. j a v a 2 s .c om*/ documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new PepperModuleException(e.getMessage(), e); } File configurationFile = new File(props.getSAnnotationMappingsFilePath()); NodeList nodes = null; try { nodes = documentBuilder.parse(configurationFile).getDocumentElement().getChildNodes(); } catch (SAXException e) { throw new PepperModuleException(e.getMessage(), e); } catch (IOException e) { throw new PepperModuleException(e.getMessage(), e); } for (int i = 0; i < nodes.getLength(); i++) { Node xmlNode = nodes.item(i); if (xmlNode.getNodeType() != Node.ELEMENT_NODE) { continue; } String nodeName = xmlNode.getNodeName(); if (nodeName.equals(MAPPING_NODE_NAME)) { Node mapping_infos = null; Node condition_infos = null; NodeList sub_nodes = xmlNode.getChildNodes(); for (int j = 0; j < sub_nodes.getLength(); j++) { Node sub_xmlNode = sub_nodes.item(j); if (sub_xmlNode.getNodeType() != Node.ELEMENT_NODE) { continue; } String sub_nodeName = sub_xmlNode.getNodeName(); if (sub_nodeName.equals(MAPPING_INFOS_NODE_NAME)) { if (mapping_infos == null) { mapping_infos = sub_xmlNode; } else { throw new PepperModuleException( "More than one mapping infos defined on SAnnotation Mapping '" + xmlNode + "'"); } } else if (sub_nodeName.equals(CONDITION_NODE_NAME)) { if (condition_infos == null) { condition_infos = sub_xmlNode; } else { throw new PepperModuleException( "More than one match condition defined on SAnnotation Mapping '" + xmlNode + "'"); } } else { throw new PepperModuleException("Unknown type of Node '" + sub_xmlNode + "' with name '" + sub_nodeName + "' on SAnnotation Mapping '" + xmlNode + "'"); } } NamedNodeMap mapping_attributes = mapping_infos.getAttributes(); Node associatedSchemeNameAttribute = mapping_attributes.getNamedItem(SANN_MAPPING_ASS_SCHEME); if (associatedSchemeNameAttribute == null) { throw new PepperModuleException("associated scheme name '" + SANN_MAPPING_ASS_SCHEME + "' on SAnnotation Mapping infos Node '" + mapping_infos + "' is not defined..."); } String associatedSchemeName = associatedSchemeNameAttribute.getNodeValue(); mapping_attributes.removeNamedItem(SANN_MAPPING_ASS_SCHEME); Node associatedAttributeNameAttribute = mapping_attributes.getNamedItem(SANN_MAPPING_ASS_ATTR); if (associatedAttributeNameAttribute == null) { throw new PepperModuleException("associated attribute name '" + SANN_MAPPING_ASS_ATTR + "' on SAnnotation Mapping infos Node '" + mapping_infos + "' is not defined..."); } String associatedAttributeName = associatedAttributeNameAttribute.getNodeValue(); mapping_attributes.removeNamedItem(SANN_MAPPING_ASS_ATTR); SAnnotationMatchCondition condition = parseSAnnotationMatchCondition(condition_infos); if (mapping_attributes.getLength() != 0) { ArrayList<String> unknownAttributes = new ArrayList<String>(); for (int j = 0; j < mapping_attributes.getLength(); j++) { unknownAttributes.add(mapping_attributes.item(j).getNodeName()); } throw new PepperModuleException( "Unknown attributes '" + StringUtils.join(unknownAttributes, ",") + "' on SAnnotation Mapping infos Node '" + mapping_infos + "'"); } mappings.add(new SAnnotationMapping(condition, associatedSchemeName, associatedAttributeName)); } else if (xmlNode.getNodeType() == Node.ELEMENT_NODE) { throw new PepperModuleException("Unknown type of Node among Mapping nodes '" + xmlNode + "' with name '" + nodeName + "'"); } } } return mappings; }
From source file:com.naryx.tagfusion.cfm.document.cfDOCUMENT.java
private void removeBackground(Node _node) { // Remove any background items from the node. // For now we only remove the 'bgcolor' attribute. NamedNodeMap attributes = _node.getAttributes(); if ((attributes != null) && (attributes.getNamedItem("bgcolor") != null)) attributes.removeNamedItem("bgcolor"); // If the node has children then make recursive calls to remove the // background items from the children too. if (_node.hasChildNodes()) { NodeList children = _node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) removeBackground(children.item(i)); }//from w w w .j a va 2 s. c o m }