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