public void startElement()

in ch-commons-xbean/src/main/java/com/cloudhopper/commons/xml/XmlParser.java [279:357]


        public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
            // figure out tag
            String tag = (uri == null || uri.equals("")) ? qName : localName;

            // debug
            //logger.trace("startElement: tag=" + tag);

            // always increment our depth
            depth++;

            //
            // if NOOP, then skip
            //
            if (noop) {
                //logger.trace("in noop mode, skipping this element");
                return;
            }

            // create the current node we're parsing
            Node node = new Node(tag, attrs);

            // always set the new node's parent to the current context
            // if this happens to be the root node, then it'll be null
            node.setParent(context);

            // debug
            //logger.trace("node: " + tag + ", path: " + node.getPath());

            //
            // is this node in our excludeXPath?
            //
            if (excludeXPaths != null && excludeXPaths.size() > 0) {
                String path = node.getPath();
                boolean match = false;
                for (int i = 0; !match && i < excludeXPaths.size(); i++) {
                    XPath xpath = excludeXPaths.get(i);
                    match = xpath.matches(path, false);

                }
                // if there was a match, then we want to exclude this node and any children nodes
                if (match) {
                    //logger.debug("turning on noop mode (due to exclusion match)");
                    noop = true;
                    noopDepth = depth;
                    return;
                }
            }

            //
            // is this node in our includeXPath list?
            //
            if (includeXPaths != null && includeXPaths.size() > 0) {
                String path = node.getPath();
                boolean match = false;
                for (int i = 0; !match && i < includeXPaths.size(); i++) {
                    XPath xpath = includeXPaths.get(i);
                    match = xpath.matches(path);

                }
                // if no match, then we do NOT want to include this node
                if (!match) {
                    //logger.debug("turning on noop mode (due to NO inclusion match)");
                    noop = true;
                    noopDepth = depth;
                    return;
                }
            }

            // is this the first node (root)?
            if (depth == 0) {
                root = node;
            } else {
                // add this node as a child to the current context
                context.addChild(node);    
            }
      
            // we're done, so set the current context to the current node
            context = node;
        }