rtXmlNamespace.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2010 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00028 #ifndef _RTXMLNAMESPACE_H_
00029 #define _RTXMLNAMESPACE_H_
00030 
00031 #include "rtxsrc/rtxContext.h"
00032 #include "rtxsrc/rtxDynPtrArray.h"
00033 #include "rtxsrc/rtxXmlQName.h"
00034 #include "rtxmlsrc/rtXmlExternDefs.h"
00035 
00036 /* Well-known namespace URI's */
00037 #define OSXMLNSURI "http://www.w3.org/XML/1998/namespace"
00038 #define OSXSINSURI "http://www.w3.org/2001/XMLSchema-instance"
00039 #define OSXSDNSURI "http://www.w3.org/2001/XMLSchema"
00040 
00041 typedef struct OSXMLNamespace {
00042    const OSUTF8CHAR* prefix;
00043    const OSUTF8CHAR* uri;
00044 } OSXMLNamespace;
00045 
00046 /* This structure links a namespace prefix to an entry in a generated 
00047    namespace table. */
00048 typedef struct OSXMLNSPfxLink {
00049    OSINT32 nsidx;
00050    OSXMLNamespace ns;  /* primary namespace prefix is in this record. It may be empty. */
00051    OSRTDynPtrArray extraPrefixes; /* holds additional prefixes for this URI, all of which must be non-empty */
00052    struct OSXMLNSPfxLink* next;
00053 } OSXMLNSPfxLink;
00054 
00055 /* Node in namespace-prefix link stack */
00056 typedef struct OSXMLNSPfxLinkStackNode {
00057    struct OSXMLNSPfxLink* link;
00058    struct OSXMLNSPfxLinkStackNode* next;
00059 } OSXMLNSPfxLinkStackNode;
00060 
00061 /* This structure is used to maintain a stack of namespace prefix links 
00062    within the context.  An entry is added to the stack at each level where 
00063    an xmlns attribute is detected. */
00064 typedef struct OSXMLNSPfxLinkStack {
00065    OSINT32      count;  /* count of elements in stack */
00066    OSXMLNSPfxLinkStackNode* top;  /* top of stack     */
00067 } OSXMLNSPfxLinkStack;
00068 
00069 /* This structure describes a namespace URI table */
00070 typedef struct OSXMLNSURITable {
00071    OSUINT32     nrows;
00072    const OSUTF8CHAR** data;
00073 } OSXMLNSURITable;
00074 
00075 #ifdef __cplusplus
00076 extern "C" {
00077 #endif
00078 
00089 EXTERNXML OSXMLNamespace* rtXmlNSAddNamespace 
00090 (OSCTXT* pctxt, OSRTDList* pNSAttrs, const OSUTF8CHAR* prefix, 
00091  const OSUTF8CHAR* uri);
00092 
00102 EXTERNXML OSBOOL rtXmlNSEqual (OSXMLNamespace* pNS1, OSXMLNamespace* pNS2);
00103 
00111 EXTERNXML void rtXmlNSFreeAttrList (OSCTXT* pctxt, OSRTDList* pNSAttrs);
00112 
00124 EXTERNXML const OSUTF8CHAR* rtXmlNSGetPrefix 
00125 (OSCTXT* pctxt, const OSUTF8CHAR* uri);
00126 
00139 EXTERNXML const OSUTF8CHAR* rtXmlNSGetPrefixUsingIndex 
00140 (OSCTXT* pctxt, const OSUTF8CHAR* uri, OSUINT32 idx);
00141 
00150 EXTERNXML OSUINT32 rtXmlNSGetPrefixCount 
00151 (OSCTXT* pctxt, const OSUTF8CHAR* uri);
00152 
00167 EXTERNXML int rtXmlNSGetPrefixIndex 
00168 (OSCTXT* pctxt, const OSUTF8CHAR* uri, const OSUTF8CHAR* prefix, 
00169  OSUINT32* pcount);
00170 
00182 EXTERNXML const OSUTF8CHAR* rtXmlNSGetQName
00183 (OSCTXT* pctxt, OSUTF8CHAR* buf, size_t bufsiz, const OSUTF8CHAR* uri, 
00184  const OSUTF8CHAR* localName);
00185 
00199 EXTERNXML const OSUTF8CHAR* rtXmlNSGetAttrQName
00200 (OSCTXT* pctxt, OSUTF8CHAR* buf, size_t bufsiz, OSXMLNamespace* pNS, 
00201  const OSUTF8CHAR* localName, OSRTDList* pNSAttrs);
00202 
00211 EXTERNXML OSXMLNamespace* rtXmlNSLookupURI 
00212 (OSCTXT* pctxt, const OSUTF8CHAR* uri);
00213 
00222 EXTERNXML OSXMLNamespace* rtXmlNSLookupURIInList 
00223 (OSRTDList* pNSAttrs, const OSUTF8CHAR* uri);
00224 
00225 
00236 EXTERNXML const OSUTF8CHAR* rtXmlNSLookupPrefixForURI 
00237 (OSCTXT* pctxt, const OSUTF8CHAR* uri);
00238 
00239 
00248 EXTERNXML const OSUTF8CHAR* rtXmlNSLookupPrefix
00249 (OSCTXT* pctxt, const OSUTF8CHAR* prefix);
00250 
00260 EXTERNXML const OSUTF8CHAR* rtXmlNSLookupPrefixFrag
00261 (OSCTXT* pctxt, const OSUTF8CHAR* prefix, size_t prefixLen);
00262 
00269 EXTERNXML void rtXmlNSRemoveAll (OSCTXT* pctxt);
00270 
00287 EXTERNXML OSXMLNamespace* rtXmlNSSetNamespace 
00288 (OSCTXT* pctxt, OSRTDList* pNSAttrs, const OSUTF8CHAR* prefix, 
00289  const OSUTF8CHAR* uri, OSBOOL override);
00290 
00301 EXTERNXML const OSUTF8CHAR* rtXmlNSNewPrefix 
00302 (OSCTXT* pctxt, const OSUTF8CHAR* uri, OSRTDList* pNSAttrs);
00303 
00313 #define RTXMLNSSETQNAME(qname,pNS) \
00314 if (0 != pNS) { qname.nsPrefix = pNS->prefix; qname.nsURI = pNS->uri; } \
00315 else { qname.nsPrefix = qname.nsURI = 0; }
00316 
00320 EXTERNXML int rtXmlNSAddPrefixLink
00321 (OSCTXT* pctxt, const OSUTF8CHAR* prefix, const OSUTF8CHAR* uri, 
00322  const OSUTF8CHAR* nsTable[], OSUINT32 nsTableRowCount);
00323 
00327 EXTERNXML int rtXmlNSFreeAllPrefixLinks 
00328 (OSCTXT* pctxt, OSXMLNSPfxLinkStackNode* pStackNode);
00329 
00333 EXTERNXML int rtXmlNSFreePrefixLink (OSCTXT* pctxt, OSXMLNSPfxLink* plink);
00334 
00339 EXTERNXML int rtXmlNSGetIndex (OSCTXT* pctxt, const OSUTF8CHAR* prefix);
00340 
00344 EXTERNXML int rtXmlNSPush (OSCTXT* pctxt);
00345 
00349 EXTERNXML int rtXmlNSPop (OSCTXT* pctxt);
00350 
00354 EXTERNXML void rtXmlNSSetURITable 
00355 (OSCTXT* pctxt, const OSUTF8CHAR* data[], OSUINT32 nrows);
00356 
00357 #ifdef __cplusplus
00358 }
00359 #endif
00360 
00361 #endif