org.cyberneko.html.filters
Class NamespaceBinder

java.lang.Object
  extended byorg.cyberneko.html.filters.DefaultFilter
      extended byorg.cyberneko.html.filters.NamespaceBinder
All Implemented Interfaces:
HTMLComponent, XMLComponent, XMLDocumentFilter, XMLDocumentHandler, XMLDocumentSource

public class NamespaceBinder
extends DefaultFilter

This filter binds namespaces if namespace processing is turned on by setting the feature "http://xml.org/sax/features/namespaces" is set to true.

This configuration recognizes the following features:

Version:
$Id$
Author:
Andy Clark

Nested Class Summary
static class NamespaceBinder.NamespaceSupport
          This namespace context object implements the old and new XNI NamespaceContext interface methods so that it can be used across all versions of Xerces2.
 
Field Summary
protected  boolean fInsertNamespaces
          Insert namespaces.
protected  short fNamesAttrs
          Modify HTML attribute names.
protected  short fNamesElems
          Modify HTML element names.
protected  NamespaceBinder.NamespaceSupport fNamespaceContext
          Namespace context.
protected  boolean fNamespacePrefixes
          Namespace prefixes.
protected  boolean fNamespaces
          Namespaces.
protected  String fNamespacesURI
          Namespaces URI.
protected  boolean fOverrideNamespaces
          Override namespaces.
protected static String INSERT_NAMESPACES
          Insert namespace binding URIs.
protected static String NAMES_ATTRS
          Modify HTML attribute names: { "upper", "lower", "default" }.
protected static String NAMES_ELEMS
          Modify HTML element names: { "upper", "lower", "default" }.
protected static short NAMES_LOWERCASE
          Lowercase HTML names.
protected static short NAMES_NO_CHANGE
          Don't modify HTML names.
protected static short NAMES_UPPERCASE
          Uppercase HTML names.
protected static String NAMESPACES
          Namespaces.
protected static String NAMESPACES_URI
          Namespaces URI.
protected static String OVERRIDE_NAMESPACES
          Override namespace binding URI.
static String XHTML_1_0_URI
          XHTML 1.0 namespace URI (http://www.w3.org/1999/xhtml).
 
Fields inherited from class org.cyberneko.html.filters.DefaultFilter
fDocumentHandler, fDocumentSource
 
Constructor Summary
NamespaceBinder()
           
 
Method Summary
protected  void bindNamespaces(QName element, XMLAttributes attrs)
          Binds namespaces.
 void emptyElement(QName element, XMLAttributes attrs, Augmentations augs)
          Empty element.
 void endElement(QName element, Augmentations augs)
          End element.
 Boolean getFeatureDefault(String featureId)
          Returns the default state for a feature, or null if this component does not want to report a default value for this feature.
protected static short getNamesValue(String value)
          Converts HTML names string value to constant value.
 Object getPropertyDefault(String propertyId)
          Returns the default value for a property, or null if this component does not want to report a default value for this property.
 String[] getRecognizedFeatures()
          Returns a list of feature identifiers that are recognized by this component.
 String[] getRecognizedProperties()
          Returns a list of property identifiers that are recognized by this component.
protected static String modifyName(String name, short mode)
          Modifies the given name based on the specified mode.
 void reset(XMLComponentManager manager)
          Resets the component.
protected static void splitQName(QName qname)
          Splits a qualified name.
 void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
          Start document.
 void startElement(QName element, XMLAttributes attrs, Augmentations augs)
          Start element.
 
Methods inherited from class org.cyberneko.html.filters.DefaultFilter
characters, comment, doctypeDecl, endCDATA, endDocument, endGeneralEntity, endPrefixMapping, getDocumentHandler, getDocumentSource, ignorableWhitespace, merge, processingInstruction, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, startDocument, startGeneralEntity, startPrefixMapping, textDecl, xmlDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XHTML_1_0_URI

public static final String XHTML_1_0_URI
XHTML 1.0 namespace URI (http://www.w3.org/1999/xhtml).

See Also:
Constant Field Values

NAMESPACES

protected static final String NAMESPACES
Namespaces.

See Also:
Constant Field Values

OVERRIDE_NAMESPACES

protected static final String OVERRIDE_NAMESPACES
Override namespace binding URI.

See Also:
Constant Field Values

INSERT_NAMESPACES

protected static final String INSERT_NAMESPACES
Insert namespace binding URIs.

See Also:
Constant Field Values

NAMES_ELEMS

protected static final String NAMES_ELEMS
Modify HTML element names: { "upper", "lower", "default" }.

See Also:
Constant Field Values

NAMES_ATTRS

protected static final String NAMES_ATTRS
Modify HTML attribute names: { "upper", "lower", "default" }.

See Also:
Constant Field Values

NAMESPACES_URI

protected static final String NAMESPACES_URI
Namespaces URI.

See Also:
Constant Field Values

NAMES_NO_CHANGE

protected static final short NAMES_NO_CHANGE
Don't modify HTML names.

See Also:
Constant Field Values

NAMES_UPPERCASE

protected static final short NAMES_UPPERCASE
Uppercase HTML names.

See Also:
Constant Field Values

NAMES_LOWERCASE

protected static final short NAMES_LOWERCASE
Lowercase HTML names.

See Also:
Constant Field Values

fNamespaces

protected boolean fNamespaces
Namespaces.


fNamespacePrefixes

protected boolean fNamespacePrefixes
Namespace prefixes.


fOverrideNamespaces

protected boolean fOverrideNamespaces
Override namespaces.


fInsertNamespaces

protected boolean fInsertNamespaces
Insert namespaces.


fNamesElems

protected short fNamesElems
Modify HTML element names.


fNamesAttrs

protected short fNamesAttrs
Modify HTML attribute names.


fNamespacesURI

protected String fNamespacesURI
Namespaces URI.


fNamespaceContext

protected final NamespaceBinder.NamespaceSupport fNamespaceContext
Namespace context.

Constructor Detail

NamespaceBinder

public NamespaceBinder()
Method Detail

getRecognizedFeatures

public String[] getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by this component. This method may return null if no features are recognized by this component.

Specified by:
getRecognizedFeatures in interface XMLComponent
Overrides:
getRecognizedFeatures in class DefaultFilter

getFeatureDefault

public Boolean getFeatureDefault(String featureId)
Returns the default state for a feature, or null if this component does not want to report a default value for this feature.

Specified by:
getFeatureDefault in interface HTMLComponent
Overrides:
getFeatureDefault in class DefaultFilter

getRecognizedProperties

public String[] getRecognizedProperties()
Returns a list of property identifiers that are recognized by this component. This method may return null if no properties are recognized by this component.

Specified by:
getRecognizedProperties in interface XMLComponent
Overrides:
getRecognizedProperties in class DefaultFilter

getPropertyDefault

public Object getPropertyDefault(String propertyId)
Returns the default value for a property, or null if this component does not want to report a default value for this property.

Specified by:
getPropertyDefault in interface HTMLComponent
Overrides:
getPropertyDefault in class DefaultFilter

reset

public void reset(XMLComponentManager manager)
           throws XMLConfigurationException
Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Specified by:
reset in interface XMLComponent
Overrides:
reset in class DefaultFilter
Parameters:
manager - The component manager.
Throws:
XNIException - Thrown by component on initialization error.
XMLConfigurationException

startDocument

public void startDocument(XMLLocator locator,
                          String encoding,
                          NamespaceContext nscontext,
                          Augmentations augs)
                   throws XNIException
Start document.

Specified by:
startDocument in interface XMLDocumentHandler
Overrides:
startDocument in class DefaultFilter
Throws:
XNIException

startElement

public void startElement(QName element,
                         XMLAttributes attrs,
                         Augmentations augs)
                  throws XNIException
Start element.

Specified by:
startElement in interface XMLDocumentHandler
Overrides:
startElement in class DefaultFilter
Throws:
XNIException

emptyElement

public void emptyElement(QName element,
                         XMLAttributes attrs,
                         Augmentations augs)
                  throws XNIException
Empty element.

Specified by:
emptyElement in interface XMLDocumentHandler
Overrides:
emptyElement in class DefaultFilter
Throws:
XNIException

endElement

public void endElement(QName element,
                       Augmentations augs)
                throws XNIException
End element.

Specified by:
endElement in interface XMLDocumentHandler
Overrides:
endElement in class DefaultFilter
Throws:
XNIException

splitQName

protected static void splitQName(QName qname)
Splits a qualified name.


getNamesValue

protected static final short getNamesValue(String value)
Converts HTML names string value to constant value.

See Also:
NAMES_NO_CHANGE, NAMES_LOWERCASE, NAMES_UPPERCASE

modifyName

protected static final String modifyName(String name,
                                         short mode)
Modifies the given name based on the specified mode.


bindNamespaces

protected void bindNamespaces(QName element,
                              XMLAttributes attrs)
Binds namespaces.



(C) Copyright 2002-2004, Andy Clark. All rights reserved.