Code example for NamespaceSupport

Methods: popContextpushContext

0
    public void startElement (String uri, String localName,
                              String qName, Attributes atts)
        throws SAXException 
    { 
        elementLevel++;
        nsSupport.pushContext();
	if (forceDTD && !hasOutputDTD) startDTD(localName == null ? qName : localName, "", "");
        write('<'); 
        writeName(uri, localName, qName, true);
        writeAttributes(atts);
        if (elementLevel == 1) {
            forceNSDecls(); 
        } 
        writeNSDecls(); 
        write('>'); 
//	System.out.println("%%%% startElement [" + qName + "] htmlMode = " + htmlMode); 
	if (htmlMode && (qName.equals("script") || qName.equals("style"))) {
                cdataElement = true;
//		System.out.println("%%%% CDATA element"); 
                } 
        super.startElement(uri, localName, qName, atts);
    } 
 
 
    /** 
     * Write an end tag. 
     * 
     * Pass the event on down the filter chain for further processing. 
     * 
     * @param uri The Namespace URI, or the empty string if none 
     *        is available. 
     * @param localName The element's local (unprefixed) name (required). 
     * @param qName The element's qualified (prefixed) name, or the 
     *        empty string is none is available.  This method will 
     *        use the qName as a template for generating a prefix 
     *        if necessary, but it is not guaranteed to use the 
     *        same qName. 
     * @exception org.xml.sax.SAXException If there is an error 
     *            writing the end tag, or if a handler further down 
     *            the filter chain raises an exception. 
     * @see org.xml.sax.ContentHandler#endElement 
     */ 
    public void endElement (String uri, String localName, String qName)
        throws SAXException 
    { 
	if (!(htmlMode &&
            (uri.equals("http://www.w3.org/1999/xhtml") ||
		uri.equals("")) &&
            (qName.equals("area") || qName.equals("base") ||
            qName.equals("basefont") || qName.equals("br") ||
            qName.equals("col") || qName.equals("frame") ||
            qName.equals("hr") || qName.equals("img") ||
            qName.equals("input") || qName.equals("isindex") ||
            qName.equals("link") || qName.equals("meta") ||
            qName.equals("param")))) {
                write("</"); 
                writeName(uri, localName, qName, true);
                write('>'); 
            } 
        if (elementLevel == 1) {
            write('\n'); 
        } 
        cdataElement = false;
        super.endElement(uri, localName, qName);
        nsSupport.popContext();
        elementLevel--;
    } 
     
 
    /** 
Connect your IDE to all the code out there  Get Codota for Java