rtXmlNamespace.h File Reference

XML namespace handling structures and function definitions. More...

#include "rtxsrc/rtxContext.h"
#include "rtxsrc/rtxDynPtrArray.h"
#include "rtxsrc/rtxXmlQName.h"
#include "rtxmlsrc/rtXmlExternDefs.h"

Go to the source code of this file.

Defines

#define RTXMLNSSETQNAME(qname, pNS)
 This macro populates the given QName structure with information from the given namespace structure (namespace URI and prefix).

Functions

OSXMLNamespace * rtXmlNSAddNamespace (OSCTXT *pctxt, OSRTDList *pNSAttrs, const OSUTF8CHAR *prefix, const OSUTF8CHAR *uri)
 This function adds a namespace to the context namespace list.
OSBOOL rtXmlNSEqual (OSXMLNamespace *pNS1, OSXMLNamespace *pNS2)
 This function checks if two namespace records are equal.
void rtXmlNSFreeAttrList (OSCTXT *pctxt, OSRTDList *pNSAttrs)
 This function frees dynamic memory used to hold namespace attribute values.
const OSUTF8CHAR * rtXmlNSGetPrefix (OSCTXT *pctxt, const OSUTF8CHAR *uri)
 This function gets a namespace prefix assigned to the given URI.
const OSUTF8CHAR * rtXmlNSGetPrefixUsingIndex (OSCTXT *pctxt, const OSUTF8CHAR *uri, OSUINT32 idx)
 This function gets a namespace prefix assigned to the given URI using the given index to select a specific prefix from the URI/prefix map.
OSUINT32 rtXmlNSGetPrefixCount (OSCTXT *pctxt, const OSUTF8CHAR *uri)
 This function returns the total number of prefixes currently assigned to the given URI.
int rtXmlNSGetPrefixIndex (OSCTXT *pctxt, const OSUTF8CHAR *uri, const OSUTF8CHAR *prefix, OSUINT32 *pcount)
 This function gets the index of a given prefix in the internal list of prefixes maintained for a given URI in teh namespace stack.
const OSUTF8CHAR * rtXmlNSGetQName (OSCTXT *pctxt, OSUTF8CHAR *buf, size_t bufsiz, const OSUTF8CHAR *uri, const OSUTF8CHAR *localName)
 This function creates a QName in the given fixed-site buffer.
const OSUTF8CHAR * rtXmlNSGetAttrQName (OSCTXT *pctxt, OSUTF8CHAR *buf, size_t bufsiz, OSXMLNamespace *pNS, const OSUTF8CHAR *localName, OSRTDList *pNSAttrs)
 This function creates a QName for a qualified attribute.
OSXMLNamespace * rtXmlNSLookupURI (OSCTXT *pctxt, const OSUTF8CHAR *uri)
 This function looks up a namespace in the context namespace stack using URI as the key value.
OSXMLNamespace * rtXmlNSLookupURIInList (OSRTDList *pNSAttrs, const OSUTF8CHAR *uri)
 This function looks up a namespace in the given list using URI as the key value.
const OSUTF8CHAR * rtXmlNSLookupPrefixForURI (OSCTXT *pctxt, const OSUTF8CHAR *uri)
 This function looks up a namespace in the context namespace stack using URI as the key value and returns a non-empty prefix, if one has been defined.
const OSUTF8CHAR * rtXmlNSLookupPrefix (OSCTXT *pctxt, const OSUTF8CHAR *prefix)
 This function looks up a namespace in the context namespace list using the prefix as the key value.
const OSUTF8CHAR * rtXmlNSLookupPrefixFrag (OSCTXT *pctxt, const OSUTF8CHAR *prefix, size_t prefixLen)
 This function looks up a namespace in the context namespace list using the prefix as the key value.
void rtXmlNSRemoveAll (OSCTXT *pctxt)
 This function removes all namespaces from the context namespace list and frees the dynamic memory used to hold the names.
OSXMLNamespace * rtXmlNSSetNamespace (OSCTXT *pctxt, OSRTDList *pNSAttrs, const OSUTF8CHAR *prefix, const OSUTF8CHAR *uri, OSBOOL override)
 This function sets a namespace in the context namespace list.
const OSUTF8CHAR * rtXmlNSNewPrefix (OSCTXT *pctxt, const OSUTF8CHAR *uri, OSRTDList *pNSAttrs)
 This function returns the next unused prefix of the form "nsX" where X is a number.
int rtXmlNSAddPrefixLink (OSCTXT *pctxt, const OSUTF8CHAR *prefix, const OSUTF8CHAR *uri, const OSUTF8CHAR *nsTable[], OSUINT32 nsTableRowCount)
 Add a prefix link at the current stack level.
int rtXmlNSFreeAllPrefixLinks (OSCTXT *pctxt, OSXMLNSPfxLinkStackNode *pStackNode)
 Free all prefixs links in the given namespace stack entry.
int rtXmlNSFreePrefixLink (OSCTXT *pctxt, OSXMLNSPfxLink *plink)
 Free all data within a given namespace prefix link structure.
int rtXmlNSGetIndex (OSCTXT *pctxt, const OSUTF8CHAR *prefix)
 Get namespace index for a given namespace prefix based on current namespace stack in context.
int rtXmlNSPush (OSCTXT *pctxt)
 Push new namespace prefix mapping level onto stack.
int rtXmlNSPop (OSCTXT *pctxt)
 Remove top namespace prefix mapping level from stack.
void rtXmlNSSetURITable (OSCTXT *pctxt, const OSUTF8CHAR *data[], OSUINT32 nrows)
 Set namespace URI table in context.

Detailed Description

XML namespace handling structures and function definitions.

Definition in file rtXmlNamespace.h.


Define Documentation

#define RTXMLNSSETQNAME ( qname,
pNS   ) 
Value:
if (0 != pNS) { qname.nsPrefix = pNS->prefix; qname.nsURI = pNS->uri; } \
else { qname.nsPrefix = qname.nsURI = 0; }

This macro populates the given QName structure with information from the given namespace structure (namespace URI and prefix).

Parameters:
qname Reference to QName structure to be populated. Pointers to items in pNS are assigned directly to fields in qname. No copies of data are made.
pNS Pointer to namespace structure.

Definition at line 313 of file rtXmlNamespace.h.


Function Documentation

OSXMLNamespace* rtXmlNSAddNamespace ( OSCTXT *  pctxt,
OSRTDList *  pNSAttrs,
const OSUTF8CHAR *  prefix,
const OSUTF8CHAR *  uri 
)

This function adds a namespace to the context namespace list.

Parameters:
pctxt Pointer to OSCTXT structure
pNSAttrs Namespace attribute list to which namespace info is to be added.
prefix Namespace prefix to be added
uri Namespace URI to be added
Returns:
Pointer to namespace structure or NULL if not added.
OSBOOL rtXmlNSEqual ( OSXMLNamespace *  pNS1,
OSXMLNamespace *  pNS2 
)

This function checks if two namespace records are equal.

This does a a deep compare in that it will first check if the pointers are equal and then it will check if the contents are equal (same prefix and URI).

Parameters:
pNS1 Pointer to first namespace records to check.
pNS2 Pointer to second record.
Returns:
True if records are equal, false otherwise.
void rtXmlNSFreeAttrList ( OSCTXT *  pctxt,
OSRTDList *  pNSAttrs 
)

This function frees dynamic memory used to hold namespace attribute values.

Parameters:
pctxt Pointer to OSCTXT structure
pNSAttrs Pointer to namespace attribute list to be freed.
const OSUTF8CHAR* rtXmlNSGetAttrQName ( OSCTXT *  pctxt,
OSUTF8CHAR *  buf,
size_t  bufsiz,
OSXMLNamespace *  pNS,
const OSUTF8CHAR *  localName,
OSRTDList *  pNSAttrs 
)

This function creates a QName for a qualified attribute.

If a prefix is not found for the name, a new namespace entry is created with a generated prefix.

Parameters:
pctxt Pointer to OSCTXT structure
buf Buffer into which qname will be written.
bufsiz Size of the buffer.
pNS Pointer to namespace URI and prefix structure.
localName Local name of the item.
pNSAttrs List of namespace records.
Returns:
Pointer to QName buffer (buf).
const OSUTF8CHAR* rtXmlNSGetPrefix ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri 
)

This function gets a namespace prefix assigned to the given URI.

This gives preference to empty prefixes.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI to be searched for
Returns:
Pointer to namespace prefix string. If a NULL or empty prefix was assigned to the URI, an empty sring is returned. Otherwise, any assigned prefix is returned. If no prefix was assigned, null is returned.
OSUINT32 rtXmlNSGetPrefixCount ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri 
)

This function returns the total number of prefixes currently assigned to the given URI.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI to be searched for
Returns:
Count of prefixes assigned to the URI.
int rtXmlNSGetPrefixIndex ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri,
const OSUTF8CHAR *  prefix,
OSUINT32 *  pcount 
)

This function gets the index of a given prefix in the internal list of prefixes maintained for a given URI in teh namespace stack.

It also may return the total number of prefixes currently assigned to the URI.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI to be searched for
prefix Namespace prefix for which to get index.
pcount Optional pointer to an integer count variable. If provided, the total number of prefixes currently assigned to the URI will be returned.
Returns:
Index to namespace prefix or -1 if the prefix is not assigned to the given URI.
const OSUTF8CHAR* rtXmlNSGetPrefixUsingIndex ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri,
OSUINT32  idx 
)

This function gets a namespace prefix assigned to the given URI using the given index to select a specific prefix from the URI/prefix map.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI to be searched for
idx Index to prefix in map. This only has meaning when multiple prefixes have been assigned to the given URI.
Returns:
Pointer to namespace prefix string
const OSUTF8CHAR* rtXmlNSGetQName ( OSCTXT *  pctxt,
OSUTF8CHAR *  buf,
size_t  bufsiz,
const OSUTF8CHAR *  uri,
const OSUTF8CHAR *  localName 
)

This function creates a QName in the given fixed-site buffer.

If the name will not fit in the buffer, it is truncated.

Parameters:
pctxt Pointer to OSCTXT structure
buf Buffer into which qname will be written.
bufsiz Size of the buffer.
uri Namespace URI.
localName Local name of the item.
Returns:
Pointer to QName buffer (buf).
const OSUTF8CHAR* rtXmlNSLookupPrefix ( OSCTXT *  pctxt,
const OSUTF8CHAR *  prefix 
)

This function looks up a namespace in the context namespace list using the prefix as the key value.

Parameters:
pctxt Pointer to OSCTXT structure
prefix Namespace Prefix to be found.
Returns:
Pointer to namespace URI or NULL if not found.
const OSUTF8CHAR* rtXmlNSLookupPrefixForURI ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri 
)

This function looks up a namespace in the context namespace stack using URI as the key value and returns a non-empty prefix, if one has been defined.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI to be found.
Returns:
Pointer to non-empty prefix. NULL if URI is not found or URI has no associated non-empty prefix.
const OSUTF8CHAR* rtXmlNSLookupPrefixFrag ( OSCTXT *  pctxt,
const OSUTF8CHAR *  prefix,
size_t  prefixLen 
)

This function looks up a namespace in the context namespace list using the prefix as the key value.

Parameters:
pctxt Pointer to OSCTXT structure
prefix Namespace Prefix to be found.
prefixLen Namespace Prefix length.
Returns:
Pointer to namespace URI or NULL if not found.
OSXMLNamespace* rtXmlNSLookupURI ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri 
)

This function looks up a namespace in the context namespace stack using URI as the key value.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI to be found.
Returns:
Pointer to namespace structure or NULL if not found.
OSXMLNamespace* rtXmlNSLookupURIInList ( OSRTDList *  pNSAttrs,
const OSUTF8CHAR *  uri 
)

This function looks up a namespace in the given list using URI as the key value.

Parameters:
pNSAttrs List of namespace records.
uri Namespace URI to be found.
Returns:
Pointer to namespace structure or NULL if not found.
const OSUTF8CHAR* rtXmlNSNewPrefix ( OSCTXT *  pctxt,
const OSUTF8CHAR *  uri,
OSRTDList *  pNSAttrs 
)

This function returns the next unused prefix of the form "nsX" where X is a number.

The new namespace declaration is added to the list provided or the context list if a NULL pointer is passed for pNSAttrs.

Parameters:
pctxt Pointer to OSCTXT structure
uri Namespace URI. Must not be NULL or empty string.
pNSAttrs Pointer to list of namespace attributes.
Returns:
New namespace prefix.
void rtXmlNSRemoveAll ( OSCTXT *  pctxt  ) 

This function removes all namespaces from the context namespace list and frees the dynamic memory used to hold the names.

Parameters:
pctxt Pointer to OSCTXT structure
OSXMLNamespace* rtXmlNSSetNamespace ( OSCTXT *  pctxt,
OSRTDList *  pNSAttrs,
const OSUTF8CHAR *  prefix,
const OSUTF8CHAR *  uri,
OSBOOL  override 
)

This function sets a namespace in the context namespace list.

If the given namespace URI does not exist in the list, the namespace is added. If the URI is found, the action depends on the value of the override flag. If true, the value of the namespace prefix will be changed to the given prefix. If false, the existing namespace specification is not altered.

Parameters:
pctxt Pointer to OSCTXT structure
pNSAttrs Namespace attribute list to which namespace info is to be added.
prefix Namespace prefix
uri Namespace URI
override Should existing definition be changed?
Returns:
Pointer to namespace structure or NULL if not set.