public class NamespaceFilter extends org.xml.sax.helpers.XMLFilterImpl
ObjectFactory annotations and use an
XMLStreamReader that is non-namespace aware, like so:
JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class);
XMLInputFactory xif = XMLInputFactory.newFactory();
xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
StreamSource source = new StreamSource(f);
XMLStreamReader xsr = xif.createXMLStreamReader(source);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Object unmarshal = unmarshaller.unmarshal(xsr);
new NamespaceFilter("http://www.example.com/namespaceurl", true);
new NamespaceFilter(null, false);
XMLFilter| Constructor and Description |
|---|
NamespaceFilter(String namespaceUri,
boolean addNamespace) |
| Modifier and Type | Method and Description |
|---|---|
void |
endElement(String arg0,
String arg1,
String arg2) |
void |
startDocument() |
void |
startElement(String arg0,
String arg1,
String arg2,
Attributes arg3) |
void |
startPrefixMapping(String prefix,
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, unparsedEntityDecl, warningpublic NamespaceFilter(String namespaceUri, boolean addNamespace)
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.XMLFilterImplSAXExceptionpublic void startElement(String arg0, String arg1, String arg2, Attributes arg3) throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.XMLFilterImplSAXExceptionpublic void endElement(String arg0, String arg1, String arg2) throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.XMLFilterImplSAXExceptionpublic void startPrefixMapping(String prefix, String url) throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.XMLFilterImplSAXExceptionCopyright © 2017. All rights reserved.