當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。