Java Code Examples for org.w3c.dom.Node#getFirstChild()

The following examples show how to use org.w3c.dom.Node#getFirstChild() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private static boolean hasChildren(Node n) {
    Node dataNodeN = n.getAttributes().getNamedItemNS(XFA_DATA_SCHEMA, "dataNode");
    if (dataNodeN != null) {
        String dataNode = dataNodeN.getNodeValue();
        if ("dataGroup".equals(dataNode))
            return true;
        else if ("dataValue".equals(dataNode))
            return false;
    }
    if (!n.hasChildNodes())
        return false;
    Node n2 = n.getFirstChild();
    while (n2 != null) {
        if (n2.getNodeType() == Node.ELEMENT_NODE) {
            return true;
        }
        n2 = n2.getNextSibling();
    }
    return false;
}
 
Example 2
Source Project: hottub   File: DOMUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** Finds and returns the first child node with the given qualified name. */
public static Element getFirstChildElementNS(Node parent,
        String uri, String localpart) {

    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String childURI = child.getNamespaceURI();
            if (childURI != null && childURI.equals(uri) &&
                    child.getLocalName().equals(localpart)) {
                return (Element)child;
            }
        }
        child = child.getNextSibling();
    }

    // not found
    return null;

}
 
Example 3
Source Project: jdk8u60   File: DOMUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** Finds and returns the first child node with the given name. */
public static Element getFirstChildElement(Node parent, String elemName) {

    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            if (child.getNodeName().equals(elemName)) {
                return (Element)child;
            }
        }
        child = child.getNextSibling();
    }

    // not found
    return null;

}
 
Example 4
Source Project: L2jOrg   File: ZoneManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
private ZoneArea parsePolygon(Node polygonNode) throws InvalidZoneException {
    IntList xPoints = new ArrayIntList();
    IntList yPoints = new ArrayIntList();

    for (Node node = polygonNode.getFirstChild(); node != null; node = node.getNextSibling()) {
        if ("point".equalsIgnoreCase(node.getNodeName())) {
            var attr = node.getAttributes();
            xPoints.add(parseInteger(attr, "x"));
            yPoints.add(parseInteger(attr, "y"));
        }
    }
    if(xPoints.size() < 3) {
        throw new InvalidZoneException("The Zone with Polygon form must have at least 3 points");
    }

    var attributes = polygonNode.getAttributes();
    var minZ = parseInteger(attributes, "min-z");
    var maxZ = parseInteger(attributes, "max-z");
    return new ZonePolygonArea(xPoints.toArray(int[]::new), yPoints.toArray(int[]::new), minZ, maxZ);
}
 
Example 5
Source Project: L2jOrg   File: SpawnsData.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void parseLocations(Node n, NpcSpawnTemplate npcTemplate) {
    for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
        if ("location".equalsIgnoreCase(d.getNodeName())) {
            final int x = parseInteger(d.getAttributes(), "x");
            final int y = parseInteger(d.getAttributes(), "y");
            final int z = parseInteger(d.getAttributes(), "z");
            final int heading = parseInteger(d.getAttributes(), "heading", 0);
            final double chance = parseDouble(d.getAttributes(), "chance");
            npcTemplate.addSpawnLocation(new ChanceLocation(x, y, z, heading, chance));
        }
    }
}
 
Example 6
Source Project: jdk8u60   File: TreeWalker.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Perform a pre-order traversal non-recursive style.

 * Note that TreeWalker assumes that the subtree is intended to represent
 * a complete (though not necessarily well-formed) document and, during a
 * traversal, startDocument and endDocument will always be issued to the
 * SAX listener.
 *
 * @param pos Node in the tree where to start traversal
 * @param top Node in the tree where to end traversal
 *
 * @throws TransformerException
 */
public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
{

      this.m_contentHandler.startDocument();

  while (null != pos)
  {
    startNode(pos);

    Node nextNode = pos.getFirstChild();

    while (null == nextNode)
    {
      endNode(pos);

      if ((null != top) && top.equals(pos))
        break;

      nextNode = pos.getNextSibling();

      if (null == nextNode)
      {
        pos = pos.getParentNode();

        if ((null == pos) || ((null != top) && top.equals(pos)))
        {
          nextNode = null;

          break;
        }
      }
    }

    pos = nextNode;
  }
  this.m_contentHandler.endDocument();
}
 
Example 7
Source Project: RADL   File: XmlMerger.java    License: Apache License 2.0 5 votes vote down vote up
private void duplicate(Element node, Node parent) {
  if (parent instanceof Document && parent.getFirstChild() != null) {
    parent.removeChild(parent.getFirstChild());
  }
  Node importedNode = getDocument(parent).importNode(node, true);
  // TODO: documentation should be first element -> introduce XmlMergeRules interface
  parent.appendChild(importedNode);
}
 
Example 8
Source Project: pentaho-kettle   File: CarteIT.java    License: Apache License 2.0 5 votes vote down vote up
public static void print( Node node, String indent ) {
  // System.out.println(indent + node.getClass().getName());
  if ( node.getNodeType() == Node.TEXT_NODE && !StringUtils.isEmpty( node.getTextContent().trim() ) ) {
    System.out.println( node.getParentNode().getNodeName() );
    System.out.println( node.getNodeName() + node.getTextContent() );
  }
  Node child = node.getFirstChild();
  while ( child != null ) {
    print( child, indent + " " );
    child = child.getNextSibling();
  }
}
 
Example 9
Source Project: javaide   File: SdkStats.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the first child element with the given XML local name.
 * If xmlLocalName is null, returns the very first child element.
 */
private Node getFirstChild(Node node, String nsUri, String xmlLocalName) {

    for(Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
        if (child.getNodeType() == Node.ELEMENT_NODE &&
                nsUri.equals(child.getNamespaceURI())) {
            if (xmlLocalName == null || child.getLocalName().equals(xmlLocalName)) {
                return child;
            }
        }
    }

    return null;
}
 
Example 10
@Override
public void parseScript(Node eventNode, BSFManager context)
   {
       String ID = attribute(eventNode, "ID");

       if (DEBUG) _log.fine("Parsing Event \""+ID+"\"");

       _eventDates = DateRange.parse(attribute(eventNode, "Active"), DATE_FORMAT);

       Date currentDate = new Date();
       if (_eventDates.getEndDate().before(currentDate))
       {
           _log.warning("Event ID: (" + ID + ") has passed... Ignored.");
           return;
       }

       for (Node node = eventNode.getFirstChild(); node != null; node = node.getNextSibling()) {

           if (isNodeName(node, "DropList"))
           {
               parseEventDropList(node);
           }
           else if (isNodeName(node, "Message"))
           {
               parseEventMessage(node);
           }
       }
   }
 
Example 11
/**
 * @param sibling
 * @param nodeName
 * @param number
 * @return nodes with the constrain
 */
public static Text selectDs11NodeText(Node sibling, String nodeName, int number) {
    Node n = selectDs11Node(sibling,nodeName,number);
    if (n == null) {
        return null;
    }
    n = n.getFirstChild();
    while (n != null && n.getNodeType() != Node.TEXT_NODE) {
        n = n.getNextSibling();
    }
    return (Text)n;
}
 
Example 12
@SuppressWarnings("fallthrough")
private static void getSetRec(final Node rootNode, final Set<Node> result,
                            final Node exclude, final boolean com) {
    if (rootNode == exclude) {
        return;
    }
    switch (rootNode.getNodeType()) {
    case Node.ELEMENT_NODE:
        result.add(rootNode);
        Element el = (Element)rootNode;
        if (el.hasAttributes()) {
            NamedNodeMap nl = el.getAttributes();
            for (int i = 0;i < nl.getLength(); i++) {
                result.add(nl.item(i));
            }
        }
        //no return keep working
    case Node.DOCUMENT_NODE:
        for (Node r = rootNode.getFirstChild(); r != null; r = r.getNextSibling()) {
            if (r.getNodeType() == Node.TEXT_NODE) {
                result.add(r);
                while ((r != null) && (r.getNodeType() == Node.TEXT_NODE)) {
                    r = r.getNextSibling();
                }
                if (r == null) {
                    return;
                }
            }
            getSetRec(r, result, exclude, com);
        }
        return;
    case Node.COMMENT_NODE:
        if (com) {
            result.add(rootNode);
        }
        return;
    case Node.DOCUMENT_TYPE_NODE:
        return;
    default:
        result.add(rootNode);
    }
}
 
Example 13
Source Project: dn-modbus   File: UnityModbus.java    License: Apache License 2.0 4 votes vote down vote up
void initControllerFromXmlById(int controllerId) {

		// 清除这个controller然后重新添加
		controllers.remove(controllerId);

		String path = System.getProperty("user.dir") + "/xml/";

		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

		try {
			DocumentBuilder db = dbf.newDocumentBuilder();

			List<File> files = CommonUtil.getFiles(path);

			for (int i = 0; i < files.size(); i++) {
				Document doc = db.parse(files.get(i));

				Element rootEle = doc.getDocumentElement();

				String id = rootEle.getAttribute("id");

				if (Integer.parseInt(id) == controllerId) {
					NodeList registers = doc.getElementsByTagName("register");

					String mode = doc.getElementsByTagName("mode").item(0)
							.getFirstChild().getNodeValue();
					String controller = doc.getElementsByTagName("ctorName")
							.item(0).getFirstChild().getNodeValue();
					String ip = doc.getElementsByTagName("ip").item(0)
							.getFirstChild().getNodeValue();
					String port = doc.getElementsByTagName("port").item(0)
							.getFirstChild().getNodeValue();

					Map<Integer, RegisterEntity> map = new HashMap<Integer, RegisterEntity>();
					ControllerEntity ce = new ControllerEntity();
					if (mode.toLowerCase().equals("simulateandforwarding")) {
						ce.setMode(SimulationMode.SimulateAndForwarding);
					} else {
						ce.setMode(SimulationMode.SimulateOnly);
					}

					BaseController ctor = (BaseController) Class.forName(
							controller).newInstance();

					// 启动每个controller的线程
					Thread demo = new Thread(ctor);
					demo.start();

					ce.setController(ctor);
					ce.setIp(ip);
					ce.setPort(Integer.parseInt(port));
					ce.setId(Integer.parseInt(id));
					ce.setRegisters(map);

					for (int j = 0; j < registers.getLength(); j++) {
						Node register = registers.item(j);
						RegisterEntity re = new RegisterEntity();

						for (Node node = register.getFirstChild(); node != null; node = node
								.getNextSibling()) {
							if (node.getNodeType() == Node.ELEMENT_NODE) {
								String name = node.getNodeName();
								String value = node.getFirstChild()
										.getNodeValue();

								if (name.equals("address")) {
									re.setAddress(Integer.parseInt(value));
								} else if (name.equals("defaultValue")) {
									re.setValue(Integer.parseInt(value));
								} else {
									re.setType(value);
								}
							}
						}

						map.put(re.getAddress(), re);
					}

					controllers.put(Integer.parseInt(id), ctor);
				}

			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
Example 14
/**
 * Recursively traverses the subtree, and returns an XPath-equivalent
 * node-set of all nodes traversed, excluding any comment nodes,
 * if specified.
 *
 * @param node the node to traverse
 * @param nodeSet the set of nodes traversed so far
 * @param the previous sibling node
 */
@SuppressWarnings("fallthrough")
private void nodeSetMinusCommentNodes(Node node, List<Node> nodeSet,
                                      Node prevSibling)
{
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE :
            NamedNodeMap attrs = node.getAttributes();
            if (attrs != null) {
                for (int i = 0, len = attrs.getLength(); i < len; i++) {
                    nodeSet.add(attrs.item(i));
                }
            }
            nodeSet.add(node);
            Node pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.DOCUMENT_NODE :
            pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE:
            // emulate XPath which only returns the first node in
            // contiguous text/cdata nodes
            if (prevSibling != null &&
                (prevSibling.getNodeType() == Node.TEXT_NODE ||
                 prevSibling.getNodeType() == Node.CDATA_SECTION_NODE)) {
                return;
            }
            nodeSet.add(node);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE :
            nodeSet.add(node);
            break;
        case Node.COMMENT_NODE:
            if (withComments) {
                nodeSet.add(node);
            }
    }
}
 
Example 15
/**
 * Creates a {@code TIFFField} from a TIFF native image
 * metadata node. If the value of the {@code "number"} attribute
 * of the node is not found in {@code tagSet} then a new
 * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME}
 * will be created and assigned to the field.
 *
 * @param tagSet The {@code TIFFTagSet} to which the
 * {@code TIFFTag} of the field belongs.
 * @param node A native TIFF image metadata {@code TIFFField} node.
 * @throws IllegalArgumentException If the {@code Node} parameter content
 * does not adhere to the {@code TIFFField} element structure defined by
 * the <a href="../../metadata/doc-files/tiff_metadata.html#ImageMetadata">
 * TIFF native image metadata format specification</a>, or if the
 * combination of node attributes and data is not legal per the
 * {@link #TIFFField(TIFFTag,int,int,Object)} constructor specification.
 * Note that a cause might be set on such an exception.
 * @return A new {@code TIFFField}.
 */
public static TIFFField createFromMetadataNode(TIFFTagSet tagSet,
                                               Node node) {
    if (node == null) {
        // This method is specified to throw only IllegalArgumentExceptions
        // so we create an IAE with a NullPointerException as its cause.
        throw new IllegalArgumentException(new NullPointerException
            ("node == null!"));
    }
    String name = node.getNodeName();
    if (!name.equals("TIFFField")) {
        throw new IllegalArgumentException("!name.equals(\"TIFFField\")");
    }

    int tagNumber = Integer.parseInt(getAttribute(node, "number"));
    TIFFTag tag = null;
    if (tagSet != null) {
        tag = tagSet.getTag(tagNumber);
    }

    int type = TIFFTag.TIFF_UNDEFINED;
    int count = 0;
    Object data = null;

    Node child = node.getFirstChild();
    if (child != null) {
        String typeName = child.getNodeName();
        if (typeName.equals("TIFFUndefined")) {
            String values = getAttribute(child, "value");
            StringTokenizer st = new StringTokenizer(values, ",");
            count = st.countTokens();

            byte[] bdata = new byte[count];
            for (int i = 0; i < count; i++) {
                bdata[i] = (byte)Integer.parseInt(st.nextToken());
            }

            type = TIFFTag.TIFF_UNDEFINED;
            data = bdata;
        } else {
            int[] otype = new int[1];
            int[] ocount = new int[1];
            Object[] odata = new Object[1];

            initData(node.getFirstChild(), otype, ocount, odata);
            type = otype[0];
            count = ocount[0];
            data = odata[0];
        }
    } else if (tag != null) {
        int t = TIFFTag.MAX_DATATYPE;
        while(t >= TIFFTag.MIN_DATATYPE && !tag.isDataTypeOK(t)) {
            t--;
        }
        type = t;
    }

    if (tag == null) {
        tag = new TIFFTag(TIFFTag.UNKNOWN_TAG_NAME, tagNumber, 1 << type);
    }

    TIFFField field;
    try {
        field = new TIFFField(tag, type, count, data);
    } catch (NullPointerException npe) {
        // This method is specified to throw only IllegalArgumentExceptions
        // so we catch the NullPointerException and set it as the cause of
        // the IAE which is thrown.
        throw new IllegalArgumentException(npe);
    }

    return field;
}
 
Example 16
/**
 * Recursively traverses the subtree, and returns an XPath-equivalent
 * node-set of all nodes traversed, excluding any comment nodes,
 * if specified.
 *
 * @param node the node to traverse
 * @param nodeSet the set of nodes traversed so far
 * @param the previous sibling node
 */
@SuppressWarnings("fallthrough")
private void nodeSetMinusCommentNodes(Node node, List<Node> nodeSet,
                                      Node prevSibling)
{
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE :
            nodeSet.add(node);
            NamedNodeMap attrs = node.getAttributes();
            if (attrs != null) {
                for (int i = 0, len = attrs.getLength(); i < len; i++) {
                    nodeSet.add(attrs.item(i));
                }
            }
            Node pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.DOCUMENT_NODE :
            pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE:
            // emulate XPath which only returns the first node in
            // contiguous text/cdata nodes
            if (prevSibling != null &&
                (prevSibling.getNodeType() == Node.TEXT_NODE ||
                 prevSibling.getNodeType() == Node.CDATA_SECTION_NODE)) {
                return;
            }
            nodeSet.add(node);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE :
            nodeSet.add(node);
            break;
        case Node.COMMENT_NODE:
            if (withComments) {
                nodeSet.add(node);
            }
    }
}
 
Example 17
Source Project: iaf   File: DomTreeAligner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String getNodeText(XSElementDeclaration elementDeclaration, Node node) {
	Node childNode=node.getFirstChild();
	return childNode==null?null:childNode.getNodeValue();
}
 
Example 18
/**
 * Recursively traverses the subtree, and returns an XPath-equivalent
 * node-set of all nodes traversed, excluding any comment nodes,
 * if specified.
 *
 * @param node the node to traverse
 * @param nodeSet the set of nodes traversed so far
 * @param the previous sibling node
 */
@SuppressWarnings("fallthrough")
private void nodeSetMinusCommentNodes(Node node, List<Node> nodeSet,
                                      Node prevSibling)
{
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE :
            NamedNodeMap attrs = node.getAttributes();
            if (attrs != null) {
                for (int i = 0, len = attrs.getLength(); i < len; i++) {
                    nodeSet.add(attrs.item(i));
                }
            }
            nodeSet.add(node);
            Node pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.DOCUMENT_NODE :
            pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE:
            // emulate XPath which only returns the first node in
            // contiguous text/cdata nodes
            if (prevSibling != null &&
                (prevSibling.getNodeType() == Node.TEXT_NODE ||
                 prevSibling.getNodeType() == Node.CDATA_SECTION_NODE)) {
                return;
            }
            nodeSet.add(node);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE :
            nodeSet.add(node);
            break;
        case Node.COMMENT_NODE:
            if (withComments) {
                nodeSet.add(node);
            }
    }
}
 
Example 19
Source Project: netbeans   File: HudsonConnector.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Gets general information about a build.
 * The changelog ({@code <changeSet>}) can be interpreted separately by {@link HudsonJobBuild#getChanges}.
 */
@Override
public Collection<BuildData> getJobBuildsData(HudsonJob job) {
    Document docBuild = getDocument(job.getUrl() + XML_API_URL + (canUseTree(true) ?
        "?tree=builds[number,result,building]" :
        "?xpath=/*/build&wrapper=root&exclude=//url"), true);
    if (docBuild == null) {
        return Collections.emptySet();
    }
    List<BuildData> builds = new ArrayList<BuildData>();
    NodeList buildNodes = docBuild.getElementsByTagName("build"); // NOI18N // HUDSON-3267: might be root elt
    for (int i = 0; i < buildNodes.getLength(); i++) {
        Node build = buildNodes.item(i);
        int number = 0;
        boolean building = false;
        Result result = null;
        NodeList details = build.getChildNodes();
        for (int j = 0; j < details.getLength(); j++) {
            Node detail = details.item(j);
            if (detail.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            String nodeName = detail.getNodeName();
            Node firstChild = detail.getFirstChild();
            if (firstChild == null) {
                LOG.log(Level.WARNING, "#170267: unexpected empty <build> child: {0}", nodeName);
                continue;
            }
            String text = firstChild.getTextContent();
            if (nodeName.equals("number")) { // NOI18N
                number = Integer.parseInt(text);
            } else if (nodeName.equals("building")) { // NOI18N
                building = Boolean.valueOf(text);
            } else if (nodeName.equals("result")) { // NOI18N
                result = Result.valueOf(text);
            } else {
                LOG.log(Level.WARNING, "unexpected <build> child: {0}", nodeName);
            }
        }
        builds.add(new BuildData(number, result, building));
    }
    return builds;
}
 
Example 20
/**
 * Recursively traverses the subtree, and returns an XPath-equivalent
 * node-set of all nodes traversed, excluding any comment nodes,
 * if specified.
 *
 * @param node the node to traverse
 * @param nodeSet the set of nodes traversed so far
 * @param the previous sibling node
 */
@SuppressWarnings("fallthrough")
private void nodeSetMinusCommentNodes(Node node, List<Node> nodeSet,
                                      Node prevSibling)
{
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE :
            NamedNodeMap attrs = node.getAttributes();
            if (attrs != null) {
                for (int i = 0, len = attrs.getLength(); i < len; i++) {
                    nodeSet.add(attrs.item(i));
                }
            }
            nodeSet.add(node);
            Node pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.DOCUMENT_NODE :
            pSibling = null;
            for (Node child = node.getFirstChild(); child != null;
                child = child.getNextSibling()) {
                nodeSetMinusCommentNodes(child, nodeSet, pSibling);
                pSibling = child;
            }
            break;
        case Node.TEXT_NODE :
        case Node.CDATA_SECTION_NODE:
            // emulate XPath which only returns the first node in
            // contiguous text/cdata nodes
            if (prevSibling != null &&
                (prevSibling.getNodeType() == Node.TEXT_NODE ||
                 prevSibling.getNodeType() == Node.CDATA_SECTION_NODE)) {
                return;
            }
            nodeSet.add(node);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE :
            nodeSet.add(node);
            break;
        case Node.COMMENT_NODE:
            if (withComments) {
                nodeSet.add(node);
            }
    }
}