本文整理汇总了Java中org.w3c.dom.NodeList类的典型用法代码示例。如果您正苦于以下问题:Java NodeList类的具体用法?Java NodeList怎么用?Java NodeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeList类属于org.w3c.dom包,在下文中一共展示了NodeList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeStandardTextNode
import org.w3c.dom.NodeList; //导入依赖的package包/类
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);
}
}
}
示例2: parseCommentGenerator
import org.w3c.dom.NodeList; //导入依赖的package包/类
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);
}
}
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:26,代码来源:MyBatisGeneratorConfigurationParser.java
示例3: insertXMLSchemaElement
import org.w3c.dom.NodeList; //导入依赖的package包/类
/**
* 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;
}
示例4: parseIgnoreColumnByRegex
import org.w3c.dom.NodeList; //导入依赖的package包/类
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);
}
示例5: getArguments
import org.w3c.dom.NodeList; //导入依赖的package包/类
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;
}
示例6: findDuplicateElements
import org.w3c.dom.NodeList; //导入依赖的package包/类
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)));
}
}
}
}
示例7: extractMapValue
import org.w3c.dom.NodeList; //导入依赖的package包/类
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;
}
示例8: parseFieldDefines
import org.w3c.dom.NodeList; //导入依赖的package包/类
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()]));
}
}
}
示例9: ToXmlValores
import org.w3c.dom.NodeList; //导入依赖的package包/类
@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));
}
}
示例10: testTasksXML
import org.w3c.dom.NodeList; //导入依赖的package包/类
@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));
}
}
示例11: parseConfiguration
import org.w3c.dom.NodeList; //导入依赖的package包/类
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;
}
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:25,代码来源:MyBatisGeneratorConfigurationParser.java
示例12: getText
import org.w3c.dom.NodeList; //导入依赖的package包/类
/**
* 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();
}
示例13: makeNodeList
import org.w3c.dom.NodeList; //导入依赖的package包/类
/**
* 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));
}
}
示例14: getCoAnchors
import org.w3c.dom.NodeList; //导入依赖的package包/类
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;
}
示例15: highest
import org.w3c.dom.NodeList; //导入依赖的package包/类
/**
* 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;
}