use of org.w3c.dom.NamedNodeMap in project tdi-studio-se by Talend.
the class ExpressionFileOperation method importExpressionFromFile.
/**
* yzhang Comment method "getExpressionFromFile".
*
* @param file
* @return
* @throws IOException
* @throws SAXException
* @throws ParserConfigurationException
*/
public List importExpressionFromFile(File file, Shell shell) throws IOException, ParserConfigurationException, SAXException {
if (file != null) {
List list = new ArrayList();
if (!file.isFile()) {
openDialog(shell);
return list;
} else {
final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
final Bundle b = Platform.getBundle(PLUGIN_ID);
final URL url = FileLocator.toFileURL(FileLocator.find(b, new Path(SCHEMA_XSD), null));
final File schema = new File(url.getPath());
final Document document = XSDValidator.checkXSD(file, schema);
final NodeList expressionNodes = document.getElementsByTagName(Messages.getString(//$NON-NLS-1$
"ExpressionFileOperation.expression"));
if (expressionNodes.getLength() == 1) {
Node expressionNode = expressionNodes.item(0);
NamedNodeMap epxressionAttrs = expressionNode.getAttributes();
Node contentNode = epxressionAttrs.getNamedItem(Messages.getString(//$NON-NLS-1$
"ExpressionFileOperation.content"));
list.add(contentNode.getNodeValue());
}
final NodeList variableNodes = document.getElementsByTagName(Messages.getString(//$NON-NLS-1$
"ExpressionFileOperation.variable"));
for (int i = 0; i < variableNodes.getLength(); i++) {
Node variableNode = variableNodes.item(i);
NamedNodeMap varAttrs = variableNode.getAttributes();
//$NON-NLS-1$
Node nameNode = varAttrs.getNamedItem(Messages.getString("ExpressionFileOperation.name"));
//$NON-NLS-1$
Node valueNode = varAttrs.getNamedItem(Messages.getString("ExpressionFileOperation.value"));
Node talendTypeNode = varAttrs.getNamedItem(Messages.getString(//$NON-NLS-1$
"ExpressionFileOperation.talendType"));
//$NON-NLS-1$
Node nullableNode = varAttrs.getNamedItem(Messages.getString("ExpressionFileOperation.nullable"));
Variable variable = new Variable();
variable.setName(nameNode.getNodeValue());
variable.setValue(valueNode.getNodeValue());
variable.setTalendType(talendTypeNode.getNodeValue());
String s = nullableNode.getNodeValue();
Boolean boo = Boolean.valueOf(s);
if (boo == null) {
boo = false;
}
variable.setNullable(boo);
list.add(variable);
}
return list;
}
}
return null;
}
use of org.w3c.dom.NamedNodeMap in project OpenAM by OpenRock.
the class DelegationConfig method getAttribute.
private String getAttribute(Node node, String attrName) {
String value = null;
NamedNodeMap attrs = node.getAttributes();
Node nodeID = attrs.getNamedItem(attrName);
if (nodeID != null) {
value = nodeID.getNodeValue();
value = value.trim();
}
return value;
}
use of org.w3c.dom.NamedNodeMap in project OpenAM by OpenRock.
the class AMPropertySheetModel method parseNodeList.
private void parseNodeList(NodeList nodeList) {
if (nodeList != null) {
int length = nodeList.getLength();
mapOptionList = new HashMap<String, OptionList>();
for (int i = 0; i < length; i++) {
Node node = nodeList.item(i);
// Check node for name attribute.
if (node.hasAttributes()) {
NamedNodeMap nodeAttrs = node.getAttributes();
Node nameNode = nodeAttrs.getNamedItem(NAME_ATTRIBUTE);
Node tagclassNode = nodeAttrs.getNamedItem(CCDescriptor.CC_ELEMENT_TAGCLASS);
if ((nameNode != null) && (tagclassNode != null)) {
String name = nameNode.getNodeValue();
String v = tagclassNode.getNodeValue();
if (name.startsWith(DATE_MARKER_NAME)) {
String dateName = name.substring(DATE_MARKER_NAME.length());
dateComponents.add(dateName);
} else if (v != null) {
if (v.equals(CCTagClass.EDITABLELIST)) {
setModel(name, new CCEditableListModel());
} else if (v.equals(CCTagClass.PASSWORD)) {
passwordComponents.add(name);
} else if (v.equals(CCTagClass.RADIOBUTTON)) {
String def = getNodeDefaultValue(node);
if (def != null) {
radioDefaultValue.put(name, def);
}
}
childMap.put(name, v);
NodeList optionElements = ((Element) node).getElementsByTagName(VALUE_OPTION_TAG_NAME);
if (optionElements.getLength() > 0) {
OptionList optionList = new OptionList();
int numOptions = optionElements.getLength();
for (int j = 0; j < numOptions; j++) {
Node option = optionElements.item(j);
if (option.hasAttributes()) {
NamedNodeMap optAttrs = option.getAttributes();
optionList.add(j, optAttrs.getNamedItem(OPTION_LABEL_ATTR_NAME).getNodeValue(), optAttrs.getNamedItem(OPTION_VALUE_ATTR_NAME).getNodeValue());
}
}
mapOptionList.put(name, optionList);
}
}
if (name.equals(TBL_SUB_CONFIG)) {
hasSubConfigTable = true;
}
}
}
}
}
}
use of org.w3c.dom.NamedNodeMap in project ACS by ACS-Community.
the class LogEntryXML method printNode.
/**
* Recursively prints the struct of the node
*
* @param logNode The node to print
*/
public static void printNode(Node logNode, int depth) {
String indent = "";
for (int i = 0; i < depth; i++) indent = indent + "\t";
System.out.print(indent + "Node name " + logNode.getNodeName());
System.out.print(", type " + logNode.getNodeType());
System.out.println(", val " + logNode.getNodeValue());
NamedNodeMap map = logNode.getAttributes();
if (map != null) {
for (int i = 0; i < map.getLength(); i++) {
Node nd = map.item(i);
System.out.print(indent + "\tAttr name " + nd.getNodeName());
System.out.print(", type " + nd.getNodeType());
System.out.println(", val " + nd.getNodeValue());
}
}
NodeList childs = logNode.getChildNodes();
if (childs != null) {
for (int i = 0; i < childs.getLength(); i++) {
printNode(childs.item(i), depth + 1);
}
}
}
use of org.w3c.dom.NamedNodeMap in project kotlin by JetBrains.
the class ResourceVisitor method visitElement.
private void visitElement(@NonNull XmlContext context, @NonNull Element element) {
List<Detector.XmlScanner> elementChecks = mElementToCheck.get(element.getTagName());
if (elementChecks != null) {
assert elementChecks instanceof RandomAccess;
for (XmlScanner check : elementChecks) {
check.visitElement(context, element);
}
}
if (!mAllElementDetectors.isEmpty()) {
for (XmlScanner check : mAllElementDetectors) {
check.visitElement(context, element);
}
}
if (!mAttributeToCheck.isEmpty() || !mAllAttributeDetectors.isEmpty()) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0, n = attributes.getLength(); i < n; i++) {
Attr attribute = (Attr) attributes.item(i);
String name = attribute.getLocalName();
if (name == null) {
name = attribute.getName();
}
List<Detector.XmlScanner> list = mAttributeToCheck.get(name);
if (list != null) {
for (XmlScanner check : list) {
check.visitAttribute(context, attribute);
}
}
if (!mAllAttributeDetectors.isEmpty()) {
for (XmlScanner check : mAllAttributeDetectors) {
check.visitAttribute(context, attribute);
}
}
}
}
// Visit children
NodeList childNodes = element.getChildNodes();
for (int i = 0, n = childNodes.getLength(); i < n; i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
visitElement(context, (Element) child);
}
}
// Post hooks
if (elementChecks != null) {
for (XmlScanner check : elementChecks) {
check.visitElementAfter(context, element);
}
}
if (!mAllElementDetectors.isEmpty()) {
for (XmlScanner check : mAllElementDetectors) {
check.visitElementAfter(context, element);
}
}
}
Aggregations