ACEXML  6.1.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
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:
Collaboration graph

Public Member Functions

 ACEXML_NamespaceSupport (void)
 ~ACEXML_NamespaceSupport (void)
int init (void)
int declarePrefix (const ACEXML_Char *prefix, const ACEXML_Char *uri)
int getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const
const ACEXML_ChargetPrefix (const ACEXML_Char *uri) const
int getPrefixes (ACEXML_STR_LIST &prefixes) const
int getPrefixes (const ACEXML_Char *uri, ACEXML_STR_LIST &prefixes) const
const ACEXML_ChargetURI (const ACEXML_Char *prefix) const
int popContext (void)
int processName (const ACEXML_Char *qName, const ACEXML_Char *&uri, const ACEXML_Char *&name, int is_attribute) const
int pushContext (void)
int reset (void)

Static Public Attributes

static const ACEXML_CharXMLNS = ACEXML_XMLNS_URI_name

Private Attributes

ACEXML_Namespace_Context_Stack ns_stack_

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.declarePrefix("", "");
support.declarePrefix("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]);

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

Constructor & Destructor Documentation

ACEXML_NamespaceSupport::ACEXML_NamespaceSupport ( void  )

Default constructor.

ACEXML_NamespaceSupport::~ACEXML_NamespaceSupport ( void  )

Default destructor.

Member Function Documentation

int ACEXML_NamespaceSupport::declarePrefix ( const ACEXML_Char prefix,
const ACEXML_Char uri 

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.

const ACEXML_Char * ACEXML_NamespaceSupport::getPrefix ( const ACEXML_Char uri) const

Return one of the prefixes mapped to a Namespace URI.

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.

int ACEXML_NamespaceSupport::getPrefixes ( const ACEXML_Char uri,
) const

Return all prefixes currently declared for a URI in the user-supplied list.

const ACEXML_Char * ACEXML_NamespaceSupport::getURI ( const ACEXML_Char prefix) const

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.

int ACEXML_NamespaceSupport::processName ( const ACEXML_Char qName,
const ACEXML_Char *&  uri,
const ACEXML_Char *&  name,
int  is_attribute 
) const

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

ACEXML_NS_CONTEXT* ACEXML_NamespaceSupport::effective_context_

The effective namespace context.

ACEXML_Namespace_Context_Stack ACEXML_NamespaceSupport::ns_stack_

Namespace Context stack. When we entering a new namespace context, the old context is duplicated and pushed into this stack.

const ACEXML_Char * ACEXML_NamespaceSupport::XMLNS = ACEXML_XMLNS_URI_name

XMLNS default prefix and URI strings.

The documentation for this class was generated from the following files: