当前位置: 首页>>代码示例>>Java>>正文


Java NodeIterator类代码示例

本文整理汇总了Java中org.w3c.dom.traversal.NodeIterator的典型用法代码示例。如果您正苦于以下问题:Java NodeIterator类的具体用法?Java NodeIterator怎么用?Java NodeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NodeIterator类属于org.w3c.dom.traversal包,在下文中一共展示了NodeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNodes

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * Copy NodeList members into this nodelist, adding in
 * document order.  Null references are not added.
 *
 * @param iterator NodeIterator which yields the nodes to be added.
 * @throws RuntimeException thrown if this NodeSet is not of
 * a mutable type.
 */
public void addNodes(NodeIterator iterator)
{

  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

  if (null != iterator)  // defensive to fix a bug that Sanjiva reported.
  {
    Node obj;

    while (null != (obj = iterator.nextNode()))
    {
      addElement(obj);
    }
  }

  // checkDups();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:NodeSet.java

示例2: createNodeIterator

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * Create and return a NodeIterator. The NodeIterator is
 * added to a list of NodeIterators so that it can be
 * removed to free up the DOM Nodes it references.
 *
 * @param root The root of the iterator.
 * @param whatToShow The whatToShow mask.
 * @param filter The NodeFilter installed. Null means no filter.
 * @param entityReferenceExpansion true to expand the contents of
 *                                 EntityReference nodes
 * @since WD-DOM-Level-2-19990923
 */
public NodeIterator createNodeIterator(Node root,
                                       int whatToShow,
                                       NodeFilter filter,
                                       boolean entityReferenceExpansion)
{

    if (root == null) {
              String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
              throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
    }

    NodeIterator iterator = new NodeIteratorImpl(this,
                                                 root,
                                                 whatToShow,
                                                 filter,
                                                 entityReferenceExpansion);
    if (iterators == null) {
        iterators = new ArrayList<>();
    }

    iterators.add(iterator);

    return iterator;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:DocumentImpl.java

示例3: writeObject

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * @serialData Serialized fields. Convert Maps to Hashtables and Lists
 * to Vectors for backward compatibility.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Convert Maps to Hashtables, Lists to Vectors
    Vector<NodeIterator> it = (iterators == null)? null : new Vector<>(iterators);
    Vector<Range> r = (ranges == null)? null : new Vector<>(ranges);

    Hashtable<NodeImpl, Vector<LEntry>> el = null;
    if (eventListeners != null) {
        el = new Hashtable<>();
        for (Map.Entry<NodeImpl, List<LEntry>> e : eventListeners.entrySet()) {
             el.put(e.getKey(), new Vector<>(e.getValue()));
        }
    }

    // Write serialized fields
    ObjectOutputStream.PutField pf = out.putFields();
    pf.put("iterators", it);
    pf.put("ranges", r);
    pf.put("eventListeners", el);
    pf.put("mutationEvents", mutationEvents);
    out.writeFields();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:DocumentImpl.java

示例4: readObject

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in)
                    throws IOException, ClassNotFoundException {
    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = in.readFields();
    Vector<NodeIterator> it = (Vector<NodeIterator>)gf.get("iterators", null);
    Vector<Range> r = (Vector<Range>)gf.get("ranges", null);
    Hashtable<NodeImpl, Vector<LEntry>> el =
            (Hashtable<NodeImpl, Vector<LEntry>>)gf.get("eventListeners", null);

    mutationEvents = gf.get("mutationEvents", false);

    //convert Hashtables back to HashMaps and Vectors to Lists
    if (it != null) iterators = new ArrayList<>(it);
    if (r != null) ranges = new ArrayList<>(r);
    if (el != null) {
        eventListeners = new HashMap<>();
        for (Map.Entry<NodeImpl, Vector<LEntry>> e : el.entrySet()) {
             eventListeners.put(e.getKey(), new ArrayList<>(e.getValue()));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:DocumentImpl.java

示例5: main

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Document doc = XmlUtils.loadDoc("/testcode/xpath/data.xml");

    String input = args.length != 0 ? args[1] : "guess' or '1'='1";
    String query = "//groups/group[@id='" + input + "']/writeAccess/text()";

    //selectNodeIterator
    NodeIterator iterator = XPathAPI.selectNodeIterator(doc, query);
    XmlUtils.printNodeIterator(iterator);

    //selectNodeList
    NodeList nodeList = XPathAPI.selectNodeList(doc, query);
    XmlUtils.printNodeList(nodeList);

    //selectSingleNode
    Node node = XPathAPI.selectSingleNode(doc, query);
    XmlUtils.printNode(node);

    //Static string (safe)
    Node node2 = XPathAPI.selectSingleNode(doc, "//groups/group[@id='guess']/writeAccess/text()".toLowerCase());
    XmlUtils.printNode(node2);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:XPathApacheXPathApi.java

示例6: createNodeIterator

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * Creates a new node iterator.
 */
public NodeIterator createNodeIterator(AbstractDocument doc,
                                       Node root,
                                       int whatToShow, 
                                       NodeFilter filter, 
                                       boolean entityReferenceExpansion)
    throws DOMException {
    if (root == null) {
        throw doc.createDOMException
            (DOMException.NOT_SUPPORTED_ERR, "null.root",  null);
    }
    NodeIterator result = new DOMNodeIterator(doc, root, whatToShow,
                                              filter,
                                              entityReferenceExpansion);
    if (iterators == null) {
        iterators = new LinkedList();
    }
    iterators.add(result);

    return result;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:24,代码来源:TraversalSupport.java

示例7: createBlockForSdt

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
public static DocumentFragment createBlockForSdt(FOConversionContext context, 
    		NodeIterator pPrNodeIt,
    		String pStyleVal, NodeIterator childResults, String tag) {
    	
    	DocumentFragment docfrag = createBlock(context,
        		 pPrNodeIt,
        		 pStyleVal,  childResults,
        		 true);
    	
    	// Set margins, but only for a shading container,
    	// not a borders container
    	if (tag.equals(Containerization.TAG_SHADING) && docfrag!=null) {
    		// docfrag.getNodeName() is  #document-fragment
    	    Node foBlock = docfrag.getFirstChild();
    	    if (foBlock!=null) {
				((Element)foBlock).setAttribute("margin-top", "0in");    	    	
				((Element)foBlock).setAttribute("margin-bottom", "0in");    	    	

//				((Element)foBlock).setAttribute("padding-top", "0in");    	    	
//				((Element)foBlock).setAttribute("padding-bottom", "0in");    	    	
    	    }
    	}
    	    
    	return docfrag;
    }
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:26,代码来源:XsltFOFunctions.java

示例8: evaluate

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
private boolean evaluate(byte[] data) {
    try {

        InputSource inputSource = new InputSource(new ByteArrayInputStream(data));

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder dbuilder = factory.newDocumentBuilder();
        Document doc = dbuilder.parse(inputSource);
        
        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
        XObject result = cachedXPathAPI.eval(doc, xpath);
        if (result.bool())
        	return true;
        else {
        	NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
        	return (iterator.nextNode() != null);
        }  

    } catch (Throwable e) {
        return false;
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:XalanXPathEvaluator.java

示例9: filterPunctuation

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
protected void filterPunctuation(MaryData d) {
    Document doc = d.getDocument();
    NodeIterator ni = ((DocumentTraversal) doc).createNodeIterator(doc, NodeFilter.SHOW_ELEMENT, new NameNodeFilter(
														    MaryXML.PARAGRAPH), false);
    Element p = null;
    while ((p = (Element) ni.nextNode()) != null) {
	Node textNode = p.getFirstChild();
	String s = textNode.getNodeValue();

	System.err.println("FilterPunctuation");
	System.err.println(s);

	s = s.replaceAll("،", ",");
	//s = s.replaceAll("XX", "YY");

	System.err.println(s);

	textNode.setNodeValue(s);
    }
}
 
开发者ID:HaraldBerthelsen,项目名称:marytts-lang-ar,代码行数:21,代码来源:JTokeniser.java

示例10: createNodeIterator

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * Create and return a NodeIterator. The NodeIterator is
 * added to a list of NodeIterators so that it can be
 * removed to free up the DOM Nodes it references.
 *
 * @param root The root of the iterator.
 * @param whatToShow The whatToShow mask.
 * @param filter The NodeFilter installed. Null means no filter.
 * @param entityReferenceExpansion true to expand the contents of
 *                                 EntityReference nodes
 * @since WD-DOM-Level-2-19990923
 */
public NodeIterator createNodeIterator(Node root,
                                       int whatToShow,
                                       NodeFilter filter,
                                       boolean entityReferenceExpansion)
{

    if (root == null) {
              String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
              throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
    }

    NodeIterator iterator = new NodeIteratorImpl(this,
                                                 root,
                                                 whatToShow,
                                                 filter,
                                                 entityReferenceExpansion);
    if (iterators == null) {
        iterators = new Vector();
    }

    iterators.addElement(iterator);

    return iterator;
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:37,代码来源:DocumentImpl.java

示例11: evaluate

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
protected boolean evaluate(InputSource inputSource) {
   try {
      DocumentBuilder dbuilder = createDocumentBuilder();
      Document doc = dbuilder.parse(inputSource);

      //An XPath expression could return a true or false value instead of a node.
      //eval() is a better way to determine the boolean value of the exp.
      //For compliance with legacy behavior where selecting an empty node returns true,
      //selectNodeIterator is attempted in case of a failure.

      CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
      XObject result = cachedXPathAPI.eval(doc, xpath);
      if (result.bool())
         return true;
      else {
         NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath);
         return (iterator.nextNode() != null);
      }
   } catch (Throwable e) {
      return false;
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:XalanXPathEvaluator.java

示例12: addNodes

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * Copy NodeList members into this nodelist, adding in
 * document order.  Null references are not added.
 *
 * @param iterator NodeIterator which yields the nodes to be added.
 * @throws RuntimeException thrown if this NodeSet is not of 
 * a mutable type.
 */
public void addNodes(NodeIterator iterator)
{

  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

  if (null != iterator)  // defensive to fix a bug that Sanjiva reported.
  {
    Node obj;

    while (null != (obj = iterator.nextNode()))
    {
      addElement(obj);
    }
  }

  // checkDups();
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:NodeSet.java

示例13: getPlainTextBelow

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
/**
 * Return the concatenation of the values of all text nodes below the given node. One space character is inserted between
 * adjacent text nodes.
 * 
 * @param n
 *            n
 * @return null if n is null
 */
public static String getPlainTextBelow(Node n) {
	if (n == null)
		return null;
	Document doc = null;
	if (n.getNodeType() == Node.DOCUMENT_NODE) {
		doc = (Document) n;
	} else {
		doc = n.getOwnerDocument();
	}
	StringBuilder buf = new StringBuilder();
	NodeIterator it = ((DocumentTraversal) doc).createNodeIterator(n, NodeFilter.SHOW_TEXT, null, true);
	Text text = null;
	while ((text = (Text) it.nextNode()) != null) {
		buf.append(text.getData().trim());
		buf.append(" ");
	}
	return buf.toString();
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:27,代码来源:DomUtils.java

示例14: parseParameters

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
public Map<String, Parameter> parseParameters(String response) throws KettleException{ 
	Map<String, Parameter> parameters = new HashMap<String, Parameter>(); 
	try{
	    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
	    dfactory.setNamespaceAware(false);
	    Document doc = dfactory.newDocumentBuilder().parse(new InputSource(new StringReader(response)));
	    	      
	    Node n;
	    NodeIterator nodeIt = XPathAPI.selectNodeIterator(doc, root_expr);
	    while ((n = nodeIt.nextNode())!= null){ 	    	
	    	parameters.put(XPathAPI.eval(n, NAME_EXPR).str(), parseParameter(n));
	    }
	} catch (Exception e) {
		throw new KettleException("Error retrieving parameters from WPS response...", e);
	}   
	return parameters;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:18,代码来源:ParameterBuilder.java

示例15: buildBoundingBoxFormat

import org.w3c.dom.traversal.NodeIterator; //导入依赖的package包/类
private AbstractFormat buildBoundingBoxFormat(Node n) throws JDOMException, KettleException, DOMException, TransformerException{
	List<String> crss = new ArrayList<String>();
	String default_crs = XPathAPI.eval(n, DEFAULT_CRS_EXPR).str();
	if(default_crs == null)
		default_crs = EMPTY;
	
	Node crs_node;
	NodeIterator nodeIt = XPathAPI.selectNodeIterator(n, SUPPORTED_CRSS_EXPR);
    while ((crs_node = nodeIt.nextNode())!= null){ 	    	
    	crss.add(crs_node.getNodeValue());
    }	
    
    boolean alreadyExists = false;
    for(String crs: crss){
    	if(crs.equals(default_crs)){
    		alreadyExists = true;
    		break;
    	}			
    }

    if(!alreadyExists && !default_crs.equals(EMPTY))
    	crss.add(default_crs);
    return new BoundingBoxFormat(crss, default_crs);
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:25,代码来源:ParameterBuilder.java


注:本文中的org.w3c.dom.traversal.NodeIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。