1*0Sstevel@tonic-gate // Copyright (c) 1996 James Clark
2*0Sstevel@tonic-gate // See the file COPYING for copying permission.
3*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gate #ifdef __GNUG__
6*0Sstevel@tonic-gate #pragma implementation
7*0Sstevel@tonic-gate #endif
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate #include "splib.h"
10*0Sstevel@tonic-gate #include "ArcEngine.h"
11*0Sstevel@tonic-gate #include "ArcProcessor.h"
12*0Sstevel@tonic-gate #include "Vector.h"
13*0Sstevel@tonic-gate #include "NCVector.h"
14*0Sstevel@tonic-gate #include "IQueue.h"
15*0Sstevel@tonic-gate #include "ArcEngineMessages.h"
16*0Sstevel@tonic-gate #include "MessageArg.h"
17*0Sstevel@tonic-gate #include "ParserOptions.h"
18*0Sstevel@tonic-gate #include "SgmlParser.h"
19*0Sstevel@tonic-gate #include "Allocator.h"
20*0Sstevel@tonic-gate #include "LinkProcess.h"
21*0Sstevel@tonic-gate #include "macros.h"
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gate #ifdef SP_NAMESPACE
24*0Sstevel@tonic-gate namespace SP_NAMESPACE {
25*0Sstevel@tonic-gate #endif
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate static const size_t sizes[] = {
28*0Sstevel@tonic-gate sizeof(StartElementEvent),
29*0Sstevel@tonic-gate sizeof(EndElementEvent),
30*0Sstevel@tonic-gate sizeof(ImmediateDataEvent),
31*0Sstevel@tonic-gate sizeof(SdataEntityEvent),
32*0Sstevel@tonic-gate sizeof(EndPrologEvent),
33*0Sstevel@tonic-gate sizeof(CdataEntityEvent),
34*0Sstevel@tonic-gate sizeof(SdataEntityEvent),
35*0Sstevel@tonic-gate sizeof(ExternalDataEntityEvent),
36*0Sstevel@tonic-gate sizeof(OpenElement)
37*0Sstevel@tonic-gate };
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gate static
maxSize(const size_t * v,size_t n)40*0Sstevel@tonic-gate size_t maxSize(const size_t *v, size_t n)
41*0Sstevel@tonic-gate {
42*0Sstevel@tonic-gate size_t max = 0;
43*0Sstevel@tonic-gate for (size_t i = 0; i < n; i++) {
44*0Sstevel@tonic-gate if (v[i] > max)
45*0Sstevel@tonic-gate max = v[i];
46*0Sstevel@tonic-gate }
47*0Sstevel@tonic-gate return max;
48*0Sstevel@tonic-gate }
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gate const unsigned invalidAtt = unsigned(-1);
51*0Sstevel@tonic-gate const unsigned contentPseudoAtt = unsigned(-2);
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate class DelegateEventHandler : public EventHandler {
54*0Sstevel@tonic-gate public:
55*0Sstevel@tonic-gate #define EVENT(C, f) void f(C *ev) { delegateTo_->f(ev); }
56*0Sstevel@tonic-gate #include "events.h"
57*0Sstevel@tonic-gate #undef EVENT
58*0Sstevel@tonic-gate protected:
59*0Sstevel@tonic-gate EventHandler *delegateTo_;
60*0Sstevel@tonic-gate };
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate class QueueEventHandler : public EventHandler, public IQueue<Event> {
63*0Sstevel@tonic-gate public:
64*0Sstevel@tonic-gate #define EVENT(C, f) void f(C *ev) { ev->copyData(); append(ev); }
65*0Sstevel@tonic-gate #include "events.h"
66*0Sstevel@tonic-gate #undef EVENT
67*0Sstevel@tonic-gate };
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate // This just passes through messages.
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate class NullEventHandler : public EventHandler {
72*0Sstevel@tonic-gate public:
NullEventHandler(Messenger & mgr)73*0Sstevel@tonic-gate NullEventHandler(Messenger &mgr) : mgr_(&mgr) { }
message(MessageEvent * event)74*0Sstevel@tonic-gate void message(MessageEvent *event) {
75*0Sstevel@tonic-gate mgr_->dispatchMessage(event->message());
76*0Sstevel@tonic-gate }
77*0Sstevel@tonic-gate private:
78*0Sstevel@tonic-gate Messenger *mgr_;
79*0Sstevel@tonic-gate };
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gate class ArcEngineImpl : public DelegateEventHandler, private Messenger {
82*0Sstevel@tonic-gate public:
83*0Sstevel@tonic-gate ArcEngineImpl(Messenger &mgr,
84*0Sstevel@tonic-gate const SgmlParser *parser,
85*0Sstevel@tonic-gate ArcDirector &director,
86*0Sstevel@tonic-gate const volatile sig_atomic_t *cancelPtr,
87*0Sstevel@tonic-gate const Notation *,
88*0Sstevel@tonic-gate const Vector<StringC> &name,
89*0Sstevel@tonic-gate const SubstTable<Char> *table);
90*0Sstevel@tonic-gate ~ArcEngineImpl();
91*0Sstevel@tonic-gate void sgmlDecl(SgmlDeclEvent *);
92*0Sstevel@tonic-gate void appinfo(AppinfoEvent *);
93*0Sstevel@tonic-gate void startElement(StartElementEvent *);
94*0Sstevel@tonic-gate void endElement(EndElementEvent *);
95*0Sstevel@tonic-gate void data(DataEvent *);
96*0Sstevel@tonic-gate void sdataEntity(SdataEntityEvent *);
97*0Sstevel@tonic-gate void externalDataEntity(ExternalDataEntityEvent *);
98*0Sstevel@tonic-gate void pi(PiEvent *);
99*0Sstevel@tonic-gate void endProlog(EndPrologEvent *);
100*0Sstevel@tonic-gate void startDtd(StartDtdEvent *);
101*0Sstevel@tonic-gate void endDtd(EndDtdEvent *);
102*0Sstevel@tonic-gate void startLpd(StartLpdEvent *);
103*0Sstevel@tonic-gate void endLpd(EndLpdEvent *);
104*0Sstevel@tonic-gate void uselink(UselinkEvent *);
nBases() const105*0Sstevel@tonic-gate size_t nBases() const { return arcProcessors_.size(); }
delegateHandler()106*0Sstevel@tonic-gate EventHandler *delegateHandler() { return eventHandler_; }
107*0Sstevel@tonic-gate private:
108*0Sstevel@tonic-gate void dispatchMessage(const Message &);
109*0Sstevel@tonic-gate void dispatchMessage(Message &);
110*0Sstevel@tonic-gate void initMessage(Message &);
111*0Sstevel@tonic-gate
112*0Sstevel@tonic-gate EventHandler *eventHandler_;
113*0Sstevel@tonic-gate NCVector<ArcProcessor> arcProcessors_;
114*0Sstevel@tonic-gate ConstPtr<Sd> sd_;
115*0Sstevel@tonic-gate ConstPtr<Syntax> syntax_;
116*0Sstevel@tonic-gate StringC arcBase_;
117*0Sstevel@tonic-gate StringC is10744_;
118*0Sstevel@tonic-gate int stage_;
119*0Sstevel@tonic-gate QueueEventHandler eventQueue_;
120*0Sstevel@tonic-gate NullEventHandler nullHandler_;
121*0Sstevel@tonic-gate const SgmlParser *parser_;
122*0Sstevel@tonic-gate Location currentLocation_;
123*0Sstevel@tonic-gate unsigned gatheringContent_;
124*0Sstevel@tonic-gate Text content_;
125*0Sstevel@tonic-gate unsigned startAgain_;
126*0Sstevel@tonic-gate Allocator alloc_;
127*0Sstevel@tonic-gate StringC appinfo_;
128*0Sstevel@tonic-gate const AttributeList *linkAttributes_;
129*0Sstevel@tonic-gate LinkProcess linkProcess_;
130*0Sstevel@tonic-gate Boolean haveLinkProcess_;
131*0Sstevel@tonic-gate Vector<StringC> docName_;
132*0Sstevel@tonic-gate ArcDirector *director_;
133*0Sstevel@tonic-gate Messenger *mgr_;
134*0Sstevel@tonic-gate const volatile sig_atomic_t *cancelPtr_;
135*0Sstevel@tonic-gate };
136*0Sstevel@tonic-gate
137*0Sstevel@tonic-gate
parseAll(SgmlParser & parser,Messenger & mgr,ArcDirector & director,const volatile sig_atomic_t * cancelPtr)138*0Sstevel@tonic-gate void ArcEngine::parseAll(SgmlParser &parser,
139*0Sstevel@tonic-gate Messenger &mgr,
140*0Sstevel@tonic-gate ArcDirector &director,
141*0Sstevel@tonic-gate const volatile sig_atomic_t *cancelPtr)
142*0Sstevel@tonic-gate {
143*0Sstevel@tonic-gate ArcEngineImpl wrap(mgr, &parser, director, cancelPtr,
144*0Sstevel@tonic-gate 0, Vector<StringC>(), 0);
145*0Sstevel@tonic-gate parser.parseAll(wrap, cancelPtr);
146*0Sstevel@tonic-gate }
147*0Sstevel@tonic-gate
148*0Sstevel@tonic-gate EventHandler *
arcEventHandler(const Notation *,const Vector<StringC> & name,const SubstTable<Char> * table)149*0Sstevel@tonic-gate SelectOneArcDirector::arcEventHandler(const Notation *,
150*0Sstevel@tonic-gate const Vector<StringC> &name,
151*0Sstevel@tonic-gate const SubstTable<Char> *table)
152*0Sstevel@tonic-gate {
153*0Sstevel@tonic-gate if (name.size() != select_.size())
154*0Sstevel@tonic-gate return 0;
155*0Sstevel@tonic-gate for (size_t i = 0; i < name.size(); i++) {
156*0Sstevel@tonic-gate StringC tem(select_[i]);
157*0Sstevel@tonic-gate table->subst(tem);
158*0Sstevel@tonic-gate if (name[i] != tem)
159*0Sstevel@tonic-gate return 0;
160*0Sstevel@tonic-gate }
161*0Sstevel@tonic-gate return eh_;
162*0Sstevel@tonic-gate }
163*0Sstevel@tonic-gate
dispatchMessage(const Message & msg)164*0Sstevel@tonic-gate void SelectOneArcDirector::dispatchMessage(const Message &msg)
165*0Sstevel@tonic-gate {
166*0Sstevel@tonic-gate eh_->message(new MessageEvent(msg));
167*0Sstevel@tonic-gate }
168*0Sstevel@tonic-gate
dispatchMessage(Message & msg)169*0Sstevel@tonic-gate void SelectOneArcDirector::dispatchMessage(Message &msg)
170*0Sstevel@tonic-gate {
171*0Sstevel@tonic-gate eh_->message(new MessageEvent(msg));
172*0Sstevel@tonic-gate }
173*0Sstevel@tonic-gate
ArcEngineImpl(Messenger & mgr,const SgmlParser * parser,ArcDirector & director,const volatile sig_atomic_t * cancelPtr,const Notation * notation,const Vector<StringC> & docName,const SubstTable<Char> * table)174*0Sstevel@tonic-gate ArcEngineImpl::ArcEngineImpl(Messenger &mgr,
175*0Sstevel@tonic-gate const SgmlParser *parser,
176*0Sstevel@tonic-gate ArcDirector &director,
177*0Sstevel@tonic-gate const volatile sig_atomic_t *cancelPtr,
178*0Sstevel@tonic-gate const Notation *notation,
179*0Sstevel@tonic-gate const Vector<StringC> &docName,
180*0Sstevel@tonic-gate const SubstTable<Char> *table)
181*0Sstevel@tonic-gate
182*0Sstevel@tonic-gate : director_(&director), mgr_(&mgr), cancelPtr_(cancelPtr),
183*0Sstevel@tonic-gate parser_(parser), stage_(0),
184*0Sstevel@tonic-gate gatheringContent_(0), startAgain_(0), haveLinkProcess_(0),
185*0Sstevel@tonic-gate alloc_(maxSize(sizes, SIZEOF(sizes)), 50),
186*0Sstevel@tonic-gate nullHandler_(mgr), docName_(docName)
187*0Sstevel@tonic-gate {
188*0Sstevel@tonic-gate eventHandler_ = director.arcEventHandler(notation, docName, table);
189*0Sstevel@tonic-gate if (!eventHandler_)
190*0Sstevel@tonic-gate eventHandler_ = &nullHandler_;
191*0Sstevel@tonic-gate delegateTo_ = eventHandler_;
192*0Sstevel@tonic-gate }
193*0Sstevel@tonic-gate
~ArcEngineImpl()194*0Sstevel@tonic-gate ArcEngineImpl::~ArcEngineImpl()
195*0Sstevel@tonic-gate {
196*0Sstevel@tonic-gate for (size_t i = 0; i < arcProcessors_.size(); i++)
197*0Sstevel@tonic-gate if (arcProcessors_[i].valid())
198*0Sstevel@tonic-gate arcProcessors_[i].checkIdrefs();
199*0Sstevel@tonic-gate }
200*0Sstevel@tonic-gate
appinfo(AppinfoEvent * event)201*0Sstevel@tonic-gate void ArcEngineImpl::appinfo(AppinfoEvent *event)
202*0Sstevel@tonic-gate {
203*0Sstevel@tonic-gate const StringC *str;
204*0Sstevel@tonic-gate if (event->literal(str))
205*0Sstevel@tonic-gate appinfo_ = *str;
206*0Sstevel@tonic-gate DelegateEventHandler::appinfo(event);
207*0Sstevel@tonic-gate }
208*0Sstevel@tonic-gate
pi(PiEvent * event)209*0Sstevel@tonic-gate void ArcEngineImpl::pi(PiEvent *event)
210*0Sstevel@tonic-gate {
211*0Sstevel@tonic-gate currentLocation_ = event->location();
212*0Sstevel@tonic-gate if (stage_ == 1
213*0Sstevel@tonic-gate && arcBase_.size()
214*0Sstevel@tonic-gate && event->dataLength() > is10744_.size() + 1) {
215*0Sstevel@tonic-gate Boolean match = 1;
216*0Sstevel@tonic-gate size_t i = 0;
217*0Sstevel@tonic-gate for (size_t j = 0; j < is10744_.size() && match; i++, j++)
218*0Sstevel@tonic-gate if ((*syntax_->generalSubstTable())[event->data()[i]] != is10744_[j])
219*0Sstevel@tonic-gate match = 0;
220*0Sstevel@tonic-gate if (!syntax_->isS(event->data()[i]))
221*0Sstevel@tonic-gate match = 0;
222*0Sstevel@tonic-gate do {
223*0Sstevel@tonic-gate i++;
224*0Sstevel@tonic-gate } while (i < event->dataLength() && syntax_->isS(event->data()[i]));
225*0Sstevel@tonic-gate for (size_t j = 0; j < arcBase_.size() && match; i++, j++)
226*0Sstevel@tonic-gate if (i >= event->dataLength()
227*0Sstevel@tonic-gate || (*syntax_->generalSubstTable())[event->data()[i]] != arcBase_[j])
228*0Sstevel@tonic-gate match = 0;
229*0Sstevel@tonic-gate if (i >= event->dataLength() || !syntax_->isS(event->data()[i]))
230*0Sstevel@tonic-gate match = 0;
231*0Sstevel@tonic-gate if (match) {
232*0Sstevel@tonic-gate size_t dataLength = event->dataLength();
233*0Sstevel@tonic-gate const Char *data = event->data();
234*0Sstevel@tonic-gate for (;;) {
235*0Sstevel@tonic-gate while (i < dataLength && syntax_->isS(data[i]))
236*0Sstevel@tonic-gate i++;
237*0Sstevel@tonic-gate if (i >= dataLength)
238*0Sstevel@tonic-gate break;
239*0Sstevel@tonic-gate size_t start = i++;
240*0Sstevel@tonic-gate while (i < dataLength && !syntax_->isS(data[i]))
241*0Sstevel@tonic-gate i++;
242*0Sstevel@tonic-gate StringC name(data + start, i - start);
243*0Sstevel@tonic-gate syntax_->generalSubstTable()->subst(name);
244*0Sstevel@tonic-gate arcProcessors_.resize(arcProcessors_.size() + 1);
245*0Sstevel@tonic-gate arcProcessors_.back().setName(name);
246*0Sstevel@tonic-gate }
247*0Sstevel@tonic-gate }
248*0Sstevel@tonic-gate }
249*0Sstevel@tonic-gate DelegateEventHandler::pi(event);
250*0Sstevel@tonic-gate }
251*0Sstevel@tonic-gate
endProlog(EndPrologEvent * event)252*0Sstevel@tonic-gate void ArcEngineImpl::endProlog(EndPrologEvent *event)
253*0Sstevel@tonic-gate {
254*0Sstevel@tonic-gate currentLocation_ = event->location();
255*0Sstevel@tonic-gate for (size_t i = 0; i < arcProcessors_.size(); i++)
256*0Sstevel@tonic-gate arcProcessors_[i].init(*event,
257*0Sstevel@tonic-gate sd_,
258*0Sstevel@tonic-gate syntax_,
259*0Sstevel@tonic-gate parser_,
260*0Sstevel@tonic-gate this,
261*0Sstevel@tonic-gate docName_,
262*0Sstevel@tonic-gate *director_,
263*0Sstevel@tonic-gate cancelPtr_);
264*0Sstevel@tonic-gate if (!event->lpdPointer().isNull()) {
265*0Sstevel@tonic-gate haveLinkProcess_ = 1;
266*0Sstevel@tonic-gate linkProcess_.init(event->lpdPointer());
267*0Sstevel@tonic-gate }
268*0Sstevel@tonic-gate DelegateEventHandler::endProlog(event);
269*0Sstevel@tonic-gate }
270*0Sstevel@tonic-gate
startDtd(StartDtdEvent * event)271*0Sstevel@tonic-gate void ArcEngineImpl::startDtd(StartDtdEvent *event)
272*0Sstevel@tonic-gate {
273*0Sstevel@tonic-gate stage_++;
274*0Sstevel@tonic-gate DelegateEventHandler::startDtd(event);
275*0Sstevel@tonic-gate }
276*0Sstevel@tonic-gate
endDtd(EndDtdEvent * event)277*0Sstevel@tonic-gate void ArcEngineImpl::endDtd(EndDtdEvent *event)
278*0Sstevel@tonic-gate {
279*0Sstevel@tonic-gate stage_++;
280*0Sstevel@tonic-gate DelegateEventHandler::endDtd(event);
281*0Sstevel@tonic-gate }
282*0Sstevel@tonic-gate
startLpd(StartLpdEvent * event)283*0Sstevel@tonic-gate void ArcEngineImpl::startLpd(StartLpdEvent *event)
284*0Sstevel@tonic-gate {
285*0Sstevel@tonic-gate if (event->active())
286*0Sstevel@tonic-gate stage_ = 1;
287*0Sstevel@tonic-gate DelegateEventHandler::startLpd(event);
288*0Sstevel@tonic-gate }
289*0Sstevel@tonic-gate
endLpd(EndLpdEvent * event)290*0Sstevel@tonic-gate void ArcEngineImpl::endLpd(EndLpdEvent *event)
291*0Sstevel@tonic-gate {
292*0Sstevel@tonic-gate stage_++;
293*0Sstevel@tonic-gate DelegateEventHandler::endLpd(event);
294*0Sstevel@tonic-gate }
295*0Sstevel@tonic-gate
sgmlDecl(SgmlDeclEvent * event)296*0Sstevel@tonic-gate void ArcEngineImpl::sgmlDecl(SgmlDeclEvent *event)
297*0Sstevel@tonic-gate {
298*0Sstevel@tonic-gate currentLocation_ = event->location();
299*0Sstevel@tonic-gate sd_ = event->sdPointer();
300*0Sstevel@tonic-gate syntax_ = event->instanceSyntaxPointer();
301*0Sstevel@tonic-gate arcBase_ = sd_->execToInternal("ArcBase");
302*0Sstevel@tonic-gate syntax_->generalSubstTable()->subst(arcBase_);
303*0Sstevel@tonic-gate is10744_ = sd_->execToInternal("IS10744");
304*0Sstevel@tonic-gate Boolean atStart = 1;
305*0Sstevel@tonic-gate for (size_t i = 0; i < appinfo_.size(); i++)
306*0Sstevel@tonic-gate if (syntax_->isS(appinfo_[i]))
307*0Sstevel@tonic-gate atStart = 1;
308*0Sstevel@tonic-gate else if (atStart) {
309*0Sstevel@tonic-gate if (i + 7 > appinfo_.size())
310*0Sstevel@tonic-gate break;
311*0Sstevel@tonic-gate StringC tem(appinfo_.data() + i, 7);
312*0Sstevel@tonic-gate syntax_->generalSubstTable()->subst(tem);
313*0Sstevel@tonic-gate if (tem == arcBase_) {
314*0Sstevel@tonic-gate if (i + 7 == appinfo_.size() || syntax_->isS(appinfo_[i + 7]))
315*0Sstevel@tonic-gate break;
316*0Sstevel@tonic-gate if (appinfo_[i + 7] == sd_->execToInternal('=')) {
317*0Sstevel@tonic-gate arcBase_.resize(0);
318*0Sstevel@tonic-gate for (size_t j = i + 7; j < appinfo_.size(); j++) {
319*0Sstevel@tonic-gate if (syntax_->isS(appinfo_[j]))
320*0Sstevel@tonic-gate break;
321*0Sstevel@tonic-gate arcBase_ += appinfo_[j];
322*0Sstevel@tonic-gate }
323*0Sstevel@tonic-gate // Allow quotes around replacement name.
324*0Sstevel@tonic-gate if (arcBase_.size() > 2
325*0Sstevel@tonic-gate && (arcBase_[0] == sd_->execToInternal('"')
326*0Sstevel@tonic-gate || arcBase_[0] == sd_->execToInternal('\''))
327*0Sstevel@tonic-gate && arcBase_[arcBase_.size() - 1] == arcBase_[0]) {
328*0Sstevel@tonic-gate for (size_t j = 0; j < arcBase_.size() - 2; j++)
329*0Sstevel@tonic-gate arcBase_[j] = arcBase_[j + 1];
330*0Sstevel@tonic-gate arcBase_.resize(arcBase_.size() - 2);
331*0Sstevel@tonic-gate }
332*0Sstevel@tonic-gate syntax_->generalSubstTable()->subst(arcBase_);
333*0Sstevel@tonic-gate break;
334*0Sstevel@tonic-gate }
335*0Sstevel@tonic-gate }
336*0Sstevel@tonic-gate atStart = 0;
337*0Sstevel@tonic-gate }
338*0Sstevel@tonic-gate DelegateEventHandler::sgmlDecl(event);
339*0Sstevel@tonic-gate }
340*0Sstevel@tonic-gate
startElement(StartElementEvent * event)341*0Sstevel@tonic-gate void ArcEngineImpl::startElement(StartElementEvent *event)
342*0Sstevel@tonic-gate {
343*0Sstevel@tonic-gate if (gatheringContent_) {
344*0Sstevel@tonic-gate gatheringContent_++;
345*0Sstevel@tonic-gate DelegateEventHandler::startElement(event);
346*0Sstevel@tonic-gate return;
347*0Sstevel@tonic-gate }
348*0Sstevel@tonic-gate currentLocation_ = event->location();
349*0Sstevel@tonic-gate const Text *contentP;
350*0Sstevel@tonic-gate size_t start;
351*0Sstevel@tonic-gate if (startAgain_) {
352*0Sstevel@tonic-gate start = startAgain_ - 1;
353*0Sstevel@tonic-gate contentP = &content_;
354*0Sstevel@tonic-gate startAgain_ = 0;
355*0Sstevel@tonic-gate }
356*0Sstevel@tonic-gate else {
357*0Sstevel@tonic-gate contentP = 0;
358*0Sstevel@tonic-gate start = 0;
359*0Sstevel@tonic-gate if (haveLinkProcess_) {
360*0Sstevel@tonic-gate const ResultElementSpec *resultElementSpec;
361*0Sstevel@tonic-gate linkProcess_.startElement(event->elementType(),
362*0Sstevel@tonic-gate event->attributes(),
363*0Sstevel@tonic-gate event->location(),
364*0Sstevel@tonic-gate *this, // Messenger &
365*0Sstevel@tonic-gate linkAttributes_,
366*0Sstevel@tonic-gate resultElementSpec);
367*0Sstevel@tonic-gate }
368*0Sstevel@tonic-gate else
369*0Sstevel@tonic-gate linkAttributes_ = 0;
370*0Sstevel@tonic-gate }
371*0Sstevel@tonic-gate for (size_t i = start; i < arcProcessors_.size(); i++) {
372*0Sstevel@tonic-gate if (arcProcessors_[i].valid()) {
373*0Sstevel@tonic-gate if (!arcProcessors_[i].processStartElement(*event,
374*0Sstevel@tonic-gate linkAttributes_,
375*0Sstevel@tonic-gate contentP,
376*0Sstevel@tonic-gate alloc_)) {
377*0Sstevel@tonic-gate ASSERT(contentP == 0);
378*0Sstevel@tonic-gate startAgain_ = i + 1;
379*0Sstevel@tonic-gate gatheringContent_ = 1;
380*0Sstevel@tonic-gate delegateTo_ = &eventQueue_;
381*0Sstevel@tonic-gate DelegateEventHandler::startElement(event);
382*0Sstevel@tonic-gate return;
383*0Sstevel@tonic-gate }
384*0Sstevel@tonic-gate }
385*0Sstevel@tonic-gate }
386*0Sstevel@tonic-gate
387*0Sstevel@tonic-gate content_.clear();
388*0Sstevel@tonic-gate DelegateEventHandler::startElement(event);
389*0Sstevel@tonic-gate }
390*0Sstevel@tonic-gate
data(DataEvent * event)391*0Sstevel@tonic-gate void ArcEngineImpl::data(DataEvent *event)
392*0Sstevel@tonic-gate {
393*0Sstevel@tonic-gate const Entity *entity = event->entity();
394*0Sstevel@tonic-gate if (gatheringContent_) {
395*0Sstevel@tonic-gate if (entity)
396*0Sstevel@tonic-gate content_.addCdata(entity->asInternalEntity(),
397*0Sstevel@tonic-gate event->location().origin());
398*0Sstevel@tonic-gate else {
399*0Sstevel@tonic-gate // Do attribute value literal interpretation.
400*0Sstevel@tonic-gate Location loc(event->location());
401*0Sstevel@tonic-gate for (size_t i = 0; i < event->dataLength(); i++, loc += 1) {
402*0Sstevel@tonic-gate Char ch = event->data()[i];
403*0Sstevel@tonic-gate if (syntax_->isS(ch) && ch != syntax_->space()) {
404*0Sstevel@tonic-gate if (ch == syntax_->standardFunction(Syntax::fRS))
405*0Sstevel@tonic-gate content_.ignoreChar(ch, loc);
406*0Sstevel@tonic-gate else
407*0Sstevel@tonic-gate content_.addChar(syntax_->space(),
408*0Sstevel@tonic-gate Location(new ReplacementOrigin(loc, ch), 0));
409*0Sstevel@tonic-gate }
410*0Sstevel@tonic-gate else
411*0Sstevel@tonic-gate content_.addChar(ch, loc);
412*0Sstevel@tonic-gate }
413*0Sstevel@tonic-gate }
414*0Sstevel@tonic-gate }
415*0Sstevel@tonic-gate else {
416*0Sstevel@tonic-gate currentLocation_ = event->location();
417*0Sstevel@tonic-gate for (size_t i = 0; i < arcProcessors_.size(); i++) {
418*0Sstevel@tonic-gate if (arcProcessors_[i].valid() && arcProcessors_[i].processData()) {
419*0Sstevel@tonic-gate if (entity)
420*0Sstevel@tonic-gate arcProcessors_[i].docHandler()
421*0Sstevel@tonic-gate .data(new (alloc_) CdataEntityEvent(entity->asInternalEntity(),
422*0Sstevel@tonic-gate event->location().origin()));
423*0Sstevel@tonic-gate else
424*0Sstevel@tonic-gate arcProcessors_[i].docHandler()
425*0Sstevel@tonic-gate .data(new (alloc_) ImmediateDataEvent(event->type(),
426*0Sstevel@tonic-gate event->data(),
427*0Sstevel@tonic-gate event->dataLength(),
428*0Sstevel@tonic-gate event->location(),
429*0Sstevel@tonic-gate 0));
430*0Sstevel@tonic-gate }
431*0Sstevel@tonic-gate }
432*0Sstevel@tonic-gate }
433*0Sstevel@tonic-gate DelegateEventHandler::data(event);
434*0Sstevel@tonic-gate }
435*0Sstevel@tonic-gate
sdataEntity(SdataEntityEvent * event)436*0Sstevel@tonic-gate void ArcEngineImpl::sdataEntity(SdataEntityEvent *event)
437*0Sstevel@tonic-gate {
438*0Sstevel@tonic-gate if (gatheringContent_) {
439*0Sstevel@tonic-gate content_.addSdata(event->entity()->asInternalEntity(),
440*0Sstevel@tonic-gate event->location().origin());
441*0Sstevel@tonic-gate return;
442*0Sstevel@tonic-gate }
443*0Sstevel@tonic-gate else {
444*0Sstevel@tonic-gate currentLocation_ = event->location();
445*0Sstevel@tonic-gate for (size_t i = 0; i < arcProcessors_.size(); i++) {
446*0Sstevel@tonic-gate if (arcProcessors_[i].valid() && arcProcessors_[i].processData()) {
447*0Sstevel@tonic-gate const Entity *entity = event->entity();
448*0Sstevel@tonic-gate arcProcessors_[i].docHandler()
449*0Sstevel@tonic-gate .sdataEntity(new (alloc_)
450*0Sstevel@tonic-gate SdataEntityEvent(entity->asInternalEntity(),
451*0Sstevel@tonic-gate event->location().origin()));
452*0Sstevel@tonic-gate }
453*0Sstevel@tonic-gate }
454*0Sstevel@tonic-gate }
455*0Sstevel@tonic-gate DelegateEventHandler::sdataEntity(event);
456*0Sstevel@tonic-gate }
457*0Sstevel@tonic-gate
externalDataEntity(ExternalDataEntityEvent * event)458*0Sstevel@tonic-gate void ArcEngineImpl::externalDataEntity(ExternalDataEntityEvent *event)
459*0Sstevel@tonic-gate {
460*0Sstevel@tonic-gate if (!gatheringContent_) {
461*0Sstevel@tonic-gate currentLocation_ = event->location();
462*0Sstevel@tonic-gate for (size_t i = 0; i < arcProcessors_.size(); i++) {
463*0Sstevel@tonic-gate if (arcProcessors_[i].valid()
464*0Sstevel@tonic-gate && arcProcessors_[i].processData()) {
465*0Sstevel@tonic-gate ConstPtr<Entity> entity
466*0Sstevel@tonic-gate = arcProcessors_[i].dtdPointer()
467*0Sstevel@tonic-gate ->lookupEntity(0, event->entity()->name());
468*0Sstevel@tonic-gate if (!entity.isNull()) {
469*0Sstevel@tonic-gate ConstPtr<EntityOrigin> oldOrigin = event->entityOrigin();
470*0Sstevel@tonic-gate Owner<Markup> markup;
471*0Sstevel@tonic-gate if (oldOrigin->markup())
472*0Sstevel@tonic-gate markup = new Markup(*oldOrigin->markup());
473*0Sstevel@tonic-gate ConstPtr<EntityOrigin> newOrigin
474*0Sstevel@tonic-gate = EntityOrigin::make(entity,
475*0Sstevel@tonic-gate oldOrigin->parent(),
476*0Sstevel@tonic-gate oldOrigin->refLength(),
477*0Sstevel@tonic-gate markup);
478*0Sstevel@tonic-gate arcProcessors_[i].docHandler()
479*0Sstevel@tonic-gate .externalDataEntity(new (alloc_)
480*0Sstevel@tonic-gate ExternalDataEntityEvent(entity->asExternalDataEntity(),
481*0Sstevel@tonic-gate newOrigin));
482*0Sstevel@tonic-gate }
483*0Sstevel@tonic-gate // otherwise entity is not architectural
484*0Sstevel@tonic-gate }
485*0Sstevel@tonic-gate }
486*0Sstevel@tonic-gate }
487*0Sstevel@tonic-gate DelegateEventHandler::externalDataEntity(event);
488*0Sstevel@tonic-gate }
489*0Sstevel@tonic-gate
endElement(EndElementEvent * event)490*0Sstevel@tonic-gate void ArcEngineImpl::endElement(EndElementEvent *event)
491*0Sstevel@tonic-gate {
492*0Sstevel@tonic-gate while (gatheringContent_) {
493*0Sstevel@tonic-gate if (--gatheringContent_ > 0) {
494*0Sstevel@tonic-gate DelegateEventHandler::endElement(event);
495*0Sstevel@tonic-gate return;
496*0Sstevel@tonic-gate }
497*0Sstevel@tonic-gate delegateTo_ = delegateHandler();
498*0Sstevel@tonic-gate // Clear out eventQueue_ in case handling the events
499*0Sstevel@tonic-gate // causes events to be queued again.
500*0Sstevel@tonic-gate IQueue<Event> tem;
501*0Sstevel@tonic-gate tem.swap(eventQueue_);
502*0Sstevel@tonic-gate while (!tem.empty())
503*0Sstevel@tonic-gate tem.get()->handle(*this);
504*0Sstevel@tonic-gate }
505*0Sstevel@tonic-gate currentLocation_ = event->location();
506*0Sstevel@tonic-gate for (size_t i = 0; i < arcProcessors_.size(); i++)
507*0Sstevel@tonic-gate if (arcProcessors_[i].valid())
508*0Sstevel@tonic-gate arcProcessors_[i].processEndElement(*event, alloc_);
509*0Sstevel@tonic-gate DelegateEventHandler::endElement(event);
510*0Sstevel@tonic-gate if (haveLinkProcess_)
511*0Sstevel@tonic-gate linkProcess_.endElement();
512*0Sstevel@tonic-gate }
513*0Sstevel@tonic-gate
uselink(UselinkEvent * event)514*0Sstevel@tonic-gate void ArcEngineImpl::uselink(UselinkEvent *event)
515*0Sstevel@tonic-gate {
516*0Sstevel@tonic-gate if (!gatheringContent_)
517*0Sstevel@tonic-gate linkProcess_.uselink(event->linkSet(),
518*0Sstevel@tonic-gate event->restore(),
519*0Sstevel@tonic-gate event->lpd().pointer());
520*0Sstevel@tonic-gate DelegateEventHandler::uselink(event);
521*0Sstevel@tonic-gate }
522*0Sstevel@tonic-gate
dispatchMessage(const Message & msg)523*0Sstevel@tonic-gate void ArcEngineImpl::dispatchMessage(const Message &msg)
524*0Sstevel@tonic-gate {
525*0Sstevel@tonic-gate mgr_->dispatchMessage(msg);
526*0Sstevel@tonic-gate }
527*0Sstevel@tonic-gate
dispatchMessage(Message & msg)528*0Sstevel@tonic-gate void ArcEngineImpl::dispatchMessage(Message &msg)
529*0Sstevel@tonic-gate {
530*0Sstevel@tonic-gate mgr_->dispatchMessage(msg);
531*0Sstevel@tonic-gate }
532*0Sstevel@tonic-gate
initMessage(Message & msg)533*0Sstevel@tonic-gate void ArcEngineImpl::initMessage(Message &msg)
534*0Sstevel@tonic-gate {
535*0Sstevel@tonic-gate mgr_->initMessage(msg);
536*0Sstevel@tonic-gate msg.loc = currentLocation_;
537*0Sstevel@tonic-gate }
538*0Sstevel@tonic-gate
ArcProcessor()539*0Sstevel@tonic-gate ArcProcessor::ArcProcessor()
540*0Sstevel@tonic-gate : errorIdref_(1), docHandler_(0), arcAuto_(1),
541*0Sstevel@tonic-gate arcDtdIsParam_(0)
542*0Sstevel@tonic-gate {
543*0Sstevel@tonic-gate }
544*0Sstevel@tonic-gate
setName(const StringC & name)545*0Sstevel@tonic-gate void ArcProcessor::setName(const StringC &name)
546*0Sstevel@tonic-gate {
547*0Sstevel@tonic-gate name_ = name;
548*0Sstevel@tonic-gate }
549*0Sstevel@tonic-gate
attributeSyntax() const550*0Sstevel@tonic-gate const Syntax &ArcProcessor::attributeSyntax() const
551*0Sstevel@tonic-gate {
552*0Sstevel@tonic-gate return *docSyntax_;
553*0Sstevel@tonic-gate }
554*0Sstevel@tonic-gate
getAttributeNotation(const StringC & name,const Location &)555*0Sstevel@tonic-gate ConstPtr<Notation> ArcProcessor::getAttributeNotation(const StringC &name,
556*0Sstevel@tonic-gate const Location &)
557*0Sstevel@tonic-gate {
558*0Sstevel@tonic-gate if (!metaDtd_.isNull())
559*0Sstevel@tonic-gate return metaDtd_->lookupNotation(name);
560*0Sstevel@tonic-gate return 0;
561*0Sstevel@tonic-gate }
562*0Sstevel@tonic-gate
getAttributeEntity(const StringC & name,const Location &)563*0Sstevel@tonic-gate ConstPtr<Entity> ArcProcessor::getAttributeEntity(const StringC &name,
564*0Sstevel@tonic-gate const Location &)
565*0Sstevel@tonic-gate {
566*0Sstevel@tonic-gate // FIXME What about default entity
567*0Sstevel@tonic-gate if (!metaDtd_.isNull())
568*0Sstevel@tonic-gate return metaDtd_->lookupEntity(0, name);
569*0Sstevel@tonic-gate return 0;
570*0Sstevel@tonic-gate }
571*0Sstevel@tonic-gate
noteCurrentAttribute(size_t i,AttributeValue * value)572*0Sstevel@tonic-gate void ArcProcessor::noteCurrentAttribute(size_t i, AttributeValue *value)
573*0Sstevel@tonic-gate {
574*0Sstevel@tonic-gate if (valid_)
575*0Sstevel@tonic-gate currentAttributes_[i] = value;
576*0Sstevel@tonic-gate }
577*0Sstevel@tonic-gate
getCurrentAttribute(size_t i) const578*0Sstevel@tonic-gate ConstPtr<AttributeValue> ArcProcessor::getCurrentAttribute(size_t i) const
579*0Sstevel@tonic-gate {
580*0Sstevel@tonic-gate return currentAttributes_[i];
581*0Sstevel@tonic-gate }
582*0Sstevel@tonic-gate
583*0Sstevel@tonic-gate // This code is the same as in the main parser.
584*0Sstevel@tonic-gate // Once handling of ID/IDREF in architectures has been clarified.
585*0Sstevel@tonic-gate // Maybe factor out into AttributeContext.
586*0Sstevel@tonic-gate
defineId(const StringC & str,const Location & loc,Location & prevLoc)587*0Sstevel@tonic-gate Boolean ArcProcessor::defineId(const StringC &str, const Location &loc,
588*0Sstevel@tonic-gate Location &prevLoc)
589*0Sstevel@tonic-gate {
590*0Sstevel@tonic-gate if (!valid_)
591*0Sstevel@tonic-gate return 1;
592*0Sstevel@tonic-gate Id *id = lookupCreateId(str);
593*0Sstevel@tonic-gate if (id->defined()) {
594*0Sstevel@tonic-gate prevLoc = id->defLocation();
595*0Sstevel@tonic-gate return 0;
596*0Sstevel@tonic-gate }
597*0Sstevel@tonic-gate id->define(loc);
598*0Sstevel@tonic-gate return 1;
599*0Sstevel@tonic-gate }
600*0Sstevel@tonic-gate
noteIdref(const StringC & str,const Location & loc)601*0Sstevel@tonic-gate void ArcProcessor::noteIdref(const StringC &str, const Location &loc)
602*0Sstevel@tonic-gate {
603*0Sstevel@tonic-gate if (!valid_ || !errorIdref_)
604*0Sstevel@tonic-gate return;
605*0Sstevel@tonic-gate Id *id = lookupCreateId(str);
606*0Sstevel@tonic-gate if (!id->defined())
607*0Sstevel@tonic-gate id->addPendingRef(loc);
608*0Sstevel@tonic-gate }
609*0Sstevel@tonic-gate
lookupCreateId(const StringC & name)610*0Sstevel@tonic-gate Id *ArcProcessor::lookupCreateId(const StringC &name)
611*0Sstevel@tonic-gate {
612*0Sstevel@tonic-gate Id *id = idTable_.lookup(name);
613*0Sstevel@tonic-gate if (!id) {
614*0Sstevel@tonic-gate id = new Id(name);
615*0Sstevel@tonic-gate idTable_.insert(id);
616*0Sstevel@tonic-gate }
617*0Sstevel@tonic-gate return id;
618*0Sstevel@tonic-gate }
619*0Sstevel@tonic-gate
checkIdrefs()620*0Sstevel@tonic-gate void ArcProcessor::checkIdrefs()
621*0Sstevel@tonic-gate {
622*0Sstevel@tonic-gate NamedTableIter<Id> iter(idTable_);
623*0Sstevel@tonic-gate Id *id;
624*0Sstevel@tonic-gate while ((id = iter.next()) != 0) {
625*0Sstevel@tonic-gate for (size_t i = 0; i < id->pendingRefs().size(); i++) {
626*0Sstevel@tonic-gate Messenger::setNextLocation(id->pendingRefs()[i]);
627*0Sstevel@tonic-gate message(ArcEngineMessages::missingId, StringMessageArg(id->name()));
628*0Sstevel@tonic-gate }
629*0Sstevel@tonic-gate }
630*0Sstevel@tonic-gate }
631*0Sstevel@tonic-gate
init(const EndPrologEvent & event,const ConstPtr<Sd> & sd,const ConstPtr<Syntax> & syntax,const SgmlParser * parentParser,Messenger * mgr,const Vector<StringC> & superName,ArcDirector & director,const volatile sig_atomic_t * cancelPtr)632*0Sstevel@tonic-gate void ArcProcessor::init(const EndPrologEvent &event,
633*0Sstevel@tonic-gate const ConstPtr<Sd> &sd,
634*0Sstevel@tonic-gate const ConstPtr<Syntax> &syntax,
635*0Sstevel@tonic-gate const SgmlParser *parentParser,
636*0Sstevel@tonic-gate Messenger *mgr,
637*0Sstevel@tonic-gate const Vector<StringC> &superName,
638*0Sstevel@tonic-gate ArcDirector &director,
639*0Sstevel@tonic-gate const volatile sig_atomic_t *cancelPtr)
640*0Sstevel@tonic-gate {
641*0Sstevel@tonic-gate director_ = &director;
642*0Sstevel@tonic-gate mgr_ = mgr;
643*0Sstevel@tonic-gate docSyntax_ = syntax;
644*0Sstevel@tonic-gate docSd_ = sd;
645*0Sstevel@tonic-gate mgr_ = mgr;
646*0Sstevel@tonic-gate valid_ = 0;
647*0Sstevel@tonic-gate docDtd_ = event.dtdPointer();
648*0Sstevel@tonic-gate metaSyntax_ = docSyntax_;
649*0Sstevel@tonic-gate mayDefaultAttribute_ = 1;
650*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(name_);
651*0Sstevel@tonic-gate Vector<StringC> docName(superName);
652*0Sstevel@tonic-gate docName.push_back(name_);
653*0Sstevel@tonic-gate ConstPtr<Notation> notation;
654*0Sstevel@tonic-gate notation = docDtd_->lookupNotation(name_);
655*0Sstevel@tonic-gate if (!notation.isNull()) {
656*0Sstevel@tonic-gate ConstPtr<AttributeDefinitionList> notAttDef = notation->attributeDef();
657*0Sstevel@tonic-gate attributeList_.init(notAttDef);
658*0Sstevel@tonic-gate attributeList_.finish(*this);
659*0Sstevel@tonic-gate supportAttributes(attributeList_);
660*0Sstevel@tonic-gate }
661*0Sstevel@tonic-gate else
662*0Sstevel@tonic-gate message(ArcEngineMessages::noArcNotation, StringMessageArg(name_));
663*0Sstevel@tonic-gate ArcEngineImpl *engine
664*0Sstevel@tonic-gate = new ArcEngineImpl(*mgr, parentParser, director, cancelPtr,
665*0Sstevel@tonic-gate notation.pointer(),
666*0Sstevel@tonic-gate docName,
667*0Sstevel@tonic-gate docSyntax_->generalSubstTable());
668*0Sstevel@tonic-gate docHandler_ = engine;
669*0Sstevel@tonic-gate ownEventHandler_ = engine;
670*0Sstevel@tonic-gate if (supportAtts_[rArcDocF].size() == 0)
671*0Sstevel@tonic-gate supportAtts_[rArcDocF] = name_;
672*0Sstevel@tonic-gate if (supportAtts_[rArcFormA].size() == 0)
673*0Sstevel@tonic-gate supportAtts_[rArcFormA] = name_;
674*0Sstevel@tonic-gate rniContent_ = docSyntax_->delimGeneral(Syntax::dRNI);
675*0Sstevel@tonic-gate rniContent_ += sd->execToInternal("CONTENT");
676*0Sstevel@tonic-gate rniDefault_ = docSyntax_->delimGeneral(Syntax::dRNI);
677*0Sstevel@tonic-gate rniDefault_ += docSyntax_->reservedName(Syntax::rDEFAULT);
678*0Sstevel@tonic-gate rniArcCont_ = metaSyntax_->delimGeneral(Syntax::dRNI);
679*0Sstevel@tonic-gate rniArcCont_ += sd->execToInternal("ARCCONT");
680*0Sstevel@tonic-gate ConstPtr<Entity> dtdent = makeDtdEntity(notation.pointer());
681*0Sstevel@tonic-gate if (dtdent.isNull())
682*0Sstevel@tonic-gate return;
683*0Sstevel@tonic-gate StringC sysid = dtdent->asExternalEntity()->externalId().effectiveSystemId();
684*0Sstevel@tonic-gate if (sysid.size() == 0
685*0Sstevel@tonic-gate && !parentParser->entityCatalog().lookup(*dtdent,
686*0Sstevel@tonic-gate *docSyntax_,
687*0Sstevel@tonic-gate sd->internalCharset(),
688*0Sstevel@tonic-gate *mgr_,
689*0Sstevel@tonic-gate sysid)) {
690*0Sstevel@tonic-gate message(ArcEngineMessages::arcGenerateSystemId,
691*0Sstevel@tonic-gate StringMessageArg(name_));
692*0Sstevel@tonic-gate return;
693*0Sstevel@tonic-gate }
694*0Sstevel@tonic-gate docHandler_->sgmlDecl(new SgmlDeclEvent(sd, syntax));
695*0Sstevel@tonic-gate docHandler_->startDtd(new StartDtdEvent(dtdent->name(),
696*0Sstevel@tonic-gate dtdent,
697*0Sstevel@tonic-gate 0,
698*0Sstevel@tonic-gate event.location(),
699*0Sstevel@tonic-gate 0));
700*0Sstevel@tonic-gate SgmlParser::Params params;
701*0Sstevel@tonic-gate params.entityType = SgmlParser::Params::dtd;
702*0Sstevel@tonic-gate params.sysid = sysid;
703*0Sstevel@tonic-gate params.parent = parentParser;
704*0Sstevel@tonic-gate ParserOptions options = parentParser->options();
705*0Sstevel@tonic-gate errorIdref_ = options.errorIdref;
706*0Sstevel@tonic-gate options.errorAfdr = 0;
707*0Sstevel@tonic-gate options.includes = arcOpts_;
708*0Sstevel@tonic-gate params.options = &options;
709*0Sstevel@tonic-gate params.sd = docSd_;
710*0Sstevel@tonic-gate if (metaSyntax_->reservedName(Syntax::rALL).size() == 0) {
711*0Sstevel@tonic-gate Ptr<Syntax> tem(new Syntax(*metaSyntax_));
712*0Sstevel@tonic-gate tem->setName(Syntax::rALL, docSd_->execToInternal("ALL"));
713*0Sstevel@tonic-gate metaSyntax_ = tem;
714*0Sstevel@tonic-gate }
715*0Sstevel@tonic-gate params.prologSyntax = metaSyntax_;
716*0Sstevel@tonic-gate params.instanceSyntax = metaSyntax_;
717*0Sstevel@tonic-gate params.doctypeName = dtdent->name();
718*0Sstevel@tonic-gate SgmlParser parser(params);
719*0Sstevel@tonic-gate parser.parseAll(*docHandler_, cancelPtr);
720*0Sstevel@tonic-gate Ptr<Dtd> baseDtd = parser.baseDtd();
721*0Sstevel@tonic-gate if (baseDtd.isNull()
722*0Sstevel@tonic-gate || baseDtd->documentElementType()->definition()->undefined())
723*0Sstevel@tonic-gate return;
724*0Sstevel@tonic-gate metaDtd_ = baseDtd;
725*0Sstevel@tonic-gate metaMapCache_.resize(docDtd_->nElementTypeIndex());
726*0Sstevel@tonic-gate mungeMetaDtd(*baseDtd, *docDtd_);
727*0Sstevel@tonic-gate docHandler_->endDtd(new EndDtdEvent(metaDtd_, event.location(), 0));
728*0Sstevel@tonic-gate startContent(*metaDtd_);
729*0Sstevel@tonic-gate currentAttributes_.resize(metaDtd_->nCurrentAttribute());
730*0Sstevel@tonic-gate valid_ = 1;
731*0Sstevel@tonic-gate docHandler_->endProlog(new EndPrologEvent(metaDtd_, event.location()));
732*0Sstevel@tonic-gate if (engine->nBases() == 0)
733*0Sstevel@tonic-gate docHandler_ = engine->delegateHandler();
734*0Sstevel@tonic-gate }
735*0Sstevel@tonic-gate
mungeMetaDtd(Dtd & metaDtd,const Dtd & docDtd)736*0Sstevel@tonic-gate void ArcProcessor::mungeMetaDtd(Dtd &metaDtd, const Dtd &docDtd)
737*0Sstevel@tonic-gate {
738*0Sstevel@tonic-gate if (supportAtts_[rArcDataF].size() > 0
739*0Sstevel@tonic-gate && metaDtd.lookupNotation(supportAtts_[rArcDataF]).isNull()) {
740*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::noArcDataF,
741*0Sstevel@tonic-gate StringMessageArg(supportAtts_[rArcDataF]));
742*0Sstevel@tonic-gate metaDtd.insertNotation(new Notation(supportAtts_[rArcDataF],
743*0Sstevel@tonic-gate metaDtd.namePointer(),
744*0Sstevel@tonic-gate metaDtd.isBase()));
745*0Sstevel@tonic-gate }
746*0Sstevel@tonic-gate // FIXME check for ArcAutoF
747*0Sstevel@tonic-gate Dtd::ConstEntityIter iter(docDtd.generalEntityIter());
748*0Sstevel@tonic-gate for (;;) {
749*0Sstevel@tonic-gate ConstPtr<Entity> ent = iter.next();
750*0Sstevel@tonic-gate if (ent.isNull())
751*0Sstevel@tonic-gate break;
752*0Sstevel@tonic-gate Ptr<Entity> copy(ent->copy());
753*0Sstevel@tonic-gate if (!copy->asExternalDataEntity()
754*0Sstevel@tonic-gate || mungeDataEntity(*(ExternalDataEntity *)copy.pointer()))
755*0Sstevel@tonic-gate metaDtd.insertEntity(copy, 1);
756*0Sstevel@tonic-gate }
757*0Sstevel@tonic-gate }
758*0Sstevel@tonic-gate
mungeDataEntity(ExternalDataEntity & entity)759*0Sstevel@tonic-gate Boolean ArcProcessor::mungeDataEntity(ExternalDataEntity &entity)
760*0Sstevel@tonic-gate {
761*0Sstevel@tonic-gate const MetaMap &map = buildMetaMap(0,
762*0Sstevel@tonic-gate entity.notation(),
763*0Sstevel@tonic-gate entity.attributes(),
764*0Sstevel@tonic-gate 0,
765*0Sstevel@tonic-gate 0);
766*0Sstevel@tonic-gate if (!map.attributed)
767*0Sstevel@tonic-gate return 0;
768*0Sstevel@tonic-gate AttributeList atts;
769*0Sstevel@tonic-gate const Notation *notation = (const Notation *)map.attributed;
770*0Sstevel@tonic-gate ConstPtr<AttributeValue> arcContent;
771*0Sstevel@tonic-gate if (mapAttributes(entity.attributes(), 0, 0, atts, arcContent, map)) {
772*0Sstevel@tonic-gate // FIXME check arcContent
773*0Sstevel@tonic-gate entity.setNotation((Notation *)notation, atts);
774*0Sstevel@tonic-gate return 1;
775*0Sstevel@tonic-gate }
776*0Sstevel@tonic-gate // FIXME error tried to use #CONTENT
777*0Sstevel@tonic-gate return 0;
778*0Sstevel@tonic-gate }
779*0Sstevel@tonic-gate
makeDtdEntity(const Notation *)780*0Sstevel@tonic-gate ConstPtr<Entity> ArcProcessor::makeDtdEntity(const Notation *)
781*0Sstevel@tonic-gate {
782*0Sstevel@tonic-gate if (!supportAtts_[rArcDTD].size()) {
783*0Sstevel@tonic-gate mgr_->message(ArcEngineMessages::noArcDTDAtt);
784*0Sstevel@tonic-gate return 0;
785*0Sstevel@tonic-gate }
786*0Sstevel@tonic-gate ConstPtr<Entity> entity = docDtd_->lookupEntity(arcDtdIsParam_,
787*0Sstevel@tonic-gate supportAtts_[rArcDTD]);
788*0Sstevel@tonic-gate if (entity.isNull()) {
789*0Sstevel@tonic-gate mgr_->message(arcDtdIsParam_
790*0Sstevel@tonic-gate ? ArcEngineMessages::arcDtdNotDeclaredParameter
791*0Sstevel@tonic-gate : ArcEngineMessages::arcDtdNotDeclaredParameter,
792*0Sstevel@tonic-gate StringMessageArg(supportAtts_[rArcDTD]));
793*0Sstevel@tonic-gate return 0;
794*0Sstevel@tonic-gate }
795*0Sstevel@tonic-gate if (!entity->asExternalEntity()) {
796*0Sstevel@tonic-gate mgr_->message(ArcEngineMessages::arcDtdNotExternal,
797*0Sstevel@tonic-gate StringMessageArg(supportAtts_[rArcDTD]));
798*0Sstevel@tonic-gate return 0;
799*0Sstevel@tonic-gate }
800*0Sstevel@tonic-gate ExternalId externalId(entity->asExternalEntity()->externalId());
801*0Sstevel@tonic-gate #if 0
802*0Sstevel@tonic-gate // Use the public identifier of the notation to find the meta-DTD.
803*0Sstevel@tonic-gate if (externalId.effectiveSystemId().size() == 0 && notation) {
804*0Sstevel@tonic-gate if (notation->externalId().effectiveSystemId().size()) {
805*0Sstevel@tonic-gate StringC tem(notation->externalId().effectiveSystemId());
806*0Sstevel@tonic-gate externalId.setEffectiveSystem(tem);
807*0Sstevel@tonic-gate }
808*0Sstevel@tonic-gate else if (!externalId.publicId()) {
809*0Sstevel@tonic-gate const PublicId *pubid = notation->externalId().publicId();
810*0Sstevel@tonic-gate PublicId::OwnerType ownerType;
811*0Sstevel@tonic-gate if (pubid && pubid->getOwnerType(ownerType)) {
812*0Sstevel@tonic-gate Text pubidText;
813*0Sstevel@tonic-gate unsigned textClassPos = 2;
814*0Sstevel@tonic-gate if (ownerType != PublicId::ISO)
815*0Sstevel@tonic-gate textClassPos += 3;
816*0Sstevel@tonic-gate StringC owner;
817*0Sstevel@tonic-gate pubid->getOwner(owner);
818*0Sstevel@tonic-gate textClassPos += owner.size();
819*0Sstevel@tonic-gate pubidText.addChars(pubid->string().data(),
820*0Sstevel@tonic-gate textClassPos,
821*0Sstevel@tonic-gate pubid->text().charLocation(0));
822*0Sstevel@tonic-gate pubidText.addChars(docSd_->execToInternal("DTD"),
823*0Sstevel@tonic-gate pubid->text().charLocation(textClassPos));
824*0Sstevel@tonic-gate for (; textClassPos < pubid->string().size(); textClassPos++)
825*0Sstevel@tonic-gate if (pubid->string()[textClassPos] == docSyntax_->space())
826*0Sstevel@tonic-gate break;
827*0Sstevel@tonic-gate pubidText.addChars(pubid->string().data() + textClassPos,
828*0Sstevel@tonic-gate pubid->string().size() - textClassPos,
829*0Sstevel@tonic-gate pubid->text().charLocation(textClassPos));
830*0Sstevel@tonic-gate const MessageType1 *msg;
831*0Sstevel@tonic-gate externalId.setPublic(pubidText, docSd_->internalCharset(),
832*0Sstevel@tonic-gate docSyntax_->space(), msg);
833*0Sstevel@tonic-gate }
834*0Sstevel@tonic-gate }
835*0Sstevel@tonic-gate }
836*0Sstevel@tonic-gate #endif
837*0Sstevel@tonic-gate return new ExternalTextEntity(supportAtts_[rArcDocF],
838*0Sstevel@tonic-gate Entity::doctype,
839*0Sstevel@tonic-gate entity->defLocation(),
840*0Sstevel@tonic-gate externalId);
841*0Sstevel@tonic-gate }
842*0Sstevel@tonic-gate
supportAttributes(const AttributeList & atts)843*0Sstevel@tonic-gate void ArcProcessor::supportAttributes(const AttributeList &atts)
844*0Sstevel@tonic-gate {
845*0Sstevel@tonic-gate static const char *const s[] = {
846*0Sstevel@tonic-gate "ArcFormA",
847*0Sstevel@tonic-gate "ArcNamrA",
848*0Sstevel@tonic-gate "ArcSuprA",
849*0Sstevel@tonic-gate "ArcIgnDA",
850*0Sstevel@tonic-gate "ArcDocF",
851*0Sstevel@tonic-gate "ArcSuprF",
852*0Sstevel@tonic-gate "ArcBridF",
853*0Sstevel@tonic-gate "ArcDataF",
854*0Sstevel@tonic-gate "ArcAuto",
855*0Sstevel@tonic-gate "ArcIndr",
856*0Sstevel@tonic-gate "ArcDTD",
857*0Sstevel@tonic-gate "ArcQuant",
858*0Sstevel@tonic-gate };
859*0Sstevel@tonic-gate for (size_t i = 0; i < SIZEOF(s); i++) {
860*0Sstevel@tonic-gate StringC attName(docSd_->execToInternal(s[i]));
861*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(attName);
862*0Sstevel@tonic-gate unsigned ind;
863*0Sstevel@tonic-gate if (atts.attributeIndex(attName, ind)) {
864*0Sstevel@tonic-gate const AttributeValue *value = atts.value(ind);
865*0Sstevel@tonic-gate if (value) {
866*0Sstevel@tonic-gate const Text *textP = value->text();
867*0Sstevel@tonic-gate // FIXME check for empty value
868*0Sstevel@tonic-gate if (textP) {
869*0Sstevel@tonic-gate supportAtts_[i] = textP->string();
870*0Sstevel@tonic-gate switch (i) {
871*0Sstevel@tonic-gate case rArcQuant:
872*0Sstevel@tonic-gate processArcQuant(*textP);
873*0Sstevel@tonic-gate break;
874*0Sstevel@tonic-gate case rArcAuto:
875*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(supportAtts_[i]);
876*0Sstevel@tonic-gate if (supportAtts_[i] == docSd_->execToInternal("ARCAUTO"))
877*0Sstevel@tonic-gate arcAuto_ = 1;
878*0Sstevel@tonic-gate else if (supportAtts_[i] == docSd_->execToInternal("NARCAUTO"))
879*0Sstevel@tonic-gate arcAuto_ = 0;
880*0Sstevel@tonic-gate else
881*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidArcAuto,
882*0Sstevel@tonic-gate StringMessageArg(supportAtts_[i]));
883*0Sstevel@tonic-gate break;
884*0Sstevel@tonic-gate case rArcIndr:
885*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(supportAtts_[i]);
886*0Sstevel@tonic-gate if (supportAtts_[i] == docSd_->execToInternal("ARCINDR")) {
887*0Sstevel@tonic-gate Messenger::setNextLocation(textP->charLocation(0));
888*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::arcIndrNotSupported);
889*0Sstevel@tonic-gate }
890*0Sstevel@tonic-gate else if (supportAtts_[i] != docSd_->execToInternal("NARCINDR")) {
891*0Sstevel@tonic-gate Messenger::setNextLocation(textP->charLocation(0));
892*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidArcIndr,
893*0Sstevel@tonic-gate StringMessageArg(supportAtts_[i]));
894*0Sstevel@tonic-gate }
895*0Sstevel@tonic-gate break;
896*0Sstevel@tonic-gate case rArcFormA:
897*0Sstevel@tonic-gate case rArcNamrA:
898*0Sstevel@tonic-gate case rArcSuprA:
899*0Sstevel@tonic-gate case rArcIgnDA:
900*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(supportAtts_[i]);
901*0Sstevel@tonic-gate break;
902*0Sstevel@tonic-gate case rArcDocF:
903*0Sstevel@tonic-gate case rArcSuprF:
904*0Sstevel@tonic-gate case rArcBridF:
905*0Sstevel@tonic-gate case rArcDataF:
906*0Sstevel@tonic-gate metaSyntax_->generalSubstTable()->subst(supportAtts_[i]);
907*0Sstevel@tonic-gate break;
908*0Sstevel@tonic-gate case rArcDTD:
909*0Sstevel@tonic-gate {
910*0Sstevel@tonic-gate const StringC &pero = docSyntax_->delimGeneral(Syntax::dPERO);
911*0Sstevel@tonic-gate if (supportAtts_[i].size() >= pero.size()) {
912*0Sstevel@tonic-gate StringC tem(supportAtts_[i].data(), pero.size());
913*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(tem);
914*0Sstevel@tonic-gate if (tem == pero) {
915*0Sstevel@tonic-gate arcDtdIsParam_ = 1;
916*0Sstevel@tonic-gate tem.assign(supportAtts_[i].data() + pero.size(),
917*0Sstevel@tonic-gate supportAtts_[i].size() - pero.size());
918*0Sstevel@tonic-gate tem.swap(supportAtts_[i]);
919*0Sstevel@tonic-gate }
920*0Sstevel@tonic-gate }
921*0Sstevel@tonic-gate docSyntax_->entitySubstTable()->subst(supportAtts_[i]);
922*0Sstevel@tonic-gate }
923*0Sstevel@tonic-gate break;
924*0Sstevel@tonic-gate }
925*0Sstevel@tonic-gate }
926*0Sstevel@tonic-gate }
927*0Sstevel@tonic-gate }
928*0Sstevel@tonic-gate }
929*0Sstevel@tonic-gate processArcOpts(atts);
930*0Sstevel@tonic-gate }
931*0Sstevel@tonic-gate
processArcOpts(const AttributeList & atts)932*0Sstevel@tonic-gate void ArcProcessor::processArcOpts(const AttributeList &atts)
933*0Sstevel@tonic-gate {
934*0Sstevel@tonic-gate StringC attName(docSd_->execToInternal("ArcOptSA"));
935*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(attName);
936*0Sstevel@tonic-gate unsigned ind;
937*0Sstevel@tonic-gate Vector<StringC> arcOptA;
938*0Sstevel@tonic-gate Vector<size_t> arcOptAPos;
939*0Sstevel@tonic-gate const Text *arcOptAText = 0;
940*0Sstevel@tonic-gate if (atts.attributeIndex(attName, ind)) {
941*0Sstevel@tonic-gate const AttributeValue *value = atts.value(ind);
942*0Sstevel@tonic-gate if (value) {
943*0Sstevel@tonic-gate arcOptAText = value->text();
944*0Sstevel@tonic-gate if (arcOptAText)
945*0Sstevel@tonic-gate split(*arcOptAText, docSyntax_->space(), arcOptA, arcOptAPos);
946*0Sstevel@tonic-gate }
947*0Sstevel@tonic-gate }
948*0Sstevel@tonic-gate if (!arcOptAText)
949*0Sstevel@tonic-gate arcOptA.push_back(docSd_->execToInternal("ArcOpt"));
950*0Sstevel@tonic-gate for (size_t i = 0; i < arcOptA.size(); i++) {
951*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(arcOptA[i]);
952*0Sstevel@tonic-gate if (atts.attributeIndex(arcOptA[i], ind)) {
953*0Sstevel@tonic-gate const AttributeValue *value = atts.value(ind);
954*0Sstevel@tonic-gate if (value) {
955*0Sstevel@tonic-gate const Text *textP = value->text();
956*0Sstevel@tonic-gate if (textP) {
957*0Sstevel@tonic-gate Vector<StringC> opts;
958*0Sstevel@tonic-gate Vector<size_t> optsPos;
959*0Sstevel@tonic-gate split(*textP, docSyntax_->space(), opts, optsPos);
960*0Sstevel@tonic-gate arcOpts_.insert(arcOpts_.begin(),
961*0Sstevel@tonic-gate opts.begin(), opts.begin() + opts.size());
962*0Sstevel@tonic-gate }
963*0Sstevel@tonic-gate }
964*0Sstevel@tonic-gate }
965*0Sstevel@tonic-gate }
966*0Sstevel@tonic-gate }
967*0Sstevel@tonic-gate
processArcQuant(const Text & text)968*0Sstevel@tonic-gate void ArcProcessor::processArcQuant(const Text &text)
969*0Sstevel@tonic-gate {
970*0Sstevel@tonic-gate Ptr<Syntax> newMetaSyntax;
971*0Sstevel@tonic-gate Vector<StringC> tokens;
972*0Sstevel@tonic-gate Vector<size_t> tokensPos;
973*0Sstevel@tonic-gate split(text, docSyntax_->space(), tokens, tokensPos);
974*0Sstevel@tonic-gate for (size_t i = 0; i < tokens.size(); i++) {
975*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(tokens[i]);
976*0Sstevel@tonic-gate Syntax::Quantity quantityName;
977*0Sstevel@tonic-gate if (!docSd_->lookupQuantityName(tokens[i], quantityName)) {
978*0Sstevel@tonic-gate setNextLocation(text.charLocation(tokensPos[i]));
979*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidQuantity,
980*0Sstevel@tonic-gate StringMessageArg(tokens[i]));
981*0Sstevel@tonic-gate }
982*0Sstevel@tonic-gate else if (i + 1 >= tokens.size()) {
983*0Sstevel@tonic-gate setNextLocation(text.charLocation(tokensPos[i]));
984*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::missingQuantityValue,
985*0Sstevel@tonic-gate StringMessageArg(tokens[i]));
986*0Sstevel@tonic-gate }
987*0Sstevel@tonic-gate else {
988*0Sstevel@tonic-gate i++;
989*0Sstevel@tonic-gate unsigned long val = 0;
990*0Sstevel@tonic-gate if (tokens[i].size() > 8) {
991*0Sstevel@tonic-gate setNextLocation(text.charLocation(tokensPos[i] + 8));
992*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::quantityValueTooLong,
993*0Sstevel@tonic-gate StringMessageArg(tokens[i]));
994*0Sstevel@tonic-gate tokens[i].resize(8);
995*0Sstevel@tonic-gate }
996*0Sstevel@tonic-gate for (size_t j = 0; j < tokens[i].size(); j++) {
997*0Sstevel@tonic-gate int weight = docSd_->digitWeight(tokens[i][j]);
998*0Sstevel@tonic-gate if (weight < 0) {
999*0Sstevel@tonic-gate setNextLocation(text.charLocation(tokensPos[i] + j));
1000*0Sstevel@tonic-gate Char c = tokens[i][j];
1001*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidDigit,
1002*0Sstevel@tonic-gate StringMessageArg(StringC(&c, 1)));
1003*0Sstevel@tonic-gate val = 0;
1004*0Sstevel@tonic-gate break;
1005*0Sstevel@tonic-gate }
1006*0Sstevel@tonic-gate else {
1007*0Sstevel@tonic-gate val *= 10;
1008*0Sstevel@tonic-gate val += weight;
1009*0Sstevel@tonic-gate }
1010*0Sstevel@tonic-gate }
1011*0Sstevel@tonic-gate if (val > docSyntax_->quantity(quantityName)) {
1012*0Sstevel@tonic-gate if (newMetaSyntax.isNull())
1013*0Sstevel@tonic-gate newMetaSyntax = new Syntax(*docSyntax_);
1014*0Sstevel@tonic-gate newMetaSyntax->setQuantity(quantityName, val);
1015*0Sstevel@tonic-gate }
1016*0Sstevel@tonic-gate }
1017*0Sstevel@tonic-gate }
1018*0Sstevel@tonic-gate if (!newMetaSyntax.isNull())
1019*0Sstevel@tonic-gate metaSyntax_ = newMetaSyntax;
1020*0Sstevel@tonic-gate }
1021*0Sstevel@tonic-gate
processStartElement(const StartElementEvent & event,const AttributeList * linkAttributes,const Text * content,Allocator & alloc)1022*0Sstevel@tonic-gate Boolean ArcProcessor::processStartElement(const StartElementEvent &event,
1023*0Sstevel@tonic-gate const AttributeList *linkAttributes,
1024*0Sstevel@tonic-gate const Text *content,
1025*0Sstevel@tonic-gate Allocator &alloc)
1026*0Sstevel@tonic-gate {
1027*0Sstevel@tonic-gate unsigned suppressFlags = (openElementFlags_.size() > 0
1028*0Sstevel@tonic-gate ? (openElementFlags_.back() & ~isArc)
1029*0Sstevel@tonic-gate : (unsigned)condIgnoreData);
1030*0Sstevel@tonic-gate if ((suppressFlags & suppressForm)
1031*0Sstevel@tonic-gate && (suppressFlags & suppressSupr)) {
1032*0Sstevel@tonic-gate // Make this case efficient.
1033*0Sstevel@tonic-gate openElementFlags_.push_back(suppressFlags);
1034*0Sstevel@tonic-gate return 1;
1035*0Sstevel@tonic-gate }
1036*0Sstevel@tonic-gate const AttributeList &atts = event.attributes();
1037*0Sstevel@tonic-gate const MetaMap &map = buildMetaMap(event.elementType(),
1038*0Sstevel@tonic-gate 0,
1039*0Sstevel@tonic-gate atts,
1040*0Sstevel@tonic-gate linkAttributes,
1041*0Sstevel@tonic-gate suppressFlags);
1042*0Sstevel@tonic-gate const ElementType *metaType;
1043*0Sstevel@tonic-gate ConstPtr<AttributeValue> arcContent;
1044*0Sstevel@tonic-gate if (map.attributed == 0) {
1045*0Sstevel@tonic-gate if (!(tagLevel() == 0
1046*0Sstevel@tonic-gate && !currentElement().isFinished())) {
1047*0Sstevel@tonic-gate if (!arcContent.isNull()
1048*0Sstevel@tonic-gate && (currentElement().declaredEmpty()
1049*0Sstevel@tonic-gate || !currentElement().tryTransitionPcdata()))
1050*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidArcContent);
1051*0Sstevel@tonic-gate openElementFlags_.push_back(map.suppressFlags);
1052*0Sstevel@tonic-gate return 1;
1053*0Sstevel@tonic-gate }
1054*0Sstevel@tonic-gate metaType = metaDtd_->documentElementType();
1055*0Sstevel@tonic-gate mgr_->message(ArcEngineMessages::documentElementNotArc,
1056*0Sstevel@tonic-gate StringMessageArg(metaType->name()));
1057*0Sstevel@tonic-gate attributeList_.init(metaType->attributeDef());
1058*0Sstevel@tonic-gate attributeList_.finish(*this);
1059*0Sstevel@tonic-gate }
1060*0Sstevel@tonic-gate else {
1061*0Sstevel@tonic-gate if (!mapAttributes(atts, linkAttributes, content, attributeList_,
1062*0Sstevel@tonic-gate arcContent, map))
1063*0Sstevel@tonic-gate return 0;
1064*0Sstevel@tonic-gate metaType = (const ElementType *)map.attributed;
1065*0Sstevel@tonic-gate suppressFlags = map.suppressFlags;
1066*0Sstevel@tonic-gate }
1067*0Sstevel@tonic-gate StartElementEvent *genEvent
1068*0Sstevel@tonic-gate = new (alloc) StartElementEvent(metaType,
1069*0Sstevel@tonic-gate metaDtd_,
1070*0Sstevel@tonic-gate &attributeList_,
1071*0Sstevel@tonic-gate event.location(),
1072*0Sstevel@tonic-gate 0);
1073*0Sstevel@tonic-gate if (metaType->definition()->undefined())
1074*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::undefinedElement,
1075*0Sstevel@tonic-gate StringMessageArg(metaType->name()));
1076*0Sstevel@tonic-gate else if (elementIsExcluded(metaType))
1077*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::elementExcluded,
1078*0Sstevel@tonic-gate StringMessageArg(metaType->name()));
1079*0Sstevel@tonic-gate else if (elementIsIncluded(metaType))
1080*0Sstevel@tonic-gate genEvent->setIncluded();
1081*0Sstevel@tonic-gate else if (!currentElement().tryTransition(metaType))
1082*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidElement,
1083*0Sstevel@tonic-gate StringMessageArg(metaType->name()));
1084*0Sstevel@tonic-gate
1085*0Sstevel@tonic-gate pushElement(new (alloc) OpenElement(metaType,
1086*0Sstevel@tonic-gate 0,
1087*0Sstevel@tonic-gate genEvent->included(),
1088*0Sstevel@tonic-gate 0,
1089*0Sstevel@tonic-gate event.location()));
1090*0Sstevel@tonic-gate docHandler_->startElement(genEvent);
1091*0Sstevel@tonic-gate if (attributeList_.conref())
1092*0Sstevel@tonic-gate currentElement().setConref();
1093*0Sstevel@tonic-gate if (!arcContent.isNull() && arcContent->text() != 0) {
1094*0Sstevel@tonic-gate if (currentElement().declaredEmpty()
1095*0Sstevel@tonic-gate || !currentElement().tryTransitionPcdata())
1096*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidArcContent);
1097*0Sstevel@tonic-gate else
1098*0Sstevel@tonic-gate emitArcContent(*arcContent->text(), docHandler(), alloc);
1099*0Sstevel@tonic-gate suppressFlags |= (suppressForm|suppressSupr|ignoreData);
1100*0Sstevel@tonic-gate }
1101*0Sstevel@tonic-gate suppressFlags &= ~recoverData;
1102*0Sstevel@tonic-gate openElementFlags_.push_back(suppressFlags | isArc);
1103*0Sstevel@tonic-gate return 1;
1104*0Sstevel@tonic-gate }
1105*0Sstevel@tonic-gate
emitArcContent(const Text & text,EventHandler & handler,Allocator & alloc)1106*0Sstevel@tonic-gate void ArcProcessor::emitArcContent(const Text &text,
1107*0Sstevel@tonic-gate EventHandler &handler,
1108*0Sstevel@tonic-gate Allocator &alloc)
1109*0Sstevel@tonic-gate {
1110*0Sstevel@tonic-gate TextIter iter(text);
1111*0Sstevel@tonic-gate TextItem::Type type;
1112*0Sstevel@tonic-gate const Char *s;
1113*0Sstevel@tonic-gate size_t n;
1114*0Sstevel@tonic-gate const Location *loc;
1115*0Sstevel@tonic-gate while (iter.next(type, s, n, loc))
1116*0Sstevel@tonic-gate switch (type) {
1117*0Sstevel@tonic-gate case TextItem::data:
1118*0Sstevel@tonic-gate case TextItem::cdata:
1119*0Sstevel@tonic-gate // +1 because first dataEvent is the non-architectural data.
1120*0Sstevel@tonic-gate if (type == TextItem::data)
1121*0Sstevel@tonic-gate handler.data(new (alloc) ImmediateDataEvent(Event::characterData,
1122*0Sstevel@tonic-gate s,
1123*0Sstevel@tonic-gate n,
1124*0Sstevel@tonic-gate *loc,
1125*0Sstevel@tonic-gate 0));
1126*0Sstevel@tonic-gate else
1127*0Sstevel@tonic-gate
1128*0Sstevel@tonic-gate handler.data(new (alloc)
1129*0Sstevel@tonic-gate CdataEntityEvent(loc->origin()->asEntityOrigin()
1130*0Sstevel@tonic-gate ->entity()->asInternalEntity(),
1131*0Sstevel@tonic-gate loc->origin()));
1132*0Sstevel@tonic-gate break;
1133*0Sstevel@tonic-gate case TextItem::sdata:
1134*0Sstevel@tonic-gate
1135*0Sstevel@tonic-gate handler.sdataEntity(new (alloc)
1136*0Sstevel@tonic-gate SdataEntityEvent(loc->origin()->asEntityOrigin()
1137*0Sstevel@tonic-gate ->entity()->asInternalEntity(),
1138*0Sstevel@tonic-gate loc->origin()));
1139*0Sstevel@tonic-gate break;
1140*0Sstevel@tonic-gate default:
1141*0Sstevel@tonic-gate break;
1142*0Sstevel@tonic-gate }
1143*0Sstevel@tonic-gate }
1144*0Sstevel@tonic-gate
processData()1145*0Sstevel@tonic-gate Boolean ArcProcessor::processData()
1146*0Sstevel@tonic-gate {
1147*0Sstevel@tonic-gate if (openElementFlags_.size() > 0
1148*0Sstevel@tonic-gate && (openElementFlags_.back() & ignoreData))
1149*0Sstevel@tonic-gate return 0;
1150*0Sstevel@tonic-gate if (!currentElement().declaredEmpty()
1151*0Sstevel@tonic-gate && currentElement().tryTransitionPcdata())
1152*0Sstevel@tonic-gate return 1;
1153*0Sstevel@tonic-gate else if (openElementFlags_.size() > 0
1154*0Sstevel@tonic-gate && (openElementFlags_.back() & condIgnoreData))
1155*0Sstevel@tonic-gate return 0;
1156*0Sstevel@tonic-gate else {
1157*0Sstevel@tonic-gate // Only give this error once per element
1158*0Sstevel@tonic-gate if (openElementFlags_.size() > 0) {
1159*0Sstevel@tonic-gate if (openElementFlags_.back() & recoverData)
1160*0Sstevel@tonic-gate return 1;
1161*0Sstevel@tonic-gate openElementFlags_.back() |= recoverData;
1162*0Sstevel@tonic-gate }
1163*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidData);
1164*0Sstevel@tonic-gate return 1;
1165*0Sstevel@tonic-gate }
1166*0Sstevel@tonic-gate }
1167*0Sstevel@tonic-gate
mapAttributes(const AttributeList & from,const AttributeList * fromLink,const Text * content,AttributeList & to,ConstPtr<AttributeValue> & arcContent,const MetaMap & map)1168*0Sstevel@tonic-gate Boolean ArcProcessor::mapAttributes(const AttributeList &from,
1169*0Sstevel@tonic-gate const AttributeList *fromLink,
1170*0Sstevel@tonic-gate const Text *content,
1171*0Sstevel@tonic-gate AttributeList &to,
1172*0Sstevel@tonic-gate ConstPtr<AttributeValue> &arcContent,
1173*0Sstevel@tonic-gate const MetaMap &map)
1174*0Sstevel@tonic-gate {
1175*0Sstevel@tonic-gate if (map.attributed)
1176*0Sstevel@tonic-gate to.init(map.attributed->attributeDef());
1177*0Sstevel@tonic-gate for (size_t i = 0; i < map.attMapFrom.size(); i++) {
1178*0Sstevel@tonic-gate unsigned fromIndex = map.attMapFrom[i];
1179*0Sstevel@tonic-gate const AttributeList *fromList = &from;
1180*0Sstevel@tonic-gate if (fromIndex != contentPseudoAtt && fromIndex >= fromList->size()) {
1181*0Sstevel@tonic-gate fromList = fromLink;
1182*0Sstevel@tonic-gate fromIndex -= from.size();
1183*0Sstevel@tonic-gate }
1184*0Sstevel@tonic-gate if (map.attMapTo[i] == contentPseudoAtt) {
1185*0Sstevel@tonic-gate if (fromIndex != contentPseudoAtt)
1186*0Sstevel@tonic-gate arcContent = fromList->valuePointer(fromIndex);
1187*0Sstevel@tonic-gate }
1188*0Sstevel@tonic-gate else {
1189*0Sstevel@tonic-gate const Text *fromText = 0;
1190*0Sstevel@tonic-gate Boolean fromTextTokenized = 0;
1191*0Sstevel@tonic-gate if (map.attMapFrom[i] == contentPseudoAtt) {
1192*0Sstevel@tonic-gate if (!content)
1193*0Sstevel@tonic-gate return 0;
1194*0Sstevel@tonic-gate fromText = content;
1195*0Sstevel@tonic-gate }
1196*0Sstevel@tonic-gate else {
1197*0Sstevel@tonic-gate const AttributeValue *value = fromList->value(fromIndex);
1198*0Sstevel@tonic-gate if (value) {
1199*0Sstevel@tonic-gate fromText = value->text();
1200*0Sstevel@tonic-gate fromTextTokenized = fromList->tokenized(fromIndex);
1201*0Sstevel@tonic-gate if (fromText
1202*0Sstevel@tonic-gate && fromList == &from
1203*0Sstevel@tonic-gate && !from.specified(fromIndex)
1204*0Sstevel@tonic-gate && (map.attributed->attributeDef()->def(map.attMapTo[i])
1205*0Sstevel@tonic-gate ->missingValueWouldMatch(*fromText, *this)))
1206*0Sstevel@tonic-gate fromText = 0;
1207*0Sstevel@tonic-gate }
1208*0Sstevel@tonic-gate }
1209*0Sstevel@tonic-gate if (fromText) {
1210*0Sstevel@tonic-gate unsigned specLength = 0;
1211*0Sstevel@tonic-gate Text tem;
1212*0Sstevel@tonic-gate if (!fromTextTokenized && to.tokenized(map.attMapTo[i]))
1213*0Sstevel@tonic-gate fromText->tokenize(docSyntax_->space(), tem);
1214*0Sstevel@tonic-gate else
1215*0Sstevel@tonic-gate tem = *fromText;
1216*0Sstevel@tonic-gate to.setSpec(map.attMapTo[i], *this);
1217*0Sstevel@tonic-gate to.setValue(map.attMapTo[i], tem, *this, specLength);
1218*0Sstevel@tonic-gate }
1219*0Sstevel@tonic-gate }
1220*0Sstevel@tonic-gate }
1221*0Sstevel@tonic-gate if (map.attributed)
1222*0Sstevel@tonic-gate to.finish(*this);
1223*0Sstevel@tonic-gate return 1;
1224*0Sstevel@tonic-gate }
1225*0Sstevel@tonic-gate
1226*0Sstevel@tonic-gate const ArcProcessor::MetaMap &
buildMetaMap(const ElementType * docElementType,const Notation * notation,const AttributeList & atts,const AttributeList * linkAtts,unsigned suppressFlags)1227*0Sstevel@tonic-gate ArcProcessor::buildMetaMap(const ElementType *docElementType,
1228*0Sstevel@tonic-gate const Notation *notation,
1229*0Sstevel@tonic-gate const AttributeList &atts,
1230*0Sstevel@tonic-gate const AttributeList *linkAtts,
1231*0Sstevel@tonic-gate unsigned suppressFlags)
1232*0Sstevel@tonic-gate {
1233*0Sstevel@tonic-gate Boolean isNotation;
1234*0Sstevel@tonic-gate const Attributed *attributed = docElementType;
1235*0Sstevel@tonic-gate const StringC *nameP;
1236*0Sstevel@tonic-gate if (!attributed) {
1237*0Sstevel@tonic-gate attributed = notation;
1238*0Sstevel@tonic-gate isNotation = 1;
1239*0Sstevel@tonic-gate nameP = ¬ation->name();
1240*0Sstevel@tonic-gate }
1241*0Sstevel@tonic-gate else {
1242*0Sstevel@tonic-gate isNotation = 0;
1243*0Sstevel@tonic-gate nameP = &docElementType->name();
1244*0Sstevel@tonic-gate }
1245*0Sstevel@tonic-gate // Try to use cached entry.
1246*0Sstevel@tonic-gate Boolean inhibitCache = 0;
1247*0Sstevel@tonic-gate size_t cacheIndex;
1248*0Sstevel@tonic-gate if (isNotation || docElementType->definition()->undefined()) {
1249*0Sstevel@tonic-gate inhibitCache = 1;
1250*0Sstevel@tonic-gate cacheIndex = (unsigned)-1;
1251*0Sstevel@tonic-gate }
1252*0Sstevel@tonic-gate else {
1253*0Sstevel@tonic-gate cacheIndex = docElementType->index();
1254*0Sstevel@tonic-gate const MetaMapCache *cache = metaMapCache_[cacheIndex].pointer();
1255*0Sstevel@tonic-gate if (cache
1256*0Sstevel@tonic-gate && cache->suppressFlags == suppressFlags
1257*0Sstevel@tonic-gate && cache->linkAtts == linkAtts) {
1258*0Sstevel@tonic-gate for (int i = 0;; i++) {
1259*0Sstevel@tonic-gate if (i == MetaMapCache::nNoSpec)
1260*0Sstevel@tonic-gate return cache->map;
1261*0Sstevel@tonic-gate unsigned attIndex = cache->noSpec[i];
1262*0Sstevel@tonic-gate if (attIndex != invalidAtt && atts.specified(attIndex))
1263*0Sstevel@tonic-gate break;
1264*0Sstevel@tonic-gate }
1265*0Sstevel@tonic-gate }
1266*0Sstevel@tonic-gate }
1267*0Sstevel@tonic-gate // no valid cached MetaMap
1268*0Sstevel@tonic-gate // Handle suppression.
1269*0Sstevel@tonic-gate unsigned oldSuppressFlags = suppressFlags;
1270*0Sstevel@tonic-gate unsigned newSuppressFlags = suppressFlags;
1271*0Sstevel@tonic-gate unsigned arcSuprIndex;
1272*0Sstevel@tonic-gate if (!isNotation)
1273*0Sstevel@tonic-gate considerSupr(atts, linkAtts, suppressFlags, newSuppressFlags, inhibitCache,
1274*0Sstevel@tonic-gate arcSuprIndex);
1275*0Sstevel@tonic-gate else
1276*0Sstevel@tonic-gate arcSuprIndex = invalidAtt;
1277*0Sstevel@tonic-gate // Handle ArcIgnD
1278*0Sstevel@tonic-gate unsigned arcIgnDIndex;
1279*0Sstevel@tonic-gate if (!isNotation)
1280*0Sstevel@tonic-gate considerIgnD(atts, linkAtts, suppressFlags, newSuppressFlags, inhibitCache,
1281*0Sstevel@tonic-gate arcIgnDIndex);
1282*0Sstevel@tonic-gate else
1283*0Sstevel@tonic-gate arcIgnDIndex = invalidAtt;
1284*0Sstevel@tonic-gate // Handle ArcForm.
1285*0Sstevel@tonic-gate unsigned arcFormIndex;
1286*0Sstevel@tonic-gate const Attributed *metaAttributed
1287*0Sstevel@tonic-gate = considerForm(atts, linkAtts, *nameP, isNotation,
1288*0Sstevel@tonic-gate suppressFlags, newSuppressFlags,
1289*0Sstevel@tonic-gate inhibitCache, arcFormIndex);
1290*0Sstevel@tonic-gate // See if there's a renamer that will inhibit cacheing.
1291*0Sstevel@tonic-gate #pragma "%Z%%M% %I% %E% SMI"
1292*0Sstevel@tonic-gate unsigned arcNamerIndex;
1293*0Sstevel@tonic-gate const Text *namerText;
1294*0Sstevel@tonic-gate if (metaAttributed)
1295*0Sstevel@tonic-gate namerText = considerNamer(atts, inhibitCache, arcNamerIndex);
1296*0Sstevel@tonic-gate else {
1297*0Sstevel@tonic-gate arcNamerIndex = invalidAtt;
1298*0Sstevel@tonic-gate namerText = 0;
1299*0Sstevel@tonic-gate }
1300*0Sstevel@tonic-gate MetaMap *mapP;
1301*0Sstevel@tonic-gate if (inhibitCache) {
1302*0Sstevel@tonic-gate noCacheMetaMap_.clear();
1303*0Sstevel@tonic-gate mapP = &noCacheMetaMap_;
1304*0Sstevel@tonic-gate }
1305*0Sstevel@tonic-gate else {
1306*0Sstevel@tonic-gate MetaMapCache *cache = metaMapCache_[cacheIndex].pointer();
1307*0Sstevel@tonic-gate if (cache)
1308*0Sstevel@tonic-gate cache->clear();
1309*0Sstevel@tonic-gate else {
1310*0Sstevel@tonic-gate cache = new MetaMapCache;
1311*0Sstevel@tonic-gate metaMapCache_[cacheIndex] = cache;
1312*0Sstevel@tonic-gate }
1313*0Sstevel@tonic-gate cache->noSpec[0] = arcFormIndex;
1314*0Sstevel@tonic-gate cache->noSpec[1] = arcNamerIndex;
1315*0Sstevel@tonic-gate cache->noSpec[2] = arcSuprIndex;
1316*0Sstevel@tonic-gate cache->noSpec[3] = arcIgnDIndex;
1317*0Sstevel@tonic-gate cache->suppressFlags = oldSuppressFlags;
1318*0Sstevel@tonic-gate cache->linkAtts = linkAtts;
1319*0Sstevel@tonic-gate mapP = &cache->map;
1320*0Sstevel@tonic-gate }
1321*0Sstevel@tonic-gate mapP->attributed = metaAttributed;
1322*0Sstevel@tonic-gate mapP->suppressFlags = newSuppressFlags;
1323*0Sstevel@tonic-gate // Build the attribute map.
1324*0Sstevel@tonic-gate if (metaAttributed) {
1325*0Sstevel@tonic-gate Vector<PackedBoolean> renamed;
1326*0Sstevel@tonic-gate ConstPtr<AttributeDefinitionList> metaAttDef
1327*0Sstevel@tonic-gate = metaAttributed->attributeDef();
1328*0Sstevel@tonic-gate if (!metaAttDef.isNull())
1329*0Sstevel@tonic-gate renamed.assign(metaAttDef->size(), PackedBoolean(0));
1330*0Sstevel@tonic-gate if (linkAtts) {
1331*0Sstevel@tonic-gate Boolean specified;
1332*0Sstevel@tonic-gate unsigned index;
1333*0Sstevel@tonic-gate const Text *linkNamerText = considerNamer(*linkAtts, specified, index);
1334*0Sstevel@tonic-gate if (linkNamerText)
1335*0Sstevel@tonic-gate buildAttributeMapRename(*mapP, *linkNamerText, atts, linkAtts, renamed);
1336*0Sstevel@tonic-gate }
1337*0Sstevel@tonic-gate if (namerText)
1338*0Sstevel@tonic-gate buildAttributeMapRename(*mapP, *namerText, atts, 0, renamed);
1339*0Sstevel@tonic-gate buildAttributeMapRest(*mapP, atts, linkAtts, renamed);
1340*0Sstevel@tonic-gate }
1341*0Sstevel@tonic-gate return *mapP;
1342*0Sstevel@tonic-gate }
1343*0Sstevel@tonic-gate
considerSupr(const AttributeList & atts,const AttributeList * linkAtts,unsigned & thisSuppressFlags,unsigned & newSuppressFlags,Boolean & inhibitCache,unsigned & arcSuprIndex)1344*0Sstevel@tonic-gate void ArcProcessor::considerSupr(const AttributeList &atts,
1345*0Sstevel@tonic-gate const AttributeList *linkAtts,
1346*0Sstevel@tonic-gate unsigned &thisSuppressFlags,
1347*0Sstevel@tonic-gate unsigned &newSuppressFlags,
1348*0Sstevel@tonic-gate Boolean &inhibitCache,
1349*0Sstevel@tonic-gate unsigned &arcSuprIndex)
1350*0Sstevel@tonic-gate {
1351*0Sstevel@tonic-gate arcSuprIndex = invalidAtt;
1352*0Sstevel@tonic-gate if (thisSuppressFlags & suppressSupr)
1353*0Sstevel@tonic-gate return;
1354*0Sstevel@tonic-gate if (!supportAtts_[rArcSuprA].size())
1355*0Sstevel@tonic-gate return;
1356*0Sstevel@tonic-gate const AttributeValue *val;
1357*0Sstevel@tonic-gate unsigned tem;
1358*0Sstevel@tonic-gate if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcSuprA], tem))
1359*0Sstevel@tonic-gate val = linkAtts->value(tem);
1360*0Sstevel@tonic-gate else if (atts.attributeIndex(supportAtts_[rArcSuprA], arcSuprIndex)) {
1361*0Sstevel@tonic-gate if (atts.current(arcSuprIndex) || atts.specified(arcSuprIndex))
1362*0Sstevel@tonic-gate inhibitCache = 1;
1363*0Sstevel@tonic-gate val = atts.value(arcSuprIndex);
1364*0Sstevel@tonic-gate }
1365*0Sstevel@tonic-gate else
1366*0Sstevel@tonic-gate return;
1367*0Sstevel@tonic-gate if (!val)
1368*0Sstevel@tonic-gate return;
1369*0Sstevel@tonic-gate const Text *textP = val->text();
1370*0Sstevel@tonic-gate if (!textP)
1371*0Sstevel@tonic-gate return;
1372*0Sstevel@tonic-gate StringC token = textP->string();
1373*0Sstevel@tonic-gate // FIXME trim spaces
1374*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(token);
1375*0Sstevel@tonic-gate // sArcForm suppress processing for all elements except
1376*0Sstevel@tonic-gate // those that have a non-implied ArcSupr attribute.
1377*0Sstevel@tonic-gate thisSuppressFlags &= ~suppressForm;
1378*0Sstevel@tonic-gate newSuppressFlags &= ~(suppressForm|suppressSupr);
1379*0Sstevel@tonic-gate if (matchName(token, "sArcForm"))
1380*0Sstevel@tonic-gate newSuppressFlags |= suppressForm;
1381*0Sstevel@tonic-gate #if 0
1382*0Sstevel@tonic-gate // I don't think this is useful
1383*0Sstevel@tonic-gate else if (matchName(token, "sArcSupr"))
1384*0Sstevel@tonic-gate newSuppressFlags |= suppressSupr;
1385*0Sstevel@tonic-gate #endif
1386*0Sstevel@tonic-gate else if (matchName(token, "sArcAll"))
1387*0Sstevel@tonic-gate newSuppressFlags |= (suppressSupr|suppressForm);
1388*0Sstevel@tonic-gate else if (!matchName(token, "sArcNone")) {
1389*0Sstevel@tonic-gate Messenger::setNextLocation(textP->charLocation(0));
1390*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidSuppress,
1391*0Sstevel@tonic-gate StringMessageArg(token));
1392*0Sstevel@tonic-gate }
1393*0Sstevel@tonic-gate }
1394*0Sstevel@tonic-gate
considerIgnD(const AttributeList & atts,const AttributeList * linkAtts,unsigned thisSuppressFlags,unsigned & newSuppressFlags,Boolean & inhibitCache,unsigned & arcIgnDIndex)1395*0Sstevel@tonic-gate void ArcProcessor::considerIgnD(const AttributeList &atts,
1396*0Sstevel@tonic-gate const AttributeList *linkAtts,
1397*0Sstevel@tonic-gate unsigned thisSuppressFlags,
1398*0Sstevel@tonic-gate unsigned &newSuppressFlags,
1399*0Sstevel@tonic-gate Boolean &inhibitCache,
1400*0Sstevel@tonic-gate unsigned &arcIgnDIndex)
1401*0Sstevel@tonic-gate {
1402*0Sstevel@tonic-gate arcIgnDIndex = invalidAtt;
1403*0Sstevel@tonic-gate if (thisSuppressFlags & suppressSupr)
1404*0Sstevel@tonic-gate return;
1405*0Sstevel@tonic-gate if (!supportAtts_[rArcIgnDA].size())
1406*0Sstevel@tonic-gate return;
1407*0Sstevel@tonic-gate const AttributeValue *val;
1408*0Sstevel@tonic-gate unsigned tem;
1409*0Sstevel@tonic-gate if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcIgnDA], tem))
1410*0Sstevel@tonic-gate val = linkAtts->value(tem);
1411*0Sstevel@tonic-gate else if (atts.attributeIndex(supportAtts_[rArcIgnDA], arcIgnDIndex)) {
1412*0Sstevel@tonic-gate if (atts.current(arcIgnDIndex) || atts.specified(arcIgnDIndex))
1413*0Sstevel@tonic-gate inhibitCache = 1;
1414*0Sstevel@tonic-gate val = atts.value(arcIgnDIndex);
1415*0Sstevel@tonic-gate }
1416*0Sstevel@tonic-gate else
1417*0Sstevel@tonic-gate return;
1418*0Sstevel@tonic-gate if (!val)
1419*0Sstevel@tonic-gate return;
1420*0Sstevel@tonic-gate const Text *textP = val->text();
1421*0Sstevel@tonic-gate if (!textP)
1422*0Sstevel@tonic-gate return;
1423*0Sstevel@tonic-gate StringC token = textP->string();
1424*0Sstevel@tonic-gate // FIXME trim spaces
1425*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(token);
1426*0Sstevel@tonic-gate newSuppressFlags &= ~(ignoreData|condIgnoreData);
1427*0Sstevel@tonic-gate if (matchName(token, "ArcIgnD"))
1428*0Sstevel@tonic-gate newSuppressFlags |= ignoreData;
1429*0Sstevel@tonic-gate else if (matchName(token, "cArcIgnD"))
1430*0Sstevel@tonic-gate newSuppressFlags |= condIgnoreData;
1431*0Sstevel@tonic-gate else if (!matchName(token, "nArcIgnD")) {
1432*0Sstevel@tonic-gate Messenger::setNextLocation(textP->charLocation(0));
1433*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::invalidIgnD,
1434*0Sstevel@tonic-gate StringMessageArg(token));
1435*0Sstevel@tonic-gate }
1436*0Sstevel@tonic-gate }
1437*0Sstevel@tonic-gate
1438*0Sstevel@tonic-gate const Attributed *
considerForm(const AttributeList & atts,const AttributeList * linkAtts,const StringC & name,Boolean isNotation,unsigned thisSuppressFlags,unsigned & newSuppressFlags,Boolean & inhibitCache,unsigned & arcFormIndex)1439*0Sstevel@tonic-gate ArcProcessor::considerForm(const AttributeList &atts,
1440*0Sstevel@tonic-gate const AttributeList *linkAtts,
1441*0Sstevel@tonic-gate const StringC &name,
1442*0Sstevel@tonic-gate Boolean isNotation,
1443*0Sstevel@tonic-gate unsigned thisSuppressFlags,
1444*0Sstevel@tonic-gate unsigned &newSuppressFlags,
1445*0Sstevel@tonic-gate Boolean &inhibitCache,
1446*0Sstevel@tonic-gate unsigned &arcFormIndex)
1447*0Sstevel@tonic-gate {
1448*0Sstevel@tonic-gate arcFormIndex = invalidAtt;
1449*0Sstevel@tonic-gate if ((thisSuppressFlags & suppressForm)
1450*0Sstevel@tonic-gate && (supportAtts_[rArcSuprF].size() == 0
1451*0Sstevel@tonic-gate || (thisSuppressFlags & suppressSupr)
1452*0Sstevel@tonic-gate || isNotation))
1453*0Sstevel@tonic-gate return 0;
1454*0Sstevel@tonic-gate unsigned tem;
1455*0Sstevel@tonic-gate const AttributeValue *val;
1456*0Sstevel@tonic-gate if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcFormA], tem))
1457*0Sstevel@tonic-gate val = linkAtts->value(tem);
1458*0Sstevel@tonic-gate else if (atts.attributeIndex(supportAtts_[rArcFormA], arcFormIndex)) {
1459*0Sstevel@tonic-gate if (atts.current(arcFormIndex) || atts.specified(arcFormIndex))
1460*0Sstevel@tonic-gate inhibitCache = 1;
1461*0Sstevel@tonic-gate val = atts.value(arcFormIndex);
1462*0Sstevel@tonic-gate }
1463*0Sstevel@tonic-gate else
1464*0Sstevel@tonic-gate return autoForm(atts, name, isNotation,
1465*0Sstevel@tonic-gate thisSuppressFlags, newSuppressFlags,
1466*0Sstevel@tonic-gate inhibitCache, arcFormIndex);
1467*0Sstevel@tonic-gate
1468*0Sstevel@tonic-gate if (!val)
1469*0Sstevel@tonic-gate return 0;
1470*0Sstevel@tonic-gate const Text *textP = val->text();
1471*0Sstevel@tonic-gate if (!textP)
1472*0Sstevel@tonic-gate return 0;
1473*0Sstevel@tonic-gate StringC metaName;
1474*0Sstevel@tonic-gate metaName = textP->string();
1475*0Sstevel@tonic-gate // FIXME should trim leading and trailing spaces
1476*0Sstevel@tonic-gate metaSyntax_->generalSubstTable()->subst(metaName);
1477*0Sstevel@tonic-gate if (!isNotation) {
1478*0Sstevel@tonic-gate const Attributed *metaAttributed = metaDtd_->lookupElementType(metaName);
1479*0Sstevel@tonic-gate if (!metaAttributed) // CONSTDTD
1480*0Sstevel@tonic-gate metaAttributed = lookupCreateUndefinedElement(metaName, Location(), *metaDtd_);
1481*0Sstevel@tonic-gate if (metaName == supportAtts_[rArcSuprF]) {
1482*0Sstevel@tonic-gate newSuppressFlags |= suppressForm;
1483*0Sstevel@tonic-gate return metaAttributed;
1484*0Sstevel@tonic-gate }
1485*0Sstevel@tonic-gate if (thisSuppressFlags & suppressForm)
1486*0Sstevel@tonic-gate return 0;
1487*0Sstevel@tonic-gate return metaAttributed;
1488*0Sstevel@tonic-gate }
1489*0Sstevel@tonic-gate else
1490*0Sstevel@tonic-gate return metaDtd_->lookupNotation(metaName).pointer();
1491*0Sstevel@tonic-gate }
1492*0Sstevel@tonic-gate
1493*0Sstevel@tonic-gate const Attributed *
autoForm(const AttributeList & atts,const StringC & name,Boolean isNotation,unsigned thisSuppressFlags,unsigned & newSuppressFlags,Boolean & inhibitCache,unsigned & idIndex)1494*0Sstevel@tonic-gate ArcProcessor::autoForm(const AttributeList &atts,
1495*0Sstevel@tonic-gate const StringC &name,
1496*0Sstevel@tonic-gate Boolean isNotation,
1497*0Sstevel@tonic-gate unsigned thisSuppressFlags,
1498*0Sstevel@tonic-gate unsigned &newSuppressFlags,
1499*0Sstevel@tonic-gate Boolean &inhibitCache,
1500*0Sstevel@tonic-gate unsigned &idIndex)
1501*0Sstevel@tonic-gate {
1502*0Sstevel@tonic-gate if (!isNotation) {
1503*0Sstevel@tonic-gate const Attributed *metaAttributed;
1504*0Sstevel@tonic-gate if (openElementFlags_.size() == 0) {
1505*0Sstevel@tonic-gate metaAttributed = metaDtd_->documentElementType();
1506*0Sstevel@tonic-gate inhibitCache = 1;
1507*0Sstevel@tonic-gate }
1508*0Sstevel@tonic-gate else {
1509*0Sstevel@tonic-gate metaAttributed = 0;
1510*0Sstevel@tonic-gate if (arcAuto_)
1511*0Sstevel@tonic-gate metaAttributed = metaDtd_->lookupElementType(name);
1512*0Sstevel@tonic-gate if (!metaAttributed
1513*0Sstevel@tonic-gate && supportAtts_[rArcBridF].size() > 0
1514*0Sstevel@tonic-gate && atts.idIndex(idIndex)
1515*0Sstevel@tonic-gate && atts.specified(idIndex)) {
1516*0Sstevel@tonic-gate inhibitCache = 1;
1517*0Sstevel@tonic-gate metaAttributed
1518*0Sstevel@tonic-gate = metaDtd_->lookupElementType(supportAtts_[rArcBridF]);
1519*0Sstevel@tonic-gate }
1520*0Sstevel@tonic-gate }
1521*0Sstevel@tonic-gate if (metaAttributed
1522*0Sstevel@tonic-gate && name == supportAtts_[rArcSuprF]) {
1523*0Sstevel@tonic-gate newSuppressFlags = suppressForm|ignoreData;
1524*0Sstevel@tonic-gate }
1525*0Sstevel@tonic-gate else if (thisSuppressFlags & suppressForm)
1526*0Sstevel@tonic-gate return 0;
1527*0Sstevel@tonic-gate return metaAttributed;
1528*0Sstevel@tonic-gate }
1529*0Sstevel@tonic-gate else if (thisSuppressFlags & suppressForm)
1530*0Sstevel@tonic-gate return 0;
1531*0Sstevel@tonic-gate else {
1532*0Sstevel@tonic-gate const Attributed *metaAttributed = 0;
1533*0Sstevel@tonic-gate if (arcAuto_)
1534*0Sstevel@tonic-gate metaAttributed = metaDtd_->lookupNotation(name).pointer();
1535*0Sstevel@tonic-gate if (!metaAttributed && supportAtts_[rArcDataF].size() > 0)
1536*0Sstevel@tonic-gate metaAttributed
1537*0Sstevel@tonic-gate = metaDtd_->lookupNotation(supportAtts_[rArcDataF]).pointer();
1538*0Sstevel@tonic-gate return metaAttributed;
1539*0Sstevel@tonic-gate }
1540*0Sstevel@tonic-gate }
1541*0Sstevel@tonic-gate
1542*0Sstevel@tonic-gate
1543*0Sstevel@tonic-gate const Text *
considerNamer(const AttributeList & atts,Boolean & inhibitCache,unsigned & arcNamerIndex)1544*0Sstevel@tonic-gate ArcProcessor::considerNamer(const AttributeList &atts,
1545*0Sstevel@tonic-gate Boolean &inhibitCache,
1546*0Sstevel@tonic-gate unsigned &arcNamerIndex)
1547*0Sstevel@tonic-gate {
1548*0Sstevel@tonic-gate arcNamerIndex = invalidAtt;
1549*0Sstevel@tonic-gate if (supportAtts_[rArcNamrA].size() == 0
1550*0Sstevel@tonic-gate || !atts.attributeIndex(supportAtts_[rArcNamrA], arcNamerIndex))
1551*0Sstevel@tonic-gate return 0;
1552*0Sstevel@tonic-gate if (atts.current(arcNamerIndex) || atts.specified(arcNamerIndex))
1553*0Sstevel@tonic-gate inhibitCache = 1;
1554*0Sstevel@tonic-gate const AttributeValue *val = atts.value(arcNamerIndex);
1555*0Sstevel@tonic-gate if (!val)
1556*0Sstevel@tonic-gate return 0;
1557*0Sstevel@tonic-gate return val->text();
1558*0Sstevel@tonic-gate }
1559*0Sstevel@tonic-gate
buildAttributeMapRename(MetaMap & map,const Text & rename,const AttributeList & atts,const AttributeList * linkAtts,Vector<PackedBoolean> & attRenamed)1560*0Sstevel@tonic-gate void ArcProcessor::buildAttributeMapRename(MetaMap &map,
1561*0Sstevel@tonic-gate const Text &rename,
1562*0Sstevel@tonic-gate const AttributeList &atts,
1563*0Sstevel@tonic-gate const AttributeList *linkAtts,
1564*0Sstevel@tonic-gate Vector<PackedBoolean> &attRenamed)
1565*0Sstevel@tonic-gate {
1566*0Sstevel@tonic-gate Vector<StringC> tokens;
1567*0Sstevel@tonic-gate Vector<size_t> tokensPos;
1568*0Sstevel@tonic-gate split(rename, docSyntax_->space(), tokens, tokensPos);
1569*0Sstevel@tonic-gate ConstPtr<AttributeDefinitionList> metaAttDef;
1570*0Sstevel@tonic-gate if (map.attributed)
1571*0Sstevel@tonic-gate metaAttDef = map.attributed->attributeDef();
1572*0Sstevel@tonic-gate // FIXME Should check that ARCCONT doesn't appear more than once.
1573*0Sstevel@tonic-gate for (size_t i = 0; i < tokens.size(); i += 2) {
1574*0Sstevel@tonic-gate unsigned fromIndex = invalidAtt;
1575*0Sstevel@tonic-gate unsigned toIndex = invalidAtt;
1576*0Sstevel@tonic-gate metaSyntax_->generalSubstTable()->subst(tokens[i]);
1577*0Sstevel@tonic-gate if (tokens[i] == rniArcCont_)
1578*0Sstevel@tonic-gate toIndex = contentPseudoAtt;
1579*0Sstevel@tonic-gate else if (metaAttDef.isNull()
1580*0Sstevel@tonic-gate || !metaAttDef->attributeIndex(tokens[i], toIndex)) {
1581*0Sstevel@tonic-gate setNextLocation(rename.charLocation(tokensPos[i]));
1582*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::renameToInvalid,
1583*0Sstevel@tonic-gate StringMessageArg(tokens[i]));
1584*0Sstevel@tonic-gate }
1585*0Sstevel@tonic-gate else if (attRenamed[toIndex]) {
1586*0Sstevel@tonic-gate toIndex = invalidAtt;
1587*0Sstevel@tonic-gate setNextLocation(rename.charLocation(tokensPos[i]));
1588*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::renameToDuplicate,
1589*0Sstevel@tonic-gate StringMessageArg(tokens[i]));
1590*0Sstevel@tonic-gate }
1591*0Sstevel@tonic-gate if (i + 1 >= tokens.size()) {
1592*0Sstevel@tonic-gate setNextLocation(rename.charLocation(tokensPos[i]));
1593*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::renameMissingAttName);
1594*0Sstevel@tonic-gate }
1595*0Sstevel@tonic-gate else {
1596*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(tokens[i + 1]);
1597*0Sstevel@tonic-gate if (tokens[i + 1] == rniContent_) {
1598*0Sstevel@tonic-gate fromIndex = contentPseudoAtt;
1599*0Sstevel@tonic-gate }
1600*0Sstevel@tonic-gate else if (tokens[i + 1] == rniDefault_) {
1601*0Sstevel@tonic-gate if (toIndex != contentPseudoAtt)
1602*0Sstevel@tonic-gate attRenamed[toIndex] = 1;
1603*0Sstevel@tonic-gate }
1604*0Sstevel@tonic-gate else if (linkAtts
1605*0Sstevel@tonic-gate && linkAtts->attributeIndex(tokens[i + 1], fromIndex))
1606*0Sstevel@tonic-gate fromIndex += atts.size();
1607*0Sstevel@tonic-gate else if (!atts.attributeIndex(tokens[i + 1], fromIndex)) {
1608*0Sstevel@tonic-gate setNextLocation(rename.charLocation(tokensPos[i + 1]));
1609*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::renameFromInvalid,
1610*0Sstevel@tonic-gate StringMessageArg(tokens[i + 1]));
1611*0Sstevel@tonic-gate }
1612*0Sstevel@tonic-gate }
1613*0Sstevel@tonic-gate if (fromIndex != invalidAtt && toIndex != invalidAtt) {
1614*0Sstevel@tonic-gate map.attMapFrom.push_back(fromIndex);
1615*0Sstevel@tonic-gate map.attMapTo.push_back(toIndex);
1616*0Sstevel@tonic-gate if (toIndex != contentPseudoAtt) {
1617*0Sstevel@tonic-gate attRenamed[toIndex] = 1;
1618*0Sstevel@tonic-gate if (metaAttDef->def(toIndex)->isId()
1619*0Sstevel@tonic-gate && (fromIndex >= atts.size() || !atts.id(fromIndex)))
1620*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::idMismatch,
1621*0Sstevel@tonic-gate StringMessageArg(metaAttDef->def(toIndex)
1622*0Sstevel@tonic-gate ->name()));
1623*0Sstevel@tonic-gate }
1624*0Sstevel@tonic-gate }
1625*0Sstevel@tonic-gate }
1626*0Sstevel@tonic-gate }
1627*0Sstevel@tonic-gate
buildAttributeMapRest(MetaMap & map,const AttributeList & atts,const AttributeList * linkAtts,const Vector<PackedBoolean> & attRenamed)1628*0Sstevel@tonic-gate void ArcProcessor::buildAttributeMapRest(MetaMap &map,
1629*0Sstevel@tonic-gate const AttributeList &atts,
1630*0Sstevel@tonic-gate const AttributeList *linkAtts,
1631*0Sstevel@tonic-gate const Vector<PackedBoolean> &attRenamed)
1632*0Sstevel@tonic-gate {
1633*0Sstevel@tonic-gate ConstPtr<AttributeDefinitionList> metaAttDef
1634*0Sstevel@tonic-gate = map.attributed->attributeDef();
1635*0Sstevel@tonic-gate if (metaAttDef.isNull())
1636*0Sstevel@tonic-gate return;
1637*0Sstevel@tonic-gate for (unsigned i = 0; i < metaAttDef->size(); i++)
1638*0Sstevel@tonic-gate if (!attRenamed[i]) {
1639*0Sstevel@tonic-gate unsigned fromIndex;
1640*0Sstevel@tonic-gate if (metaAttDef->def(i)->isId()) {
1641*0Sstevel@tonic-gate for (unsigned j = 0; j < atts.size(); j++)
1642*0Sstevel@tonic-gate if (atts.id(j)) {
1643*0Sstevel@tonic-gate map.attMapFrom.push_back(j);
1644*0Sstevel@tonic-gate map.attMapTo.push_back(i);
1645*0Sstevel@tonic-gate break;
1646*0Sstevel@tonic-gate }
1647*0Sstevel@tonic-gate }
1648*0Sstevel@tonic-gate else if (linkAtts && linkAtts->attributeIndex(metaAttDef->def(i)->name(),
1649*0Sstevel@tonic-gate fromIndex)) {
1650*0Sstevel@tonic-gate map.attMapFrom.push_back(fromIndex + atts.size());
1651*0Sstevel@tonic-gate map.attMapTo.push_back(i);
1652*0Sstevel@tonic-gate }
1653*0Sstevel@tonic-gate else if (atts.attributeIndex(metaAttDef->def(i)->name(), fromIndex)) {
1654*0Sstevel@tonic-gate map.attMapFrom.push_back(fromIndex);
1655*0Sstevel@tonic-gate map.attMapTo.push_back(i);
1656*0Sstevel@tonic-gate }
1657*0Sstevel@tonic-gate }
1658*0Sstevel@tonic-gate }
1659*0Sstevel@tonic-gate
matchName(const StringC & name,const char * key)1660*0Sstevel@tonic-gate Boolean ArcProcessor::matchName(const StringC &name, const char *key)
1661*0Sstevel@tonic-gate {
1662*0Sstevel@tonic-gate if (name.size() != strlen(key))
1663*0Sstevel@tonic-gate return 0;
1664*0Sstevel@tonic-gate StringC tem(docSd_->execToInternal(key));
1665*0Sstevel@tonic-gate docSyntax_->generalSubstTable()->subst(tem);
1666*0Sstevel@tonic-gate return name == tem;
1667*0Sstevel@tonic-gate }
1668*0Sstevel@tonic-gate
split(const Text & text,Char space,Vector<StringC> & tokens,Vector<size_t> & tokensPos)1669*0Sstevel@tonic-gate void ArcProcessor::split(const Text &text,
1670*0Sstevel@tonic-gate Char space,
1671*0Sstevel@tonic-gate Vector<StringC> &tokens,
1672*0Sstevel@tonic-gate Vector<size_t> &tokensPos)
1673*0Sstevel@tonic-gate {
1674*0Sstevel@tonic-gate const StringC &str = text.string();
1675*0Sstevel@tonic-gate for (size_t i = 0;;) {
1676*0Sstevel@tonic-gate for (; i < str.size() && str[i] == space; i++)
1677*0Sstevel@tonic-gate ;
1678*0Sstevel@tonic-gate if (i >= str.size())
1679*0Sstevel@tonic-gate break;
1680*0Sstevel@tonic-gate size_t start = i;
1681*0Sstevel@tonic-gate for (; i < str.size() && str[i] != space; i++)
1682*0Sstevel@tonic-gate ;
1683*0Sstevel@tonic-gate tokens.push_back(StringC(str.data() + start, i - start));
1684*0Sstevel@tonic-gate tokensPos.push_back(start);
1685*0Sstevel@tonic-gate }
1686*0Sstevel@tonic-gate }
1687*0Sstevel@tonic-gate
processEndElement(const EndElementEvent & event,Allocator & alloc)1688*0Sstevel@tonic-gate void ArcProcessor::processEndElement(const EndElementEvent &event,
1689*0Sstevel@tonic-gate Allocator &alloc)
1690*0Sstevel@tonic-gate {
1691*0Sstevel@tonic-gate Boolean wasArc = (openElementFlags_.back() & isArc);
1692*0Sstevel@tonic-gate openElementFlags_.resize(openElementFlags_.size() - 1);
1693*0Sstevel@tonic-gate if (wasArc) {
1694*0Sstevel@tonic-gate EndElementEvent *genEvent
1695*0Sstevel@tonic-gate = new (alloc) EndElementEvent(currentElement().type(),
1696*0Sstevel@tonic-gate metaDtd_,
1697*0Sstevel@tonic-gate event.location(),
1698*0Sstevel@tonic-gate 0);
1699*0Sstevel@tonic-gate if (currentElement().included())
1700*0Sstevel@tonic-gate genEvent->setIncluded();
1701*0Sstevel@tonic-gate docHandler_->endElement(genEvent);
1702*0Sstevel@tonic-gate if (!currentElement().isFinished())
1703*0Sstevel@tonic-gate Messenger::message(ArcEngineMessages::unfinishedElement,
1704*0Sstevel@tonic-gate StringMessageArg(currentElement().type()->name()));
1705*0Sstevel@tonic-gate popElement();
1706*0Sstevel@tonic-gate }
1707*0Sstevel@tonic-gate }
1708*0Sstevel@tonic-gate
dispatchMessage(Message & msg)1709*0Sstevel@tonic-gate void ArcProcessor::dispatchMessage(Message &msg)
1710*0Sstevel@tonic-gate {
1711*0Sstevel@tonic-gate mgr_->dispatchMessage(msg);
1712*0Sstevel@tonic-gate }
1713*0Sstevel@tonic-gate
dispatchMessage(const Message & msg)1714*0Sstevel@tonic-gate void ArcProcessor::dispatchMessage(const Message &msg)
1715*0Sstevel@tonic-gate {
1716*0Sstevel@tonic-gate mgr_->dispatchMessage(msg);
1717*0Sstevel@tonic-gate }
1718*0Sstevel@tonic-gate
initMessage(Message & msg)1719*0Sstevel@tonic-gate void ArcProcessor::initMessage(Message &msg)
1720*0Sstevel@tonic-gate {
1721*0Sstevel@tonic-gate mgr_->initMessage(msg);
1722*0Sstevel@tonic-gate if (valid_) {
1723*0Sstevel@tonic-gate StringC rniPcdata = metaSyntax_->delimGeneral(Syntax::dRNI);
1724*0Sstevel@tonic-gate rniPcdata += metaSyntax_->reservedName(Syntax::rPCDATA);
1725*0Sstevel@tonic-gate getOpenElementInfo(msg.openElementInfo, rniPcdata);
1726*0Sstevel@tonic-gate }
1727*0Sstevel@tonic-gate }
1728*0Sstevel@tonic-gate
MetaMapCache()1729*0Sstevel@tonic-gate ArcProcessor::MetaMapCache::MetaMapCache()
1730*0Sstevel@tonic-gate {
1731*0Sstevel@tonic-gate for (int i = 0; i < nNoSpec; i++)
1732*0Sstevel@tonic-gate noSpec[i] = invalidAtt;
1733*0Sstevel@tonic-gate linkAtts = 0;
1734*0Sstevel@tonic-gate }
1735*0Sstevel@tonic-gate
clear()1736*0Sstevel@tonic-gate void ArcProcessor::MetaMapCache::clear()
1737*0Sstevel@tonic-gate {
1738*0Sstevel@tonic-gate for (int i = 0; i < nNoSpec; i++)
1739*0Sstevel@tonic-gate noSpec[i] = invalidAtt;
1740*0Sstevel@tonic-gate linkAtts = 0;
1741*0Sstevel@tonic-gate map.clear();
1742*0Sstevel@tonic-gate }
1743*0Sstevel@tonic-gate
MetaMap()1744*0Sstevel@tonic-gate ArcProcessor::MetaMap::MetaMap()
1745*0Sstevel@tonic-gate : attributed(0)
1746*0Sstevel@tonic-gate {
1747*0Sstevel@tonic-gate }
1748*0Sstevel@tonic-gate
clear()1749*0Sstevel@tonic-gate void ArcProcessor::MetaMap::clear()
1750*0Sstevel@tonic-gate {
1751*0Sstevel@tonic-gate attMapFrom.clear();
1752*0Sstevel@tonic-gate attMapTo.clear();
1753*0Sstevel@tonic-gate attributed = 0;
1754*0Sstevel@tonic-gate }
1755*0Sstevel@tonic-gate
1756*0Sstevel@tonic-gate #ifdef SP_NAMESPACE
1757*0Sstevel@tonic-gate }
1758*0Sstevel@tonic-gate #endif
1759