ACEXML_NamespaceSupport Class Reference
ACEXML_NamespaceSupport provides namespace management operation for an XML parser.
More...
#include <ACEXML/common/NamespaceSupport.h>
Collaboration diagram for ACEXML_NamespaceSupport:
[legend]List of all members.
Detailed Description
ACEXML_NamespaceSupport provides namespace management operation for an XML parser.
This class encapsulates the logic of Namespace processing: it tracks the declarations currently in force for each context and automatically processes qualified XML 1.0 names into their Namespace parts; it can also be used in reverse for generating XML 1.0 from Namespaces.
Namespace support objects are reusable, but the reset method must be invoked between each session.
Here is a simple session (in Java :-p):
String parts[] = new String[3];
NamespaceSupport support = new NamespaceSupport();
support.pushContext();
support.declarePrefix("", "http://www.w3.org/1999/xhtml");
support.declarePrefix("dc", "http://www.purl.org/dc#");
String parts[] = support.processName("p", parts, false);
System.out.println("Namespace URI: " + parts[0]);
System.out.println("Local name: " + parts[1]);
System.out.println("Raw name: " + parts[2]);
String parts[] = support.processName("dc:title", parts, false);
System.out.println("Namespace URI: " + parts[0]);
System.out.println("Local name: " + parts[1]);
System.out.println("Raw name: " + parts[2]);
support.popContext();
Note that this class is optimized for the use case where most elements do not contain Namespace declarations: if the same prefix/URI mapping is repeated for each context (for example), this class will be somewhat less efficient.
- See also:
- ACEXML_Exception
Constructor & Destructor Documentation
ACEXML_NamespaceSupport::ACEXML_NamespaceSupport |
( |
void |
|
) |
|
|
Member Function Documentation
|
Declare a Namespace prefix. Return -1 if the prefix was illegal or an internal error occured. Return 0 if the prefix gets declared successfully, 1 if the prefix replaces an existing prefix definition. |
int ACEXML_NamespaceSupport::getDeclaredPrefixes |
( |
ACEXML_STR_LIST & |
prefixes |
) |
const |
|
|
Return all prefixes declared in current context in the user-supplied list prefixes. It is user's reponsibility to ensure the list was empty originally. |
|
Return one of the prefixes mapped to a Namespace URI. |
|
Return all prefixes currently declared for a URI in the user-supplied list. |
int ACEXML_NamespaceSupport::getPrefixes |
( |
ACEXML_STR_LIST & |
prefixes |
) |
const |
|
|
Return all prefixes currently declared in the user-supplied list. @ Known bug: This function should only return user-defined prefixes. |
|
Look up a prefix and get the currently-mapped Namespace URI. |
int ACEXML_NamespaceSupport::init |
( |
void |
|
) |
|
|
|
Initialize the namespace support object |
int ACEXML_NamespaceSupport::popContext |
( |
void |
|
) |
|
|
|
Revert to the previous namespace context. |
|
Process a raw XML 1.0 name. qName is the raw XML name we want to parse, uri contains the URI string of the raw name. It points to a null string if the namespace is not valid or there's no namespace defined. name contains the original name without the prefix. is_attribute specifies whether the name is an attribute or not. Attributes have different scoping rules from elements. |
int ACEXML_NamespaceSupport::pushContext |
( |
void |
|
) |
|
|
|
Start a new Namespace context. Prefixes defined in previous context are copied over to the new context. |
int ACEXML_NamespaceSupport::reset |
( |
void |
|
) |
|
|
|
Reset this Namespace support object for reuse. |
Member Data Documentation
|
The effective namespace context. |
|
Namespace Context stack. When we entering a new namespace context, the old context is duplicated and pushed into this stack. |
|
XMLNS default prefix and URI strings. |
The documentation for this class was generated from the following files:
Generated on Sun May 15 12:55:09 2005 for ACEXML by
1.3.9.1