public class NamespaceAndElementFilter
extends org.xml.sax.helpers.XMLFilterImpl
The filter will bypass only the main element being parsed (such as the AppHdr or Document), ignoring any other sibling or parent content such as a transmission envelope. Then within the main element being processed, only the content with a recognized namespace is propagated, meaning for example any supplementary data with Any in the schema will not be parsed.
Regarding the namespace, two different behaviours are supported; bounded or unbounded.
By default the filter will unbind the propagated elements from its namespace. This is done by filtering out the namespace declaration and optional associated prefix. This is useful and actually required when the filter is used by the message parser. When parsing the Document or AppHdr for an MX, we have to unbind the main message namespace because the generated jaxb model for element types is shared and not bounded to any specific message type. Meaning we don't have duplicated type classes for each message they appear in, instead we have single non-repetitive types with no namespace.
By constructor parameter, the namespace unbinding can also be switched off to let the elements namespace binding untouched. This is useful when the filter is used in the context of a validation against schema.
| Constructor and Description |
|---|
NamespaceAndElementFilter(java.lang.String localName) |
NamespaceAndElementFilter(java.lang.String localName,
boolean unbindNamespace)
Creates the filter with an option to unbinds or not the namespace from the propagated elements
|
| Modifier and Type | Method and Description |
|---|---|
void |
endElement(java.lang.String namespace,
java.lang.String localName,
java.lang.String prefix) |
void |
startElement(java.lang.String namespace,
java.lang.String localName,
java.lang.String prefix,
org.xml.sax.Attributes attributes) |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String url) |
characters, endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, unparsedEntityDecl, warningpublic NamespaceAndElementFilter(java.lang.String localName)
localName - the XML's element to propagatepublic NamespaceAndElementFilter(java.lang.String localName,
boolean unbindNamespace)
localName - the XML's element to propagateunbindNamespace - true to filter out the namespace declaration and optional associated prefixpublic void startElement(java.lang.String namespace,
java.lang.String localName,
java.lang.String prefix,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.XMLFilterImplorg.xml.sax.SAXExceptionpublic void endElement(java.lang.String namespace,
java.lang.String localName,
java.lang.String prefix)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.XMLFilterImplorg.xml.sax.SAXExceptionpublic void startPrefixMapping(java.lang.String prefix,
java.lang.String url)
throws org.xml.sax.SAXException
startPrefixMapping in interface org.xml.sax.ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.XMLFilterImplorg.xml.sax.SAXException