001: /* this file is generated by RelaxNGCC */
002: package com.sun.xml.xsom.impl.parser.state;
003:
004: import org.xml.sax.SAXException;
005: import org.xml.sax.XMLReader;
006: import org.xml.sax.Attributes;
007: import com.sun.xml.xsom.impl.parser.NGCCRuntimeEx;
008:
009: import com.sun.xml.xsom.*;
010: import com.sun.xml.xsom.parser.*;
011: import com.sun.xml.xsom.impl.*;
012: import com.sun.xml.xsom.impl.parser.*;
013: import org.xml.sax.Locator;
014: import org.xml.sax.ContentHandler;
015: import org.xml.sax.helpers.*;
016: import java.util.*;
017:
018: class attributeDeclBody extends NGCCHandler {
019: private String name;
020: private ForeignAttributesImpl fa;
021: private AnnotationImpl annotation;
022: private Locator locator;
023: private boolean isLocal;
024: private String defaultValue;
025: private UName typeName;
026: private String fixedValue;
027: protected final NGCCRuntimeEx $runtime;
028: private int $_ngcc_current_state;
029: protected String $uri;
030: protected String $localName;
031: protected String $qname;
032:
033: public final NGCCRuntime getRuntime() {
034: return ($runtime);
035: }
036:
037: public attributeDeclBody(NGCCHandler parent,
038: NGCCEventSource source, NGCCRuntimeEx runtime, int cookie,
039: Locator _locator, boolean _isLocal, String _defaultValue,
040: String _fixedValue) {
041: super (source, parent, cookie);
042: $runtime = runtime;
043: this .locator = _locator;
044: this .isLocal = _isLocal;
045: this .defaultValue = _defaultValue;
046: this .fixedValue = _fixedValue;
047: $_ngcc_current_state = 13;
048: }
049:
050: public attributeDeclBody(NGCCRuntimeEx runtime, Locator _locator,
051: boolean _isLocal, String _defaultValue, String _fixedValue) {
052: this (null, runtime, runtime, -1, _locator, _isLocal,
053: _defaultValue, _fixedValue);
054: }
055:
056: private void action0() throws SAXException {
057:
058: type = new DelayedRef.SimpleType($runtime, locator,
059: $runtime.currentSchema, typeName);
060:
061: }
062:
063: private void action1() throws SAXException {
064: formSpecified = true;
065: }
066:
067: public void enterElement(String $__uri, String $__local,
068: String $__qname, Attributes $attrs) throws SAXException {
069: int $ai;
070: $uri = $__uri;
071: $localName = $__local;
072: $qname = $__qname;
073: switch ($_ngcc_current_state) {
074: case 13: {
075: if (($ai = $runtime.getAttributeIndex("", "form")) >= 0) {
076: $runtime.consumeAttribute($ai);
077: $runtime.sendEnterElement(super ._cookie, $__uri,
078: $__local, $__qname, $attrs);
079: } else {
080: $_ngcc_current_state = 12;
081: $runtime.sendEnterElement(super ._cookie, $__uri,
082: $__local, $__qname, $attrs);
083: }
084: }
085: break;
086: case 0: {
087: revertToParentFromEnterElement(makeResult(), super ._cookie,
088: $__uri, $__local, $__qname, $attrs);
089: }
090: break;
091: case 12: {
092: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
093: $runtime.consumeAttribute($ai);
094: $runtime.sendEnterElement(super ._cookie, $__uri,
095: $__local, $__qname, $attrs);
096: } else {
097: unexpectedEnterElement($__qname);
098: }
099: }
100: break;
101: case 9: {
102: if ((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
103: .equals("annotation")) || ((($ai = $runtime
104: .getAttributeIndex("", "type")) >= 0 && (($__uri
105: .equals("http://www.w3.org/2001/XMLSchema") && $__local
106: .equals("simpleType")) || ($__uri
107: .equals("http://www.w3.org/2001/XMLSchema") && $__local
108: .equals("annotation")))) || ($__uri
109: .equals("http://www.w3.org/2001/XMLSchema") && $__local
110: .equals("simpleType"))))) {
111: NGCCHandler h = new foreignAttributes(this ,
112: super ._source, $runtime, 340, fa);
113: spawnChildFromEnterElement(h, $__uri, $__local,
114: $__qname, $attrs);
115: } else {
116: NGCCHandler h = new foreignAttributes(this ,
117: super ._source, $runtime, 340, fa);
118: spawnChildFromEnterElement(h, $__uri, $__local,
119: $__qname, $attrs);
120: }
121: }
122: break;
123: case 7: {
124: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
125: .equals("annotation"))) {
126: NGCCHandler h = new annotation(this , super ._source,
127: $runtime, 338, null,
128: AnnotationContext.ATTRIBUTE_DECL);
129: spawnChildFromEnterElement(h, $__uri, $__local,
130: $__qname, $attrs);
131: } else {
132: $_ngcc_current_state = 1;
133: $runtime.sendEnterElement(super ._cookie, $__uri,
134: $__local, $__qname, $attrs);
135: }
136: }
137: break;
138: case 1: {
139: if (($ai = $runtime.getAttributeIndex("", "type")) >= 0) {
140: $runtime.consumeAttribute($ai);
141: $runtime.sendEnterElement(super ._cookie, $__uri,
142: $__local, $__qname, $attrs);
143: } else {
144: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
145: .equals("simpleType"))) {
146: NGCCHandler h = new simpleType(this , super ._source,
147: $runtime, 329);
148: spawnChildFromEnterElement(h, $__uri, $__local,
149: $__qname, $attrs);
150: } else {
151: $_ngcc_current_state = 0;
152: $runtime.sendEnterElement(super ._cookie, $__uri,
153: $__local, $__qname, $attrs);
154: }
155: }
156: }
157: break;
158: default: {
159: unexpectedEnterElement($__qname);
160: }
161: break;
162: }
163: }
164:
165: public void leaveElement(String $__uri, String $__local,
166: String $__qname) throws SAXException {
167: int $ai;
168: $uri = $__uri;
169: $localName = $__local;
170: $qname = $__qname;
171: switch ($_ngcc_current_state) {
172: case 13: {
173: if (($ai = $runtime.getAttributeIndex("", "form")) >= 0) {
174: $runtime.consumeAttribute($ai);
175: $runtime.sendLeaveElement(super ._cookie, $__uri,
176: $__local, $__qname);
177: } else {
178: $_ngcc_current_state = 12;
179: $runtime.sendLeaveElement(super ._cookie, $__uri,
180: $__local, $__qname);
181: }
182: }
183: break;
184: case 0: {
185: revertToParentFromLeaveElement(makeResult(), super ._cookie,
186: $__uri, $__local, $__qname);
187: }
188: break;
189: case 12: {
190: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
191: $runtime.consumeAttribute($ai);
192: $runtime.sendLeaveElement(super ._cookie, $__uri,
193: $__local, $__qname);
194: } else {
195: unexpectedLeaveElement($__qname);
196: }
197: }
198: break;
199: case 9: {
200: if (($ai = $runtime.getAttributeIndex("", "type")) >= 0) {
201: NGCCHandler h = new foreignAttributes(this ,
202: super ._source, $runtime, 340, fa);
203: spawnChildFromLeaveElement(h, $__uri, $__local,
204: $__qname);
205: } else {
206: NGCCHandler h = new foreignAttributes(this ,
207: super ._source, $runtime, 340, fa);
208: spawnChildFromLeaveElement(h, $__uri, $__local,
209: $__qname);
210: }
211: }
212: break;
213: case 7: {
214: $_ngcc_current_state = 1;
215: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
216: $__qname);
217: }
218: break;
219: case 1: {
220: if (($ai = $runtime.getAttributeIndex("", "type")) >= 0) {
221: $runtime.consumeAttribute($ai);
222: $runtime.sendLeaveElement(super ._cookie, $__uri,
223: $__local, $__qname);
224: } else {
225: $_ngcc_current_state = 0;
226: $runtime.sendLeaveElement(super ._cookie, $__uri,
227: $__local, $__qname);
228: }
229: }
230: break;
231: default: {
232: unexpectedLeaveElement($__qname);
233: }
234: break;
235: }
236: }
237:
238: public void enterAttribute(String $__uri, String $__local,
239: String $__qname) throws SAXException {
240: int $ai;
241: $uri = $__uri;
242: $localName = $__local;
243: $qname = $__qname;
244: switch ($_ngcc_current_state) {
245: case 13: {
246: if (($__uri.equals("") && $__local.equals("form"))) {
247: $_ngcc_current_state = 15;
248: } else {
249: $_ngcc_current_state = 12;
250: $runtime.sendEnterAttribute(super ._cookie, $__uri,
251: $__local, $__qname);
252: }
253: }
254: break;
255: case 0: {
256: revertToParentFromEnterAttribute(makeResult(),
257: super ._cookie, $__uri, $__local, $__qname);
258: }
259: break;
260: case 12: {
261: if (($__uri.equals("") && $__local.equals("name"))) {
262: $_ngcc_current_state = 11;
263: } else {
264: unexpectedEnterAttribute($__qname);
265: }
266: }
267: break;
268: case 9: {
269: if (($__uri.equals("") && $__local.equals("type"))) {
270: NGCCHandler h = new foreignAttributes(this ,
271: super ._source, $runtime, 340, fa);
272: spawnChildFromEnterAttribute(h, $__uri, $__local,
273: $__qname);
274: } else {
275: NGCCHandler h = new foreignAttributes(this ,
276: super ._source, $runtime, 340, fa);
277: spawnChildFromEnterAttribute(h, $__uri, $__local,
278: $__qname);
279: }
280: }
281: break;
282: case 7: {
283: $_ngcc_current_state = 1;
284: $runtime.sendEnterAttribute(super ._cookie, $__uri,
285: $__local, $__qname);
286: }
287: break;
288: case 1: {
289: if (($__uri.equals("") && $__local.equals("type"))) {
290: $_ngcc_current_state = 5;
291: } else {
292: $_ngcc_current_state = 0;
293: $runtime.sendEnterAttribute(super ._cookie, $__uri,
294: $__local, $__qname);
295: }
296: }
297: break;
298: default: {
299: unexpectedEnterAttribute($__qname);
300: }
301: break;
302: }
303: }
304:
305: public void leaveAttribute(String $__uri, String $__local,
306: String $__qname) throws SAXException {
307: int $ai;
308: $uri = $__uri;
309: $localName = $__local;
310: $qname = $__qname;
311: switch ($_ngcc_current_state) {
312: case 13: {
313: $_ngcc_current_state = 12;
314: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
315: $__local, $__qname);
316: }
317: break;
318: case 0: {
319: revertToParentFromLeaveAttribute(makeResult(),
320: super ._cookie, $__uri, $__local, $__qname);
321: }
322: break;
323: case 10: {
324: if (($__uri.equals("") && $__local.equals("name"))) {
325: $_ngcc_current_state = 9;
326: } else {
327: unexpectedLeaveAttribute($__qname);
328: }
329: }
330: break;
331: case 9: {
332: NGCCHandler h = new foreignAttributes(this , super ._source,
333: $runtime, 340, fa);
334: spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
335: }
336: break;
337: case 7: {
338: $_ngcc_current_state = 1;
339: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
340: $__local, $__qname);
341: }
342: break;
343: case 4: {
344: if (($__uri.equals("") && $__local.equals("type"))) {
345: $_ngcc_current_state = 0;
346: } else {
347: unexpectedLeaveAttribute($__qname);
348: }
349: }
350: break;
351: case 14: {
352: if (($__uri.equals("") && $__local.equals("form"))) {
353: $_ngcc_current_state = 12;
354: } else {
355: unexpectedLeaveAttribute($__qname);
356: }
357: }
358: break;
359: case 1: {
360: $_ngcc_current_state = 0;
361: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
362: $__local, $__qname);
363: }
364: break;
365: default: {
366: unexpectedLeaveAttribute($__qname);
367: }
368: break;
369: }
370: }
371:
372: public void text(String $value) throws SAXException {
373: int $ai;
374: switch ($_ngcc_current_state) {
375: case 11: {
376: name = $value;
377: $_ngcc_current_state = 10;
378: }
379: break;
380: case 13: {
381: if (($ai = $runtime.getAttributeIndex("", "form")) >= 0) {
382: $runtime.consumeAttribute($ai);
383: $runtime.sendText(super ._cookie, $value);
384: } else {
385: $_ngcc_current_state = 12;
386: $runtime.sendText(super ._cookie, $value);
387: }
388: }
389: break;
390: case 0: {
391: revertToParentFromText(makeResult(), super ._cookie, $value);
392: }
393: break;
394: case 15: {
395: if ($value.equals("unqualified")) {
396: NGCCHandler h = new qualification(this , super ._source,
397: $runtime, 345);
398: spawnChildFromText(h, $value);
399: } else {
400: if ($value.equals("qualified")) {
401: NGCCHandler h = new qualification(this ,
402: super ._source, $runtime, 345);
403: spawnChildFromText(h, $value);
404: }
405: }
406: }
407: break;
408: case 12: {
409: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
410: $runtime.consumeAttribute($ai);
411: $runtime.sendText(super ._cookie, $value);
412: }
413: }
414: break;
415: case 9: {
416: if (($ai = $runtime.getAttributeIndex("", "type")) >= 0) {
417: NGCCHandler h = new foreignAttributes(this ,
418: super ._source, $runtime, 340, fa);
419: spawnChildFromText(h, $value);
420: } else {
421: NGCCHandler h = new foreignAttributes(this ,
422: super ._source, $runtime, 340, fa);
423: spawnChildFromText(h, $value);
424: }
425: }
426: break;
427: case 7: {
428: $_ngcc_current_state = 1;
429: $runtime.sendText(super ._cookie, $value);
430: }
431: break;
432: case 1: {
433: if (($ai = $runtime.getAttributeIndex("", "type")) >= 0) {
434: $runtime.consumeAttribute($ai);
435: $runtime.sendText(super ._cookie, $value);
436: } else {
437: $_ngcc_current_state = 0;
438: $runtime.sendText(super ._cookie, $value);
439: }
440: }
441: break;
442: case 5: {
443: NGCCHandler h = new qname(this , super ._source, $runtime,
444: 331);
445: spawnChildFromText(h, $value);
446: }
447: break;
448: }
449: }
450:
451: public void onChildCompleted(Object $__result__, int $__cookie__,
452: boolean $__needAttCheck__) throws SAXException {
453: switch ($__cookie__) {
454: case 345: {
455: form = ((Boolean) $__result__).booleanValue();
456: action1();
457: $_ngcc_current_state = 14;
458: }
459: break;
460: case 340: {
461: fa = ((ForeignAttributesImpl) $__result__);
462: $_ngcc_current_state = 7;
463: }
464: break;
465: case 338: {
466: annotation = ((AnnotationImpl) $__result__);
467: $_ngcc_current_state = 1;
468: }
469: break;
470: case 329: {
471: type = ((SimpleTypeImpl) $__result__);
472: $_ngcc_current_state = 0;
473: }
474: break;
475: case 331: {
476: typeName = ((UName) $__result__);
477: action0();
478: $_ngcc_current_state = 4;
479: }
480: break;
481: }
482: }
483:
484: public boolean accepted() {
485: return ((($_ngcc_current_state == 1) || (($_ngcc_current_state == 0) || ($_ngcc_current_state == 7))));
486: }
487:
488: private boolean form;
489: private boolean formSpecified = false;
490:
491: private AttributeDeclImpl makeResult() {
492:
493: if (type == null)
494: // type defaults to anySimpleType
495: type = $runtime.parser.schemaSet.anySimpleType;
496:
497: if (!formSpecified)
498: form = $runtime.attributeFormDefault;
499: // global attributes are always qualified
500: if (!isLocal)
501: form = true;
502:
503: String tns;
504: if (form == true)
505: tns = $runtime.currentSchema.getTargetNamespace();
506: else
507: tns = "";
508:
509: // proper handling of anonymous types
510: return new AttributeDeclImpl($runtime.document, tns, name,
511: annotation, locator, fa, isLocal, $runtime
512: .createXmlString(defaultValue), $runtime
513: .createXmlString(fixedValue), type);
514: }
515:
516: private Ref.SimpleType type;
517:
518: }
|