Example usage for org.apache.commons.digester Digester getNamespaceAware

List of usage examples for org.apache.commons.digester Digester getNamespaceAware

Introduction

In this page you can find the example usage for org.apache.commons.digester Digester getNamespaceAware.

Prototype

public boolean getNamespaceAware() 

Source Link

Document

Return the "namespace aware" flag for parsers we create.

Usage

From source file:org.xchain.framework.digester.SerializationRule.java

public void begin(String namespaceUri, String name, Attributes attributes) throws Exception {
    // get the digester.
    Digester digester = getDigester();

    // store the old content handlers.
    oldCustomContentHandler = digester.getCustomContentHandler();
    if (digester instanceof ExtendedDigester) {
        oldCustomLexicalHandler = ((ExtendedDigester) digester).getCustomLexicalHandler();
    }//from  w ww.j av a 2 s  .  c o m

    // create the handler.
    handler = new RuleSerializationHandler();

    // set up the handlers that will do the serialization.
    handler.setWrappedHandler(newHandler());

    // set the new handlers.
    digester.setCustomContentHandler(handler);
    if (digester instanceof ExtendedDigester) {
        ((ExtendedDigester) digester).setCustomLexicalHandler(handler);
    }

    // push the buffer onto the stack.
    digester.push(buffer);

    // start the document.
    handler.startDocument();

    // set all of the namespaces that are defined on the digester.
    Iterator currentNamespaceIterator = digester.getCurrentNamespaces().entrySet().iterator();
    while (currentNamespaceIterator.hasNext()) {
        Map.Entry currentNamespace = (Map.Entry) currentNamespaceIterator.next();
        handler.startPrefixMapping((String) currentNamespace.getKey(), (String) currentNamespace.getValue());
    }

    // send the current element to the handler.
    if (digester.getNamespaceAware()) {
        handler.startElement(namespaceUri, name, digester.getCurrentElementName(), attributes);
    } else {
        handler.startElement(namespaceUri, name, name, attributes);
    }
}