Java 类org.w3c.dom.NodeList 实例源码
项目:org.mybatis.generator.core-1.3.5
文件:MyBatisGeneratorConfigurationParser.java
protected void parseCommentGenerator(Context context, Node node) {
CommentGeneratorConfiguration commentGeneratorConfiguration = new CommentGeneratorConfiguration();
context.setCommentGeneratorConfiguration(commentGeneratorConfiguration);
Properties attributes = parseAttributes(node);
String type = attributes.getProperty("type"); //$NON-NLS-1$
if (stringHasValue(type)) {
commentGeneratorConfiguration.setConfigurationType(type);
}
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(commentGeneratorConfiguration, childNode);
}
}
}
项目:jdk8u-jdk
文件:JPEGMetadata.java
private void mergeStandardTextNode(Node node)
throws IIOInvalidTreeException {
// Convert to comments. For the moment ignore the encoding issue.
// Ignore keywords, language, and encoding (for the moment).
// If compression tag is present, use only entries with "none".
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
NamedNodeMap attrs = child.getAttributes();
Node comp = attrs.getNamedItem("compression");
boolean copyIt = true;
if (comp != null) {
String compString = comp.getNodeValue();
if (!compString.equals("none")) {
copyIt = false;
}
}
if (copyIt) {
String value = attrs.getNamedItem("value").getNodeValue();
COMMarkerSegment com = new COMMarkerSegment(value);
insertCOMMarkerSegment(com);
}
}
}
项目:openjdk-jdk10
文件:XMLSchemaInternalizationLogic.java
/**
* Creates a new XML Schema element of the given local name
* and insert it as the first child of the given parent node.
*
* @return
* Newly create element.
*/
private Element insertXMLSchemaElement( Element parent, String localName ) {
// use the same prefix as the parent node to avoid modifying
// the namespace binding.
String qname = parent.getTagName();
int idx = qname.indexOf(':');
if(idx==-1) qname = localName;
else qname = qname.substring(0,idx+1)+localName;
Element child = parent.getOwnerDocument().createElementNS( WellKnownNamespace.XML_SCHEMA, qname );
NodeList children = parent.getChildNodes();
if( children.getLength()==0 )
parent.appendChild(child);
else
parent.insertBefore( child, children.item(0) );
return child;
}
项目:springbootWeb
文件:MyBatisGeneratorConfigurationParser.java
private void parseIgnoreColumnByRegex(TableConfiguration tc, Node node) {
Properties attributes = parseAttributes(node);
String pattern = attributes.getProperty("pattern"); //$NON-NLS-1$
IgnoredColumnPattern icPattern = new IgnoredColumnPattern(pattern);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("except".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseException(icPattern, childNode);
}
}
tc.addIgnoredColumnPattern(icPattern);
}
项目:cuttlefish
文件:XMLUtil.java
static public Hashtable<String, String> getArguments(Node source) {
Hashtable<String, String> argumentTable = new Hashtable<String, String>();
NodeList arguments = source.getChildNodes();
for( int i=0; i<arguments.getLength(); i++ ){
Node argument = arguments.item(i);
if(argument.getNodeName().equals("Argument")){
String name = argument.getAttributes().getNamedItem("name").getNodeValue();
String value = argument.getTextContent();
System.out.println(name + "->" + value);
argumentTable.put(name, value);
}
}
return argumentTable;
}
项目:incubator-netbeans
文件:M2AuxilaryConfigImpl.java
static void findDuplicateElements(@NonNull Element parent, @NonNull ProblemProvider pp, FileObject config) {
NodeList l = parent.getChildNodes();
int nodeCount = l.getLength();
Set<String> known = new HashSet<String>();
for (int i = 0; i < nodeCount; i++) {
if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
Node node = l.item(i);
String localName = node.getLocalName();
localName = localName == null ? node.getNodeName() : localName;
String id = localName + "|" + node.getNamespaceURI();
if (!known.add(id)) {
//we have a duplicate;
pp.setProblem(ProjectProblem.createWarning(
TXT_Problem_Broken_Config2(),
DESC_Problem_Broken_Config2(),
new ProblemReporterImpl.MavenProblemResolver(ProblemReporterImpl.createOpenFileAction(config), BROKEN_NBCONFIG)));
}
}
}
}
项目:TextHIN
文件:PopularityCache.java
public static Map<String, Integer> extractMapValue(NodeList results) {
Map<String, Integer> map = new HashMap<String, Integer>();
for (int i = 0; i < results.getLength(); i++) {
NodeList bindings = ((Element) results.item(i)).getElementsByTagName("binding");
String property = null;
int count = 0;
for (int j = 0; j < bindings.getLength(); j++) {
Element binding = (Element) bindings.item(j);
String var = binding.getAttribute("name");
if (var.equals("p") || var.equals("type")) {
String uri = SparqlExecutor.getTagValue("uri", binding);
property = FreebaseInfo.uri2id(uri);
}
if (var.equals("count")) {
count = Integer.parseInt(SparqlExecutor.getTagValue("literal", binding));
}
}
map.put(property, count);
}
return map;
}
项目:jspider
文件:FieldDefineBeanDefinitionParser.java
private void parseFieldDefines(FieldDefine fieldDefine, Element defineElement) {
NodeList nodeList = defineElement.getChildNodes();
if (nodeList != null && nodeList.getLength() > 0) {
int length = nodeList.getLength();
List<FieldDefine> list = new LinkedList<FieldDefine>();
for (int i = 0; i < length; i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
Element element = (Element) node;
if ("selector".equals(element.getLocalName())) {
fieldDefine.setSelector(element.getTextContent());
} else if ("processor".equals(element.getLocalName())) {
fieldDefine.setProcessor(getFieldProcessor(element));
} else {
list.add(parseFieldDefine(element));
}
}
}
if (list.size() > 0) {
fieldDefine.setDefines(list.toArray(new FieldDefine[list.size()]));
}
}
}
项目:brModelo
文件:PreTextoApenso.java
@Override
protected void ToXmlValores(Document doc, Element me) {
super.ToXmlValores(doc, me);
me.appendChild(util.XMLGenerate.ValorInteger(doc, "Alinhamento", getAlinhamento().ordinal()));
me.appendChild(util.XMLGenerate.ValorBoolean(doc, "CentrarVertical", isCentrarVertical()));
me.appendChild(util.XMLGenerate.ValorInteger(doc, "Tipo", getTipo().ordinal()));
me.appendChild(util.XMLGenerate.ValorBoolean(doc, "Autosize", isAutosize()));
me.appendChild(util.XMLGenerate.ValorBoolean(doc, "MovimentacaoManual", isMovimentacaoManual()));
//remover dicionário do XML do objeto.
NodeList nl = me.getElementsByTagName("Dicionario");
if (nl != null && nl.getLength() > 0) {
me.removeChild(nl.item(0));
}
}
项目:hadoop
文件:TestHsWebServicesTasks.java
@Test
public void testTasksXML() throws JSONException, Exception {
WebResource r = resource();
Map<JobId, Job> jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
ClientResponse response = r.path("ws").path("v1").path("history")
.path("mapreduce").path("jobs").path(jobId).path("tasks")
.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
String xml = response.getEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
Document dom = db.parse(is);
NodeList tasks = dom.getElementsByTagName("tasks");
assertEquals("incorrect number of elements", 1, tasks.getLength());
NodeList task = dom.getElementsByTagName("task");
verifyHsTaskXML(task, jobsMap.get(id));
}
}
项目:org.mybatis.generator.core-1.3.5
文件:MyBatisGeneratorConfigurationParser.java
public Configuration parseConfiguration(Element rootNode)
throws XMLParserException {
Configuration configuration = new Configuration();
NodeList nodeList = rootNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperties(configuration, childNode);
} else if ("classPathEntry".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseClassPathEntry(configuration, childNode);
} else if ("context".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseContext(configuration, childNode);
}
}
return configuration;
}
项目:Tarski
文件:XMLDOMHelper.java
/**
* Return the text that a node contains. This routine:
* <ul>
* <li>Ignores comments and processing instructions.
* <li>Concatenates TEXT nodes, CDATA nodes, and the results of recursively processing EntityRef
* nodes.
* <li>Ignores any element nodes in the sublist. (Other possible options are to recurse into
* element sublists or throw an exception.)
* </ul>
*
* @param node a DOM node
* @return a String representing its contents
*/
public static String getText(Node node) {
StringBuffer result = new StringBuffer();
if (!node.hasChildNodes())
return "";
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node subnode = list.item(i);
if (subnode.getNodeType() == Node.TEXT_NODE) {
result.append(subnode.getNodeValue());
} else if (subnode.getNodeType() == Node.CDATA_SECTION_NODE) {
result.append(subnode.getNodeValue());
} else if (subnode.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
// Recurse into the subtree for text
// (and ignore comments)
result.append(getText(subnode));
}
}
return result.toString();
}
项目:OpenJSharp
文件:SAXImpl.java
/**
* Create an org.w3c.dom.NodeList from a node in the tree
*/
public NodeList makeNodeList(int index) {
if (_nodeLists == null) {
_nodeLists = new NodeList[_namesSize];
}
int nodeID = makeNodeIdentity(index);
if (nodeID < 0) {
return null;
}
else if (nodeID < _nodeLists.length) {
return (_nodeLists[nodeID] != null) ? _nodeLists[nodeID]
: (_nodeLists[nodeID] = new DTMAxisIterNodeList(this,
new SingletonIterator(index)));
}
else {
return new DTMAxisIterNodeList(this, new SingletonIterator(index));
}
}
项目:TuLiPA-frames
文件:XMLLemmaReader.java
public static List<CoAnchor> getCoAnchors(Element e) {
List<CoAnchor> coancs = new LinkedList<CoAnchor>();
NodeList l = e.getChildNodes();
for (int i = 0; i < l.getLength(); i++) {
Node n = l.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element el = (Element) n;
if (el.getTagName().equals("coanchor")) {
String nid = el.getAttribute("node_id");
CoAnchor coanc = new CoAnchor(nid);
coanc.setLex(getLex(el));
String cat = el.getAttribute("cat");
coanc.setCat(cat);
coancs.add(coanc);
}
}
}
return coancs;
}
项目:openjdk-jdk10
文件:ExsltMath.java
/**
* The math:highest function returns the nodes in the node set whose value is the maximum
* value for the node set. The maximum value for the node set is the same as the value as
* calculated by math:max. A node has this maximum value if the result of converting its
* string value to a number as if by the number function is equal to the maximum value,
* where the equality comparison is defined as a numerical comparison using the = operator.
* <p>
* If any of the nodes in the node set has a non-numeric value, the math:max function will
* return NaN. The definition numeric comparisons entails that NaN != NaN. Therefore if any
* of the nodes in the node set has a non-numeric value, math:highest will return an empty
* node set.
*
* @param nl The NodeList for the node-set to be evaluated.
*
* @return node-set with nodes containing the maximum value found, an empty node-set
* if any node cannot be converted to a number.
*/
public static NodeList highest (NodeList nl)
{
double maxValue = max(nl);
NodeSet highNodes = new NodeSet();
highNodes.setShouldCacheNodes(true);
if (Double.isNaN(maxValue))
return highNodes; // empty Nodeset
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
if (d == maxValue)
highNodes.addElement(n);
}
return highNodes;
}
项目:kaltura-ce-sakai-extension
文件:KalturaSwfFlavorParamsOutput.java
public KalturaSwfFlavorParamsOutput(Element node) throws KalturaApiException {
super(node);
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node aNode = childNodes.item(i);
String nodeName = aNode.getNodeName();
String txt = aNode.getTextContent();
if (nodeName.equals("flashVersion")) {
this.flashVersion = ParseUtils.parseInt(txt);
continue;
} else if (nodeName.equals("poly2Bitmap")) {
this.poly2Bitmap = ParseUtils.parseBool(txt);
continue;
}
}
}
项目:MybatisGeneatorUtil
文件:MyBatisGeneratorConfigurationParser.java
protected void parseConnectionFactory(Context context, Node node) {
ConnectionFactoryConfiguration connectionFactoryConfiguration = new ConnectionFactoryConfiguration();
context.setConnectionFactoryConfiguration(connectionFactoryConfiguration);
Properties attributes = parseAttributes(node);
String type = attributes.getProperty("type"); //$NON-NLS-1$
if (stringHasValue(type)) {
connectionFactoryConfiguration.setConfigurationType(type);
}
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(connectionFactoryConfiguration, childNode);
}
}
}
项目:server-utility
文件:MyBatisGeneratorConfigurationParser.java
protected void parseSqlMapGenerator(Context context, Node node) {
SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();
context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);
Properties attributes = parseAttributes(node);
String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
sqlMapGeneratorConfiguration.setTargetProject(targetProject);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(sqlMapGeneratorConfiguration, childNode);
}
}
}
项目:pmTrans
文件:EditingPane.java
public void loadTranscription(File transcriptionFile)
throws ParserConfigurationException, SAXException, IOException {
text.setText("");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(transcriptionFile);
// Text
text.setText(doc.getElementsByTagName("text").item(0).getTextContent());
// Timestamps
NodeList nList = doc.getElementsByTagName("timeStamp");
for (int temp = 0; temp < nList.getLength(); temp++) {
Element timestamp = (Element) nList.item(temp);
printTimestamp(Integer.parseInt(timestamp.getAttribute("start")),
Integer.parseInt(timestamp.getAttribute("lenght")));
}
changed = false;
}
项目:parabuild-ci
文件:DwrXmlConfigurator.java
/**
* Internal method to load the create/convert elements
* @param child The element to read
*/
private void loadAllows(Element child)
{
NodeList allows = child.getChildNodes();
for (int j = 0; j < allows.getLength(); j++)
{
if (allows.item(j).getNodeType() == Node.ELEMENT_NODE)
{
Element allower = (Element) allows.item(j);
if (allower.getNodeName().equals(ELEMENT_CREATE))
{
loadCreate(allower);
}
else if (allower.getNodeName().equals(ELEMENT_CONVERT))
{
loadConvert(allower);
}
else if (allower.getNodeName().equals(ELEMENT_FILTER))
{
loadFilter(allower);
}
}
}
}
项目:hadoop
文件:TestRMWebServicesApps.java
@Test
public void testSingleAppsXML() throws JSONException, Exception {
rm.start();
MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
RMApp app1 = rm.submitApp(CONTAINER_MB, "testwordcount", "user1");
amNodeManager.nodeHeartbeat(true);
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster")
.path("apps").path(app1.getApplicationId().toString())
.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
String xml = response.getEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
Document dom = db.parse(is);
NodeList nodes = dom.getElementsByTagName("app");
assertEquals("incorrect number of elements", 1, nodes.getLength());
verifyAppsXML(nodes, app1);
rm.stop();
}
项目:summer-mybatis-generator
文件:MyBatisGeneratorConfigurationParser.java
protected void parseSqlMapGenerator(Context context, Node node) {
SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();
context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);
Properties attributes = parseAttributes(node);
String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
sqlMapGeneratorConfiguration.setTargetProject(targetProject);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(sqlMapGeneratorConfiguration, childNode);
}
}
}
项目:oscm
文件:SharesCalculatorBeanCutOffDayIT.java
private void verify_SupplierResult_Service(Document xml,
Organization resaleOrg, OfferingType type, String roleString)
throws XPathExpressionException {
NodeList services = XMLConverter.getNodeListByXPath(xml, "/"
+ roleString
+ "RevenueShareResult/Currency/Marketplace/Service");
for (int i = 0; i < services.getLength(); i++) {
String model = XMLConverter.getStringAttValue(services.item(i),
"model");
if (type.name().equals(model)) {
verify_SupplierResult_RevenueShareDetails(services.item(i));
if (resaleOrg != null) {
verify_ResaleOrganization(services.item(i), resaleOrg);
}
}
}
}
项目:DocIT
文件:Cut.java
public static void cut(Document doc) {
// Get the matching elements
NodeList nodelist = doc.getElementsByTagName("salary");
// Process the elements in the nodelist
for (int i=0; i<nodelist.getLength(); i++) {
// Get element
Element elem = (Element)nodelist.item(i);
// Transform content of element
double value = parseDouble(elem.getTextContent());
elem.setTextContent(Double.toString(value / 2));
}
}
项目:ChronoBike
文件:ActionShowScreen.java
private void setEditTagsForName(Document docOutput, String csName)
{
NodeList lst = docOutput.getElementsByTagName(csName) ;
int nb = lst.getLength() ;
for (int i=0; i<nb; i++)
{
Element e = (Element)lst.item(i) ;
if (e.hasAttribute("linkedvalue"))
{
String value = e.getAttribute("value");
if (value != null && value.equals(""))
{
String protection = e.getAttribute("protection");
if (protection == null || protection.equals("") || protection.equals("autoskip"))
{
String length = e.getAttribute("length");
int nLength = 1;
if (length != null && !length.equals("")) {
nLength = new Integer(length).intValue();
}
e.setAttribute("value", StringUtil.rightPad("", nLength, '*'));
}
}
}
}
}
项目:kaltura-ce-sakai-extension
文件:KalturaSshImportJobData.java
public KalturaSshImportJobData(Element node) throws KalturaApiException {
super(node);
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node aNode = childNodes.item(i);
String nodeName = aNode.getNodeName();
String txt = aNode.getTextContent();
if (nodeName.equals("privateKey")) {
this.privateKey = ParseUtils.parseString(txt);
continue;
} else if (nodeName.equals("publicKey")) {
this.publicKey = ParseUtils.parseString(txt);
continue;
} else if (nodeName.equals("passPhrase")) {
this.passPhrase = ParseUtils.parseString(txt);
continue;
}
}
}
项目:incubator-netbeans
文件:XMLSyntaxParserTest.java
public void testParsePI() throws Exception {
BaseDocument basedoc = getDocument("resources/PI_after_prolog.xml");
XMLSyntaxParser parser = new XMLSyntaxParser();
Document doc = parser.parse(basedoc);
List<Token> tokens = doc.getTokens();
assertEquals(12, tokens.size());
assertEquals(TokenType.TOKEN_PI_START_TAG, tokens.get(0).getType());
assertEquals(TokenType.TOKEN_PI_END_TAG, tokens.get(4).getType());
assertEquals(TokenType.TOKEN_PI_START_TAG, tokens.get(6).getType());
assertEquals(TokenType.TOKEN_PI_NAME, tokens.get(7).getType());
assertEquals("Siebel-Property-Set", tokens.get(7).getValue());
assertEquals(TokenType.TOKEN_PI_VAL, tokens.get(9).getType());
NodeList nl = doc.getChildNodes();
assertEquals(2, nl.getLength());
}
项目:incubator-netbeans
文件:XMLUtil.java
/**
* Find all direct child elements of an element.
* More useful than {@link Element#getElementsByTagNameNS} because it does
* not recurse into recursive child elements.
* Children which are all-whitespace text nodes or comments are ignored; others cause
* an exception to be thrown.
* @param parent a parent element in a DOM tree
* @return a list of direct child elements (may be empty)
* @throws IllegalArgumentException if there are non-element children besides whitespace
*/
static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
NodeList l = parent.getChildNodes();
List<Element> elements = new ArrayList<>(l.getLength());
for (int i = 0; i < l.getLength(); i++) {
Node n = l.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
elements.add((Element)n);
} else if (n.getNodeType() == Node.TEXT_NODE) {
String text = ((Text)n).getNodeValue();
if (text.trim().length() > 0) {
throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
}
} else if (n.getNodeType() == Node.COMMENT_NODE) {
// OK, ignore
} else {
throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
}
}
return elements;
}
项目:winter
文件:XMLMatchableReader.java
/**
* returns a list of values from a child node of the first parameter. The
* list values are expected to be atomic, i.e. no complex node structures
*
* @param node
* the node containing the data
* @param childName
* the name of the child node
* @return a list of values from the specified child node
*/
protected List<String> getListFromChildElement(Node node, String childName) {
// get all child nodes
NodeList children = node.getChildNodes();
// iterate over the child nodes until the node with childName is found
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
// check the node type and name
if (child.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE
&& child.getNodeName().equals(childName)) {
// prepare a list to hold all values
List<String> values = new ArrayList<>(child.getChildNodes()
.getLength());
// iterate the value nodes
for (int i = 0; i < child.getChildNodes().getLength(); i++) {
Node valueNode = child.getChildNodes().item(i);
String value = valueNode.getTextContent().trim();
// add the value
values.add(value);
}
return values;
}
}
return null;
}
项目:incubator-netbeans
文件:Document.java
/**
* This is a convenience attribute that allows direct access to the child
* node that is the document element of the document.
*/
public org.w3c.dom.Element getDocumentElement() {
if(hasChildNodes()) {
NodeList childNodes = getChildNodes();
for (int i=0;i<childNodes.getLength(); i++) {
Node child = (Node)childNodes.item(i);
if (child instanceof org.w3c.dom.Element)
return (org.w3c.dom.Element)child;
}
}
return null;
}
项目:OpenJSharp
文件:WSDLInternalizationLogic.java
private Element insertJAXWSBindingsElement( Element parent, String localName ) {
String qname = "JAXWS:"+localName;
Element child = parent.getOwnerDocument().createElementNS(JAXWSBindingsConstants.NS_JAXWS_BINDINGS, qname );
NodeList children = parent.getChildNodes();
if( children.getLength()==0 )
parent.appendChild(child);
else
parent.insertBefore( child, children.item(0) );
return child;
}
项目:convertigo-engine
文件:WebClipper.java
protected void generateIds(Element original, Element copy) {
String attr = context.getIdToXpathManager().addNode(original);
Engine.logBeans.trace("Added node : " + original.getNodeName() + " with id :" + attr);
copy.setAttribute("twsid", attr);
NodeList original_nodes = original.getChildNodes();
NodeList copy_nodes = copy.getChildNodes();
for (int i = 0; i < original_nodes.getLength(); i++) {
Node node = original_nodes.item(i);
Node copy_node = copy_nodes.item(i);
if (node instanceof Element && copy_node instanceof Element) {
generateIds((Element)node, (Element)copy_node);
}
}
}
项目:convertigo-engine
文件:Transaction.java
@Override
protected String getWsdlBackupDir(Element element) throws Exception {
String backupDir = super.getWsdlBackupDir(element);
Element connectorNode = (Element) element.getParentNode();
NodeList properties = connectorNode.getElementsByTagName("property");
Element pName = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "name");
String connectorName = (String) XMLUtils.readObjectFromXml((Element) XMLUtils.findChildNode(pName, Node.ELEMENT_NODE));
backupDir += "/" + connectorName;
return backupDir;
}
项目:geomapapp
文件:LayerSetDetails.java
private static List getElements(Node node, String elementName) {
List list = new LinkedList();
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
if (nodeList.item(i).getNodeName().equals(elementName)
&& nodeList.item(i).getNodeType() == Node.ELEMENT_NODE) {
list.add(nodeList.item(i));
}
}
return list;
}
项目:mi-firma-android
文件:InitiativesList.java
/** Recupera el índice del siguiente nodo de la lista de tipo
* <code>Element</code>. Empieza a comprobar los nodos a partir del
* índice marcado. Si no encuentra un nodo de tipo <i>elemento</i>
* devuelve -1.
* @param nodes Listado de nodos.
* @param currentIndex Índice del listado a partir del cual se empieza la
* comprobación.
* @return Índice del siguiente node de tipo Element o -1 si no se
* encontró. */
private static int nextNodeElementIndex(final NodeList nodes, final int currentIndex) {
Node node;
int i = currentIndex;
while (i < nodes.getLength()) {
node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
return i;
}
i++;
}
return -1;
}
项目:Proyecto-DASI
文件:ReadXMLTestSequence.java
private String getVictimArrivalTimeValueString(Element info, String tag){
NodeList timeNmElmntLst = info.getElementsByTagName(tag);
Element timeNmElmnt = (Element) timeNmElmntLst.item(0);
NodeList timeNm = timeNmElmnt.getChildNodes();
String valuetime = ((Node)timeNm.item(0)).getNodeValue();
return valuetime;
}
项目:openjdk-jdk10
文件:GeneratorBase.java
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
Element e = options.getHandlerChainConfiguration();
if (e == null) {
return;
}
JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
NodeList nl = e.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chain");
if(nl.getLength() > 0){
String fName = getHandlerConfigFileName(className);
handlerChainAnn.param("file", fName);
generateHandlerChainFile(e, className);
}
}
项目:jspider
文件:FieldDefineBeanDefinitionParser.java
private Object[] getFieldProcessorArguments(Element element) {
NodeList nodeList = element.getChildNodes();
List<Object> list = new LinkedList<Object>();
if (nodeList != null && nodeList.getLength() > 0) {
int length = nodeList.getLength();
for (int i = 0; i < length; i++) {
list.add(nodeList.item(i).getTextContent());
}
}
return list.toArray(new Object[list.size()]);
}
项目:Proyecto-DASI
文件:ReadXMLTestRobots.java
public synchronized int getRobotInitialEnergy(Element info, String tag){
NodeList initialenergyNmElmntLst = info.getElementsByTagName(tag);
Element initialenergyNmElmnt = (Element) initialenergyNmElmntLst.item(0);
NodeList initialenergyNm = initialenergyNmElmnt.getChildNodes();
String initialenergy = ((Node)initialenergyNm.item(0)).getNodeValue();
return Integer.parseInt(initialenergy);
}
项目:nifi-registry
文件:AbstractPolicyBasedAuthorizer.java
private Group parseGroup(final Element element) {
final Group.Builder builder = new Group.Builder()
.identifier(element.getAttribute(IDENTIFIER_ATTR))
.name(element.getAttribute(NAME_ATTR));
NodeList groupUsers = element.getElementsByTagName(GROUP_USER_ELEMENT);
for (int i=0; i < groupUsers.getLength(); i++) {
Element groupUserNode = (Element) groupUsers.item(i);
builder.addUser(groupUserNode.getAttribute(IDENTIFIER_ATTR));
}
return builder.build();
}