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 0x40
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
00177
00178 OSXMLEvent mLastEvent;
00179
00180 OSXMLElemNameOffset mElementName;
00181 OSBOOL mbHasAttributes;
00182 OSBOOL mbEmptyElement;
00183
00184 OSXMLStack mAttributes;
00185
00186 OSXMLStrFragment mCharacters;
00187 OSXMLStrFragment mData;
00188 OSBOOL mbLastChunk;
00189 OSBOOL mbCDATA;
00190 OSINT32 mLevel;
00191 OSINT32 mDecodeLevel;
00192
00193 int mError;
00194
00195 OSINT16 mElementNsIndex;
00196
00197
00198 int mState, mPrevState, mNewState;
00199 int mLocalStates [OSXMLSI_LAST];
00200 OSUTF8CHAR mCharBuf[10];
00201 OSUTF8CHAR* mpEscapeChar;
00202 OSUTF8CHAR* mpChars;
00203 size_t mMarkedByteIndex;
00204 OSXMLDataMode mDataMode;
00205
00206
00207 OSXMLStack mTagNamesStack;
00208
00209
00210 OSXMLStack mNamespacesStack;
00211 #ifdef OSXMLNS12
00212 const OSUTF8CHAR** mNamespaceTable;
00213 int mNamespacesNumber;
00214 const OSUTF8CHAR** mPrevNamespaceTable;
00215 int mPrevNamespacesNumber;
00216 #else
00217 const char** mNamespaceTable;
00218 int mNamespacesNumber;
00219 const char** mPrevNamespaceTable;
00220 int mPrevNamespacesNumber;
00221 #endif
00222
00223 OSOCTET mDelayedTasks [MAX_DELAYED_TASK_SIZE];
00224 size_t mDelayedTaskCount;
00225 size_t mDelayedTaskIndex;
00226
00227
00228 OSUTF8CHAR* mpBuffer;
00229 size_t mByteIndex;
00230 size_t mBufSize;
00231 size_t mReadSize;
00232 size_t mMarkedPos;
00233
00234 size_t mLastBlockSize;
00235 size_t mLastByteIndex;
00236
00237 OSBOOL mbBackoffEnabled;
00238
00239 OSXMLStack mRewindPosStack;
00240
00241
00242 OSXMLSrcPos mSrcPos;
00243
00244 } OSXMLReader;
00245
00246 #ifdef __cplusplus
00247 extern "C" {
00248 #endif
00249
00253 EXTXMLMETHOD struct OSXMLReader* rtXmlRdCreateXmlReader (OSCTXT* pctxt);
00254
00264 EXTXMLMETHOD OSXMLWhiteSpaceMode rtXmlRdSetWhiteSpaceMode
00265 (struct OSXMLReader* pReader, OSXMLWhiteSpaceMode whiteSpaceMode);
00266
00284 EXTXMLMETHOD long rtXmlRdFirstData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00285
00299 EXTXMLMETHOD long rtXmlRdNextData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00300
00307 EXTXMLMETHOD int rtXmlRdSkipCurrentLevel (struct OSXMLReader* pReader);
00308
00317 EXTXMLMETHOD int rtXmlRdNext (struct OSXMLReader* pReader);
00318
00325 EXTXMLMETHOD int rtXmlRdNextTag (struct OSXMLReader* pReader);
00326
00332 EXTXMLMETHOD int rtXmlRdNextEndTag (struct OSXMLReader* pReader);
00333
00339 EXTXMLMETHOD OSXMLEvent rtXmlRdGetLastEvent (struct OSXMLReader* pReader);
00340
00351 EXTXMLMETHOD int rtXmlRdGetTagName (struct OSXMLReader* pReader,
00352 OSXMLStrFragment* localName,
00353 OSINT16* namespaceIndex);
00354
00363 EXTXMLMETHOD int rtXmlRdGetAttributeCount (struct OSXMLReader* pReader);
00364
00375 EXTXMLMETHOD int rtXmlRdGetAttributeName (struct OSXMLReader* pReader,
00376 OSXMLNameFragments* pAttr,
00377 OSINT16* pNsidx,
00378 size_t index);
00379
00389 EXTXMLMETHOD int rtXmlRdSelectAttribute (struct OSXMLReader* pReader, size_t index);
00390
00401 EXTXMLMETHOD OSINT32 rtXmlRdGetCurrentLevel (struct OSXMLReader* pReader);
00402
00417 EXTXMLMETHOD int rtXmlRdNextEvent (struct OSXMLReader* pReader,
00418 OSUINT32 eventMask,
00419 OSINT32 maxLevel,
00420 OSXMLEvent* pLastEvent);
00421
00427 EXTXMLMETHOD OSXMLDataMode rtXmlRdGetDataMode (struct OSXMLReader* pReader);
00428
00435 EXTXMLMETHOD int rtXmlRdMarkLastEventDone (struct OSXMLReader* pReader);
00436
00443 EXTXMLMETHOD int rtXmlRdMarkLastEventActive (struct OSXMLReader* pReader);
00444
00448 EXTXMLMETHOD void rtXmlRdResetXmlReader (struct OSXMLReader* pReader);
00449
00450 EXTXMLMETHOD void rtXmlRdMarkPos (struct OSXMLReader* pReader);
00451 EXTXMLMETHOD void rtXmlRdRewindToMarkedPos (struct OSXMLReader* pReader);
00452 EXTXMLMETHOD void rtXmlRdResetMarkedPos (struct OSXMLReader* pReader);
00453
00454 EXTXMLMETHOD int rtXmlRdGetXSITypeAttr (struct OSXMLReader* pReader,
00455 const OSUTF8CHAR** ppAttrValue,
00456 OSINT16* nsidx, size_t* pLocalOffs);
00457
00461 EXTXMLMETHOD OSBOOL rtXmlRdIsEmpty (struct OSXMLReader* pReader);
00462
00463 EXTXMLMETHOD void rtXmlRdGetSourcePosition (struct OSXMLReader* pReader,
00464 OSUINT32* pLine,
00465 OSUINT32* pColumn,
00466 OSUINT32* pByteIndex,
00467 OSBOOL nextPos);
00468
00469 EXTXMLMETHOD void rtXmlRdErrAddSrcPos (struct OSXMLReader* pReader,
00470 OSBOOL nextPos);
00471
00472 EXTXMLMETHOD void rtXmlRdErrAddDataSrcPos (struct OSXMLReader* pReader,
00473 OSXMLDataCtxt* pDataCtxt,
00474 OSUINT32 offset);
00475
00476 #ifdef __cplusplus
00477 }
00478 #endif
00479
00480 #endif
00481