org.apache.avalon.framework.configuration
Class DefaultConfigurationBuilder
java.lang.Object
org.apache.avalon.framework.configuration.DefaultConfigurationBuilder
public class DefaultConfigurationBuilder
extends java.lang.Object
A DefaultConfigurationBuilder builds
Configuration
s from XML,
via a SAX2 compliant parser.
XML namespace support is optional, and disabled by default to preserve
backwards-compatibility. To enable it, pass the
DefaultConfigurationBuilder(boolean)
constructor the flag
true
, or pass
a namespace-enabled
XMLReader
to the
DefaultConfigurationBuilder(XMLReader)
constructor.
The mapping from XML namespaces to
Configuration
namespaces is pretty
straightforward, with one caveat: attribute namespaces are (deliberately) not
supported. Enabling namespace processing has the following effects:
- Attributes starting with
xmlns:
are interpreted as
declaring a prefix:namespaceURI mapping, and won't result in the creation of
xmlns
-prefixed attributes in the Configuration
.
-
Prefixed XML elements, like <doc:title xmlns:doc="http://foo.com">,
will result in a
Configuration
with getName()
.equals("title")
and getNamespace()
.equals("http://foo.com")
.
Whitespace handling. Since mixed content is not allowed in the
configurations, whitespace is completely discarded in non-leaf nodes.
For the leaf nodes the default behavior is to trim the space
surrounding the value. This can be changed by specifying
xml:space
attribute with value of
preserve
in that case the whitespace is left intact.
Version:
- Avalon Development Team
DefaultConfigurationBuilder
public DefaultConfigurationBuilder()
Create a Configuration Builder with a default XMLReader that ignores
namespaces. In order to enable namespaces, use either the constructor
that has a boolean or that allows you to pass in your own
namespace-enabled XMLReader.
DefaultConfigurationBuilder
public DefaultConfigurationBuilder(XMLReader parser)
Create a Configuration Builder with your own XMLReader.
parser
- an XMLReader
DefaultConfigurationBuilder
public DefaultConfigurationBuilder(boolean enableNamespaces)
Create a Configuration Builder, specifying a flag that determines
namespace support.
enableNamespaces
- If true
, a namespace-aware
SAXParser
is used. If false
, the default JAXP
SAXParser
(without namespace support) is used.
- 4.1
getHandler
protected SAXConfigurationHandler getHandler()
Get a SAXConfigurationHandler for your configuration reading.
- a
SAXConfigurationHandler
"Copyright B) 2001 Apache Jakarta Project. All Rights Reserved."