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
Nested Classes -
Field Summary
FieldsModifier 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidendElement(String uri, String localName, String qName) voidendPrefixMapping(String prefix) protected voidprotected voidhomonymError(String prefix, String olduri, String newuri) protected StringvoidstartElement(String uri, String localName, String qName, Attributes attrs) voidstartPrefixMapping(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, startDocumentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
endElementin interfaceContentHandler- Overrides:
endElementin classContentProxy- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin 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:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classContentProxy- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classContentProxy- Throws:
SAXException
-