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 struct {
00092 size_t offset;
00093 size_t length;
00094 } OSXMLStrFragOffset;
00095
00096 typedef struct {
00097 OSXMLStrFragment mQName;
00098 OSXMLStrFragment mLocalName;
00099 OSXMLStrFragment mPrefix;
00100
00101 OSUTF8CHAR mBuffer[OSXML_DEFAULT_QNAME_BUF_SIZE];
00102 } OSXMLElementName;
00103
00104 typedef struct OSXMLEvent {
00105 OSUINT32 mId;
00106 OSINT32 mLevel;
00107 } OSXMLEvent;
00108
00109 typedef struct OSXMLDataCtxt {
00110 OSINT32 mDataLevel;
00111 OSXMLDataMode mDataMode;
00112
00113
00114 int mnChunk;
00115 OSBOOL mbLastChunk;
00116 OSBOOL mbCDATA;
00117 OSXMLStrFragment mData;
00118
00119
00120 OSXMLStrFragment mSrcData;
00121 size_t mSrcDataOffset;
00122 OSBOOL mbInsTokenSeparator;
00123 } OSXMLDataCtxt;
00124
00125 typedef struct {
00126 OSXMLStrFragOffset mQName;
00127 OSXMLStrFragOffset mLocalName;
00128 OSXMLStrFragOffset mPrefix;
00129 } OSXMLElemNameOffset;
00130
00131 typedef struct OSXMLStack {
00132 void* mpStackArray;
00133 size_t mSize;
00134 size_t mUnitSize;
00135 size_t mCount;
00136 OSBOOL mbDynamic;
00137 } OSXMLStack;
00138
00139 typedef struct OSXMLRewindPos {
00140 size_t mPos;
00141 OSXMLEvent mEvent;
00142 OSXMLStrFragment mData;
00143 OSBOOL mbListMode;
00144 OSBOOL mbLastChunk;
00145 } OSXMLRewindPos;
00146
00147 typedef struct OSXMLSrcPos {
00148 OSUINT32 mLine;
00149 OSUINT32 mColumn;
00150 OSUINT32 mByteIdx;
00151 OSBOOL mbCR;
00152 } OSXMLSrcPos;
00153
00154 typedef struct OSXMLReader {
00155
00156 OSCTXT* mpCtxt;
00157 OSBOOL mbNoTransform;
00158
00159 OSBOOL mbMixedContext;
00160 OSBOOL mbListMode;
00161 OSBOOL mbSkipPullListElem;
00162 OSBOOL mbDecodeAsGroup;
00163 OSXMLWhiteSpaceMode mWhiteSpaceMode;
00164 OSXMLWhiteSpaceMode mStringWhiteSpaceMode;
00165 OSXMLEncoding mEncoding;
00166 OSXMLBOM mBOM;
00167
00168
00169 OSXMLEvent mLastEvent;
00170
00171 OSXMLElemNameOffset mElementName;
00172 OSBOOL mbHasAttributes;
00173 OSBOOL mbEmptyElement;
00174
00175 OSXMLStack mAttributes;
00176
00177
00178 OSXMLStrFragment mData;
00179 OSBOOL mbLastChunk;
00180 OSBOOL mbCDATA;
00181 OSINT32 mLevel;
00182 OSINT32 mDecodeLevel;
00183
00184 int mError;
00185
00186 OSINT16 mElementNsIndex;
00187
00188
00189 int mState, mPrevState, mNewState;
00190 int mLocalStates [OSXMLSI_LAST];
00191 OSUTF8CHAR mCharBuf[10];
00192 OSUTF8CHAR* mpEscapeChar;
00193 OSUTF8CHAR* mpChars;
00194 size_t mMarkedByteIndex;
00195 OSXMLDataMode mDataMode;
00196
00197
00198 OSXMLStack mTagNamesStack;
00199
00200
00201 OSXMLStack mNamespacesStack;
00202 #ifdef OSXMLNS12
00203 const OSUTF8CHAR** mNamespaceTable;
00204 int mNamespacesNumber;
00205 const OSUTF8CHAR** mPrevNamespaceTable;
00206 int mPrevNamespacesNumber;
00207 #else
00208 const char** mNamespaceTable;
00209 int mNamespacesNumber;
00210 const char** mPrevNamespaceTable;
00211 int mPrevNamespacesNumber;
00212 #endif
00213
00214 OSOCTET mDelayedTasks [MAX_DELAYED_TASK_SIZE];
00215 size_t mDelayedTaskCount;
00216 size_t mDelayedTaskIndex;
00217
00218
00219 OSUTF8CHAR* mpBuffer;
00220 size_t mByteIndex;
00221 size_t mBufSize;
00222 size_t mReadSize;
00223 size_t mMarkedPos;
00224
00225 size_t mLastBlockSize;
00226 size_t mLastByteIndex;
00227
00228 OSBOOL mbBackoffEnabled;
00229 OSBOOL mbSysMemBuf;
00230
00231 OSXMLStack mRewindPosStack;
00232
00233
00234 OSXMLSrcPos mSrcPos;
00235 size_t mMarkedAttrCount;
00236
00237 } OSXMLReader;
00238
00239 #ifdef __cplusplus
00240 extern "C" {
00241 #endif
00242
00246 EXTXMLMETHOD struct OSXMLReader* rtXmlRdCreateXmlReader (OSCTXT* pctxt);
00247
00257 EXTXMLMETHOD OSXMLWhiteSpaceMode rtXmlRdSetWhiteSpaceMode
00258 (struct OSXMLReader* pReader, OSXMLWhiteSpaceMode whiteSpaceMode);
00259
00277 EXTXMLMETHOD long rtXmlRdFirstData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00278
00292 EXTXMLMETHOD long rtXmlRdNextData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00293
00300 EXTXMLMETHOD int rtXmlRdSkipCurrentLevel (struct OSXMLReader* pReader);
00301
00310 EXTXMLMETHOD int rtXmlRdNext (struct OSXMLReader* pReader);
00311
00318 EXTXMLMETHOD int rtXmlRdNextTag (struct OSXMLReader* pReader);
00319
00325 EXTXMLMETHOD int rtXmlRdNextEndTag (struct OSXMLReader* pReader);
00326
00332 EXTXMLMETHOD OSXMLEvent rtXmlRdGetLastEvent (struct OSXMLReader* pReader);
00333
00344 EXTXMLMETHOD int rtXmlRdGetTagName (struct OSXMLReader* pReader,
00345 OSXMLStrFragment* localName,
00346 OSINT16* namespaceIndex);
00347
00356 EXTXMLMETHOD int rtXmlRdGetAttributeCount (struct OSXMLReader* pReader);
00357
00368 EXTXMLMETHOD int rtXmlRdGetAttributeName (struct OSXMLReader* pReader,
00369 OSXMLNameFragments* pAttr,
00370 OSINT16* pNsidx,
00371 size_t index);
00372
00382 EXTXMLMETHOD int rtXmlRdFirstAttr (struct OSXMLReader* pReader,
00383 OSXMLStrFragment* pAttrName,
00384 OSXMLStrFragment* pAttrValue);
00385
00395 EXTXMLMETHOD int rtXmlRdNextAttr (struct OSXMLReader* pReader,
00396 OSXMLStrFragment* pAttrName,
00397 OSXMLStrFragment* pAttrValue);
00398
00408 EXTXMLMETHOD int rtXmlRdSelectAttribute (struct OSXMLReader* pReader, size_t index);
00409
00420 EXTXMLMETHOD OSINT32 rtXmlRdGetCurrentLevel (struct OSXMLReader* pReader);
00421
00436 EXTXMLMETHOD int rtXmlRdNextEvent (struct OSXMLReader* pReader,
00437 OSUINT32 eventMask,
00438 OSINT32 maxLevel,
00439 OSXMLEvent* pLastEvent);
00440
00446 EXTXMLMETHOD OSXMLDataMode rtXmlRdGetDataMode (struct OSXMLReader* pReader);
00447
00454 EXTXMLMETHOD int rtXmlRdMarkLastEventDone (struct OSXMLReader* pReader);
00455
00462 EXTXMLMETHOD int rtXmlRdMarkLastEventActive (struct OSXMLReader* pReader);
00463
00467 EXTXMLMETHOD void rtXmlRdResetXmlReader (struct OSXMLReader* pReader);
00468
00469 EXTXMLMETHOD void rtXmlRdMarkPos (struct OSXMLReader* pReader);
00470 EXTXMLMETHOD void rtXmlRdRewindToMarkedPos (struct OSXMLReader* pReader);
00471 EXTXMLMETHOD void rtXmlRdResetMarkedPos (struct OSXMLReader* pReader);
00472
00473 EXTXMLMETHOD int rtXmlRdGetXSITypeAttr (struct OSXMLReader* pReader,
00474 const OSUTF8CHAR** ppAttrValue,
00475 OSINT16* nsidx, size_t* pLocalOffs);
00476
00480 EXTXMLMETHOD OSBOOL rtXmlRdIsEmpty (struct OSXMLReader* pReader);
00481
00482 EXTXMLMETHOD void rtXmlRdGetSourcePosition (struct OSXMLReader* pReader,
00483 OSUINT32* pLine,
00484 OSUINT32* pColumn,
00485 OSUINT32* pByteIndex,
00486 OSBOOL nextPos);
00487
00488 EXTXMLMETHOD void rtXmlRdErrAddSrcPos (struct OSXMLReader* pReader,
00489 OSBOOL nextPos);
00490
00491 EXTXMLMETHOD void rtXmlRdErrAddDataSrcPos (struct OSXMLReader* pReader,
00492 OSXMLDataCtxt* pDataCtxt,
00493 OSSIZE offset);
00494
00495 #ifdef __cplusplus
00496 }
00497 #endif
00498
00499 #endif
00500