Package eu.bandm.tools.util.xml
Class NamespaceEmbedder
java.lang.Object
eu.bandm.tools.util.xml.ContentProxy
eu.bandm.tools.util.xml.NamespaceEmbedder
- All Implemented Interfaces:
ContentHandler
Converts name space related information: (a) prefix mapping commands into
pseudo-attributes, and (b) uri/localname sax events into qName sax events.
This yields a "not-namespace-aware" format of the document.
The SAX event stream reaching this api must adhere to the following criteria
The namespace uri "http://www.w3.org/XML/1998/namespace" is (a) bound to the prefix "xml:"; (b) it may be declared, but (c) it is not required to be declared. (d) This namespace name may not be bound to a different prefix, and (e) the prefix "xml:" may not be bound to a different namespace name. [NS in XML:3, last paras].
The SAX event stream reaching this api must adhere to the following criteria
- All names are by "uri" and "localname", --- the "qname" field is ignored.
- All
startPrefixMapping(String, String)
andendPrefixMapping(String)
calls are properly nested, ... - and in sync with the scopes, as defined by the carrying elements.
- The prefix mappings are FREE of NESTED HOMONYMS (ie. the same prefix re-used for different uris, implying shadowing). Non-overlapping homonyms are permitted.
The namespace uri "http://www.w3.org/XML/1998/namespace" is (a) bound to the prefix "xml:"; (b) it may be declared, but (c) it is not required to be declared. (d) This namespace name may not be bound to a different prefix, and (e) the prefix "xml:" may not be bound to a different namespace name. [NS in XML:3, last paras].
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionall currently mapped prefices, INPUT side.protected Map<String,
NamespaceEmbedder.Pref> all currently mapped uris, INPUT side.Fields inherited from class eu.bandm.tools.util.xml.ContentProxy
out
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
endElement
(String uri, String localName, String qName) void
endPrefixMapping
(String prefix) protected void
protected void
homonymError
(String prefix, String olduri, String newuri) protected String
void
startElement
(String uri, String localName, String qName, Attributes attrs) void
startPrefixMapping
(String prefix, String uri) Establishes explicitly a relation from an uri to a (currently unused!) prefix.Methods inherited from class eu.bandm.tools.util.xml.ContentProxy
characters, endDocument, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
newPrefices
-
prefix2uri
all currently mapped prefices, INPUT side. -
uri2prefix
all currently mapped uris, INPUT side.
-
-
Constructor Details
-
NamespaceEmbedder
-
-
Method Details
-
error
-
homonymError
-
makeQname
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classContentProxy
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classContentProxy
- Throws:
SAXException
-
startPrefixMapping
Establishes explicitly a relation from an uri to a (currently unused!) prefix.
Prefix== ""
means assignment to the "default namespace"
Uri== ""
means refering to the non-name-space
uri=="" && prefix!=""
is an error.- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classContentProxy
- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classContentProxy
- Throws:
SAXException
-