FileDocCategorySizeDatePackage
SAXDocumentBuilder.javaAPI DocGlassfish v2 API5245Tue May 22 16:54:48 BST 2007oracle.toplink.essentials.platform.xml

SAXDocumentBuilder

public class SAXDocumentBuilder extends Object implements ContentHandler

Fields Summary
private Document
document
private Stack
nodes
private XMLPlatform
xmlPlatform
Constructors Summary
public SAXDocumentBuilder()


      
        super();
        nodes = new Stack();
        xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    
Methods Summary
public voidcharacters(char[] ch, int start, int length)

        String characters = new String(ch, start, length);
        if (characters.trim().length() == 0) {
            return;
        }
        Text text = getInitializedDocument().createTextNode(characters);
        Node parentNode = (Node)nodes.peek();
        parentNode.appendChild(text);
    
public voidendDocument()

        nodes.pop();
    
public voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)

        nodes.pop();
    
public voidendPrefixMapping(java.lang.String prefix)

    
public org.w3c.dom.DocumentgetDocument()

        return document;
    
public org.w3c.dom.DocumentgetInitializedDocument()

        if (document == null) {
            try {
                document = xmlPlatform.createDocument();
                nodes.push(document);
            } catch (Exception e) {
                throw new SAXException(e);
            }
        }
        return document;
    
public voidignorableWhitespace(char[] ch, int start, int length)

    
public voidprocessingInstruction(java.lang.String target, java.lang.String data)

        ProcessingInstruction pi = getInitializedDocument().createProcessingInstruction(target, data);
        Node parentNode = (Node)nodes.peek();
        parentNode.appendChild(pi);
    
public voidsetDocumentLocator(org.xml.sax.Locator locator)

    
public voidskippedEntity(java.lang.String name)

    
public voidstartDocument()

        try {
            document = xmlPlatform.createDocument();
            nodes.push(document);
        } catch (Exception e) {
            throw new SAXException(e);
        }
    
public voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)

        if ((null != namespaceURI) && ("".equals(namespaceURI))) {
            namespaceURI = null;
        }
        Element element = getInitializedDocument().createElementNS(namespaceURI, qName);
        Node parentNode = (Node)nodes.peek();
        parentNode.appendChild(element);
        nodes.push(element);

        int numberOfAttributes = atts.getLength();
        Attr attribute;
        for (int x = 0; x < numberOfAttributes; x++) {
            element.setAttributeNS(atts.getURI(x), atts.getQName(x), atts.getValue(x));
        }
    
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)