public void startElement(String uri,
			     String localName,
			     String qName,
			     Attributes a) throws SAXException {
	// always update the depth
	depth++;

	// if we're in an accepted section, simply pass through
	if (isAccepted()) {
	    getContentHandler().startElement(uri, localName, qName, a);
	    return;
	}

	// likewise, if we're excluded, then simply block and return
	if (isExcluded())
	    return;

	// now, not accepted or excluded, let's see if we've got a match.
	// we need to get the appropriate step based on the number of
	// steps we've previously accepted
	Step currentStep = (Step) steps.get(acceptedDepths.size());

	if (nodeMatchesStep(currentStep, uri, localName, qName, a)) {
	    if (DEBUG)
		System.err.println("*** Progressive match (" + acceptedDepths.size() + "): " + localName);
	    // new match (progressive)
	    acceptedDepths.push(Integer.valueOf(depth - 1));

	    // is it enough?  give acceptance another chance...
	    if (isAccepted())
	        getContentHandler().startElement(uri, localName, qName, a);
	} else if (!currentStep.isDepthUnlimited()) {
	    // if the step was preceded by '/' instead of '//', then
	    // we can't have a match at this node or beneath it
	    excludedDepth = depth - 1;
	}

	// nothing left to check; no reason to include node
        return;
    }
public void startElement ( String uri , String localName , String qName , Attributes a ) throws SAXException { depth ++ ; if ( isAccepted ( ) ) { getContentHandler ( ) . startElement ( uri , localName , qName , a ) ; return ; } if ( isExcluded ( ) ) return ; Step currentStep = ( Step ) steps . get ( acceptedDepths . size ( ) ) ; if ( nodeMatchesStep ( currentStep , uri , localName , qName , a ) ) { if ( DEBUG ) System . err . println ( "*** Progressive match (" + acceptedDepths . size ( ) + "): " + localName ) ; acceptedDepths . push ( Integer . valueOf ( depth - 1 ) ) ; if ( isAccepted ( ) ) getContentHandler ( ) . startElement ( uri , localName , qName , a ) ; } else if ( ! currentStep . isDepthUnlimited ( ) ) { excludedDepth = depth - 1 ; } return ; }
Filter for startElement().