00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __RTXMLPULL_H
00025 #define __RTXMLPULL_H
00026
00027 #include "rtxsrc/rtxCtype.h"
00028 #include "rtxsrc/rtxStream.h"
00029 #include "rtxsrc/rtxStreamBuffered.h"
00030 #include "rtxsrc/rtxErrCodes.h"
00031 #include "rtxsrc/rtxStreamDirectBuf.hh"
00032 #include "rtxmlsrc/osrtxml.h"
00033
00034
00035
00036
00037 #define MAX_DELAYED_TASK_SIZE 10
00038
00039
00040 #define OSXML_DEFAULT_QNAME_BUF_SIZE 10
00041
00042 #define OSXMLEVT_NONE 0
00043 #define OSXMLEVT_INITIAL OSXMLEVT_NONE
00044 #define OSXMLEVT_START_DOCUMENT 0x1
00045 #define OSXMLEVT_START_TAG 0x2
00046 #define OSXMLEVT_TEXT 0x4
00047 #define OSXMLEVT_END_TAG 0x8
00048 #define OSXMLEVT_END_DOCUMENT 0x10
00049 #define OSXMLEVT_COMMENT 0x20
00050 #define OSXMLEVT_PI 0x40
00051 #define OSXMLEVT_DTD 0x80
00052
00053 #define OSXMLEVT_USED_FLAG 0x80000000u
00054 #define OSXMLEVT_ID_MASK (~OSXMLEVT_USED_FLAG)
00055 #define OSXMLEVT_ALL_MASK OSXMLEVT_ID_MASK
00056
00057 #define XMLPREADER(pctxt) ((OSXMLCtxtInfo*) pctxt->pXMLInfo)->pXmlPPReader
00058
00059 typedef enum {
00060 OSXMLS_HEADER = -1,
00061 OSXMLS_COMMENT = -2,
00062 OSXMLS_START_ELEMENT = -3,
00063 OSXMLS_DTD = -4,
00064 OSXMLS_CONTENT = -5,
00065 OSXMLS_PI = -6,
00066 OSXMLS_END_ELEMENT = -7,
00067 OSXMLS_CDATA = -8,
00068
00069 OSXMLS_LAST = -9
00070 } OSXMLStates;
00071
00072 typedef enum {
00073 OSXMLSI_HEADER = -OSXMLS_HEADER-1,
00074 OSXMLSI_COMMENT = -OSXMLS_COMMENT-1,
00075 OSXMLSI_START_ELEMENT = -OSXMLS_START_ELEMENT-1,
00076 OSXMLSI_DTD = -OSXMLS_DTD-1,
00077 OSXMLSI_CONTENT = -OSXMLS_CONTENT-1,
00078 OSXMLSI_PI = -OSXMLS_PI-1,
00079 OSXMLSI_END_ELEMENT = -OSXMLS_END_ELEMENT-1,
00080 OSXMLSI_CDATA = -OSXMLS_CDATA-1,
00081
00082 OSXMLSI_LAST = -OSXMLS_LAST-1
00083 } OSXMLStatesIndex;
00084
00085 typedef enum {
00086 OSXMLDM_NONE = 0,
00087 OSXMLDM_SIMULATED,
00088 OSXMLDM_CONTENT
00089 } OSXMLDataMode;
00090
00091 typedef enum {
00092 OSXMLNSI_UNQUALIFIED = 0,
00093 OSXMLNSI_UNKNOWN = -1,
00094 OSXMLNSI_UNCHECKED = -2,
00095 OSXMLNSI_XSI = -3,
00096 OSXMLNSI_XMLNS = -4,
00097 OSXMLNSI_XML = -5,
00098 OSXMLNSI_SOAP_ENVELOPE = -6,
00099 OSXMLNSI_XSD = -7
00100 } OSXMLNsIndex;
00101
00102 typedef struct {
00103 size_t offset;
00104 size_t length;
00105 } OSXMLStrFragOffset;
00106
00107 typedef struct {
00108 OSXMLStrFragment mQName;
00109 OSXMLStrFragment mLocalName;
00110 OSXMLStrFragment mPrefix;
00111
00112 OSUTF8CHAR mBuffer[OSXML_DEFAULT_QNAME_BUF_SIZE];
00113 } OSXMLElementName;
00114
00115 typedef struct OSXMLEvent {
00116 OSUINT32 mId;
00117 OSINT32 mLevel;
00118 } OSXMLEvent;
00119
00120 typedef struct OSXMLDataCtxt {
00121 OSINT32 mDataLevel;
00122 OSXMLDataMode mDataMode;
00123
00124
00125 int mnChunk;
00126 OSBOOL mbLastChunk;
00127 OSBOOL mbCDATA;
00128 OSXMLStrFragment mData;
00129
00130
00131 OSXMLStrFragment mSrcData;
00132 size_t mSrcDataOffset;
00133 OSBOOL mbInsTokenSeparator;
00134 } OSXMLDataCtxt;
00135
00136 typedef struct {
00137 OSXMLStrFragOffset mQName;
00138 OSXMLStrFragOffset mLocalName;
00139 OSXMLStrFragOffset mPrefix;
00140 } OSXMLElemNameOffset;
00141
00142 typedef struct OSXMLStack {
00143 void* mpStackArray;
00144 size_t mSize;
00145 size_t mUnitSize;
00146 size_t mCount;
00147 OSBOOL mbDynamic;
00148 } OSXMLStack;
00149
00150 typedef struct OSXMLRewindPos {
00151 size_t mPos;
00152 OSXMLEvent mEvent;
00153 OSXMLStrFragment mData;
00154 OSBOOL mbListMode;
00155 OSBOOL mbLastChunk;
00156 } OSXMLRewindPos;
00157
00158 typedef struct OSXMLSrcPos {
00159 OSUINT32 mLine;
00160 OSUINT32 mColumn;
00161 OSUINT32 mByteIdx;
00162 OSBOOL mbCR;
00163 } OSXMLSrcPos;
00164
00165 typedef struct OSXMLReader {
00166
00167 OSCTXT* mpCtxt;
00168 OSBOOL mbNoTransform;
00169 OSBOOL mbWSOnlyContext;
00170 OSBOOL mbMixedContext;
00171 OSBOOL mbListMode;
00172 OSBOOL mbSkipPullListElem;
00173 OSBOOL mbDecodeAsGroup;
00174 OSXMLWhiteSpaceMode mWhiteSpaceMode;
00175 OSXMLWhiteSpaceMode mStringWhiteSpaceMode;
00176 OSXMLEncoding mEncoding;
00177 OSXMLBOM mBOM;
00178
00179
00180 OSXMLEvent mLastEvent;
00181
00182 OSXMLElemNameOffset mElementName;
00183 OSBOOL mbHasAttributes;
00184 OSBOOL mbEmptyElement;
00185
00186 OSXMLStack mAttributes;
00187
00188
00189 OSXMLStrFragment mData;
00190 OSBOOL mbLastChunk;
00191 OSBOOL mbCDATA;
00192 OSINT32 mLevel;
00193 OSINT32 mDecodeLevel;
00194
00195 int mError;
00196
00197 OSINT16 mElementNsIndex;
00198
00199
00200 int mState, mPrevState, mNewState;
00201 int mLocalStates [OSXMLSI_LAST];
00202 OSUTF8CHAR mCharBuf[10];
00203 OSUTF8CHAR* mpEscapeChar;
00204 OSUTF8CHAR* mpChars;
00205 size_t mMarkedByteIndex;
00206 OSXMLDataMode mDataMode;
00207
00208
00209 OSXMLStack mTagNamesStack;
00210
00211
00212 OSXMLStack mNamespacesStack;
00213 #ifdef OSXMLNS12
00214 const OSUTF8CHAR** mNamespaceTable;
00215 int mNamespacesNumber;
00216 const OSUTF8CHAR** mPrevNamespaceTable;
00217 int mPrevNamespacesNumber;
00218 #else
00219 const char** mNamespaceTable;
00220 int mNamespacesNumber;
00221 const char** mPrevNamespaceTable;
00222 int mPrevNamespacesNumber;
00223 #endif
00224
00225 OSOCTET mDelayedTasks [MAX_DELAYED_TASK_SIZE];
00226 size_t mDelayedTaskCount;
00227 size_t mDelayedTaskIndex;
00228
00229
00230 OSUTF8CHAR* mpBuffer;
00231 size_t mByteIndex;
00232 size_t mBufSize;
00233 size_t mReadSize;
00234 size_t mMarkedPos;
00235
00236 size_t mLastBlockSize;
00237 size_t mLastByteIndex;
00238
00239 OSBOOL mbBackoffEnabled;
00240 OSBOOL mbSysMemBuf;
00241
00242 OSXMLStack mRewindPosStack;
00243
00244
00245 OSXMLSrcPos mSrcPos;
00246 size_t mMarkedAttrCount;
00247
00248 } OSXMLReader;
00249
00250 #ifdef __cplusplus
00251 extern "C" {
00252 #endif
00253
00257 EXTXMLMETHOD struct OSXMLReader* rtXmlRdCreateXmlReader (OSCTXT* pctxt);
00258
00268 EXTXMLMETHOD OSXMLWhiteSpaceMode rtXmlRdSetWhiteSpaceMode
00269 (struct OSXMLReader* pReader, OSXMLWhiteSpaceMode whiteSpaceMode);
00270
00288 EXTXMLMETHOD long rtXmlRdFirstData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00289
00303 EXTXMLMETHOD long rtXmlRdNextData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00304
00311 EXTXMLMETHOD int rtXmlRdSkipCurrentLevel (struct OSXMLReader* pReader);
00312
00321 EXTXMLMETHOD int rtXmlRdNext (struct OSXMLReader* pReader);
00322
00329 EXTXMLMETHOD int rtXmlRdNextTag (struct OSXMLReader* pReader);
00330
00336 EXTXMLMETHOD int rtXmlRdNextEndTag (struct OSXMLReader* pReader);
00337
00343 EXTXMLMETHOD OSXMLEvent rtXmlRdGetLastEvent (struct OSXMLReader* pReader);
00344
00355 EXTXMLMETHOD int rtXmlRdGetTagName (struct OSXMLReader* pReader,
00356 OSXMLStrFragment* localName,
00357 OSINT16* namespaceIndex);
00358
00367 EXTXMLMETHOD int rtXmlRdGetAttributeCount (struct OSXMLReader* pReader);
00368
00379 EXTXMLMETHOD int rtXmlRdGetAttributeName (struct OSXMLReader* pReader,
00380 OSXMLNameFragments* pAttr,
00381 OSINT16* pNsidx,
00382 size_t index);
00383
00393 EXTXMLMETHOD int rtXmlRdFirstAttr (struct OSXMLReader* pReader,
00394 OSXMLStrFragment* pAttrName,
00395 OSXMLStrFragment* pAttrValue);
00396
00406 EXTXMLMETHOD int rtXmlRdNextAttr (struct OSXMLReader* pReader,
00407 OSXMLStrFragment* pAttrName,
00408 OSXMLStrFragment* pAttrValue);
00409
00419 EXTXMLMETHOD int rtXmlRdSelectAttribute (struct OSXMLReader* pReader, size_t index);
00420
00431 EXTXMLMETHOD OSINT32 rtXmlRdGetCurrentLevel (struct OSXMLReader* pReader);
00432
00447 EXTXMLMETHOD int rtXmlRdNextEvent (struct OSXMLReader* pReader,
00448 OSUINT32 eventMask,
00449 OSINT32 maxLevel,
00450 OSXMLEvent* pLastEvent);
00451
00457 EXTXMLMETHOD OSXMLDataMode rtXmlRdGetDataMode (struct OSXMLReader* pReader);
00458
00465 EXTXMLMETHOD int rtXmlRdMarkLastEventDone (struct OSXMLReader* pReader);
00466
00473 EXTXMLMETHOD int rtXmlRdMarkLastEventActive (struct OSXMLReader* pReader);
00474
00478 EXTXMLMETHOD void rtXmlRdResetXmlReader (struct OSXMLReader* pReader);
00479
00480 EXTXMLMETHOD void rtXmlRdMarkPos (struct OSXMLReader* pReader);
00481 EXTXMLMETHOD void rtXmlRdRewindToMarkedPos (struct OSXMLReader* pReader);
00482 EXTXMLMETHOD void rtXmlRdResetMarkedPos (struct OSXMLReader* pReader);
00483
00484 EXTXMLMETHOD int rtXmlRdGetXSITypeAttr (struct OSXMLReader* pReader,
00485 const OSUTF8CHAR** ppAttrValue,
00486 OSINT16* nsidx, size_t* pLocalOffs);
00487
00491 EXTXMLMETHOD OSBOOL rtXmlRdIsEmpty (struct OSXMLReader* pReader);
00492
00493 EXTXMLMETHOD void rtXmlRdGetSourcePosition (struct OSXMLReader* pReader,
00494 OSUINT32* pLine,
00495 OSUINT32* pColumn,
00496 OSUINT32* pByteIndex,
00497 OSBOOL nextPos);
00498
00499 EXTXMLMETHOD void rtXmlRdErrAddSrcPos (struct OSXMLReader* pReader,
00500 OSBOOL nextPos);
00501
00502 EXTXMLMETHOD void rtXmlRdErrAddDataSrcPos (struct OSXMLReader* pReader,
00503 OSXMLDataCtxt* pDataCtxt,
00504 OSUINT32 offset);
00505
00506 #ifdef __cplusplus
00507 }
00508 #endif
00509
00510 #endif
00511