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: import java.util.StringTokenizer;
019: import java.util.HashSet;
020:
021: class wildcardBody extends NGCCHandler {
022: private AnnotationImpl annotation;
023: private Locator locator;
024: private String modeValue;
025: private String ns;
026: private ForeignAttributesImpl fa;
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 wildcardBody(NGCCHandler parent, NGCCEventSource source,
038: NGCCRuntimeEx runtime, int cookie, Locator _locator) {
039: super (source, parent, cookie);
040: $runtime = runtime;
041: this .locator = _locator;
042: $_ngcc_current_state = 10;
043: }
044:
045: public wildcardBody(NGCCRuntimeEx runtime, Locator _locator) {
046: this (null, runtime, runtime, -1, _locator);
047: }
048:
049: public void enterElement(String $__uri, String $__local,
050: String $__qname, Attributes $attrs) throws SAXException {
051: int $ai;
052: $uri = $__uri;
053: $localName = $__local;
054: $qname = $__qname;
055: switch ($_ngcc_current_state) {
056: case 10: {
057: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
058: .equals("annotation"))) {
059: NGCCHandler h = new annotation(this , super ._source,
060: $runtime, 556, null, AnnotationContext.WILDCARD);
061: spawnChildFromEnterElement(h, $__uri, $__local,
062: $__qname, $attrs);
063: } else {
064: $_ngcc_current_state = 9;
065: $runtime.sendEnterElement(super ._cookie, $__uri,
066: $__local, $__qname, $attrs);
067: }
068: }
069: break;
070: case 0: {
071: revertToParentFromEnterElement(makeResult(), super ._cookie,
072: $__uri, $__local, $__qname, $attrs);
073: }
074: break;
075: case 1: {
076: if (($ai = $runtime.getAttributeIndex("", "namespace")) >= 0) {
077: $runtime.consumeAttribute($ai);
078: $runtime.sendEnterElement(super ._cookie, $__uri,
079: $__local, $__qname, $attrs);
080: } else {
081: $_ngcc_current_state = 0;
082: $runtime.sendEnterElement(super ._cookie, $__uri,
083: $__local, $__qname, $attrs);
084: }
085: }
086: break;
087: case 9: {
088: if ((($ai = $runtime.getAttributeIndex("",
089: "processContents")) >= 0 || ($ai = $runtime
090: .getAttributeIndex("", "namespace")) >= 0)) {
091: NGCCHandler h = new foreignAttributes(this ,
092: super ._source, $runtime, 554, null);
093: spawnChildFromEnterElement(h, $__uri, $__local,
094: $__qname, $attrs);
095: } else {
096: NGCCHandler h = new foreignAttributes(this ,
097: super ._source, $runtime, 554, null);
098: spawnChildFromEnterElement(h, $__uri, $__local,
099: $__qname, $attrs);
100: }
101: }
102: break;
103: case 5: {
104: if (($ai = $runtime
105: .getAttributeIndex("", "processContents")) >= 0) {
106: $runtime.consumeAttribute($ai);
107: $runtime.sendEnterElement(super ._cookie, $__uri,
108: $__local, $__qname, $attrs);
109: } else {
110: $_ngcc_current_state = 1;
111: $runtime.sendEnterElement(super ._cookie, $__uri,
112: $__local, $__qname, $attrs);
113: }
114: }
115: break;
116: default: {
117: unexpectedEnterElement($__qname);
118: }
119: break;
120: }
121: }
122:
123: public void leaveElement(String $__uri, String $__local,
124: String $__qname) throws SAXException {
125: int $ai;
126: $uri = $__uri;
127: $localName = $__local;
128: $qname = $__qname;
129: switch ($_ngcc_current_state) {
130: case 10: {
131: $_ngcc_current_state = 9;
132: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
133: $__qname);
134: }
135: break;
136: case 0: {
137: revertToParentFromLeaveElement(makeResult(), super ._cookie,
138: $__uri, $__local, $__qname);
139: }
140: break;
141: case 1: {
142: if (($ai = $runtime.getAttributeIndex("", "namespace")) >= 0) {
143: $runtime.consumeAttribute($ai);
144: $runtime.sendLeaveElement(super ._cookie, $__uri,
145: $__local, $__qname);
146: } else {
147: $_ngcc_current_state = 0;
148: $runtime.sendLeaveElement(super ._cookie, $__uri,
149: $__local, $__qname);
150: }
151: }
152: break;
153: case 9: {
154: if ((($ai = $runtime.getAttributeIndex("",
155: "processContents")) >= 0 || ($ai = $runtime
156: .getAttributeIndex("", "namespace")) >= 0)) {
157: NGCCHandler h = new foreignAttributes(this ,
158: super ._source, $runtime, 554, null);
159: spawnChildFromLeaveElement(h, $__uri, $__local,
160: $__qname);
161: } else {
162: NGCCHandler h = new foreignAttributes(this ,
163: super ._source, $runtime, 554, null);
164: spawnChildFromLeaveElement(h, $__uri, $__local,
165: $__qname);
166: }
167: }
168: break;
169: case 5: {
170: if (($ai = $runtime
171: .getAttributeIndex("", "processContents")) >= 0) {
172: $runtime.consumeAttribute($ai);
173: $runtime.sendLeaveElement(super ._cookie, $__uri,
174: $__local, $__qname);
175: } else {
176: $_ngcc_current_state = 1;
177: $runtime.sendLeaveElement(super ._cookie, $__uri,
178: $__local, $__qname);
179: }
180: }
181: break;
182: default: {
183: unexpectedLeaveElement($__qname);
184: }
185: break;
186: }
187: }
188:
189: public void enterAttribute(String $__uri, String $__local,
190: String $__qname) throws SAXException {
191: int $ai;
192: $uri = $__uri;
193: $localName = $__local;
194: $qname = $__qname;
195: switch ($_ngcc_current_state) {
196: case 10: {
197: $_ngcc_current_state = 9;
198: $runtime.sendEnterAttribute(super ._cookie, $__uri,
199: $__local, $__qname);
200: }
201: break;
202: case 0: {
203: revertToParentFromEnterAttribute(makeResult(),
204: super ._cookie, $__uri, $__local, $__qname);
205: }
206: break;
207: case 1: {
208: if (($__uri.equals("") && $__local.equals("namespace"))) {
209: $_ngcc_current_state = 3;
210: } else {
211: $_ngcc_current_state = 0;
212: $runtime.sendEnterAttribute(super ._cookie, $__uri,
213: $__local, $__qname);
214: }
215: }
216: break;
217: case 9: {
218: if ((($__uri.equals("") && $__local
219: .equals("processContents")) || ($__uri.equals("") && $__local
220: .equals("namespace")))) {
221: NGCCHandler h = new foreignAttributes(this ,
222: super ._source, $runtime, 554, null);
223: spawnChildFromEnterAttribute(h, $__uri, $__local,
224: $__qname);
225: } else {
226: NGCCHandler h = new foreignAttributes(this ,
227: super ._source, $runtime, 554, null);
228: spawnChildFromEnterAttribute(h, $__uri, $__local,
229: $__qname);
230: }
231: }
232: break;
233: case 5: {
234: if (($__uri.equals("") && $__local
235: .equals("processContents"))) {
236: $_ngcc_current_state = 7;
237: } else {
238: $_ngcc_current_state = 1;
239: $runtime.sendEnterAttribute(super ._cookie, $__uri,
240: $__local, $__qname);
241: }
242: }
243: break;
244: default: {
245: unexpectedEnterAttribute($__qname);
246: }
247: break;
248: }
249: }
250:
251: public void leaveAttribute(String $__uri, String $__local,
252: String $__qname) throws SAXException {
253: int $ai;
254: $uri = $__uri;
255: $localName = $__local;
256: $qname = $__qname;
257: switch ($_ngcc_current_state) {
258: case 10: {
259: $_ngcc_current_state = 9;
260: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
261: $__local, $__qname);
262: }
263: break;
264: case 0: {
265: revertToParentFromLeaveAttribute(makeResult(),
266: super ._cookie, $__uri, $__local, $__qname);
267: }
268: break;
269: case 1: {
270: $_ngcc_current_state = 0;
271: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
272: $__local, $__qname);
273: }
274: break;
275: case 6: {
276: if (($__uri.equals("") && $__local
277: .equals("processContents"))) {
278: $_ngcc_current_state = 1;
279: } else {
280: unexpectedLeaveAttribute($__qname);
281: }
282: }
283: break;
284: case 9: {
285: NGCCHandler h = new foreignAttributes(this , super ._source,
286: $runtime, 554, null);
287: spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
288: }
289: break;
290: case 2: {
291: if (($__uri.equals("") && $__local.equals("namespace"))) {
292: $_ngcc_current_state = 0;
293: } else {
294: unexpectedLeaveAttribute($__qname);
295: }
296: }
297: break;
298: case 5: {
299: $_ngcc_current_state = 1;
300: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
301: $__local, $__qname);
302: }
303: break;
304: default: {
305: unexpectedLeaveAttribute($__qname);
306: }
307: break;
308: }
309: }
310:
311: public void text(String $value) throws SAXException {
312: int $ai;
313: switch ($_ngcc_current_state) {
314: case 10: {
315: $_ngcc_current_state = 9;
316: $runtime.sendText(super ._cookie, $value);
317: }
318: break;
319: case 0: {
320: revertToParentFromText(makeResult(), super ._cookie, $value);
321: }
322: break;
323: case 1: {
324: if (($ai = $runtime.getAttributeIndex("", "namespace")) >= 0) {
325: $runtime.consumeAttribute($ai);
326: $runtime.sendText(super ._cookie, $value);
327: } else {
328: $_ngcc_current_state = 0;
329: $runtime.sendText(super ._cookie, $value);
330: }
331: }
332: break;
333: case 3: {
334: ns = $value;
335: $_ngcc_current_state = 2;
336: }
337: break;
338: case 9: {
339: if (($ai = $runtime.getAttributeIndex("", "namespace")) >= 0) {
340: NGCCHandler h = new foreignAttributes(this ,
341: super ._source, $runtime, 554, null);
342: spawnChildFromText(h, $value);
343: } else {
344: if (($ai = $runtime.getAttributeIndex("",
345: "processContents")) >= 0) {
346: NGCCHandler h = new foreignAttributes(this ,
347: super ._source, $runtime, 554, null);
348: spawnChildFromText(h, $value);
349: } else {
350: NGCCHandler h = new foreignAttributes(this ,
351: super ._source, $runtime, 554, null);
352: spawnChildFromText(h, $value);
353: }
354: }
355: }
356: break;
357: case 7: {
358: modeValue = $value;
359: $_ngcc_current_state = 6;
360: }
361: break;
362: case 5: {
363: if (($ai = $runtime
364: .getAttributeIndex("", "processContents")) >= 0) {
365: $runtime.consumeAttribute($ai);
366: $runtime.sendText(super ._cookie, $value);
367: } else {
368: $_ngcc_current_state = 1;
369: $runtime.sendText(super ._cookie, $value);
370: }
371: }
372: break;
373: }
374: }
375:
376: public void onChildCompleted(Object $__result__, int $__cookie__,
377: boolean $__needAttCheck__) throws SAXException {
378: switch ($__cookie__) {
379: case 556: {
380: annotation = ((AnnotationImpl) $__result__);
381: $_ngcc_current_state = 9;
382: }
383: break;
384: case 554: {
385: fa = ((ForeignAttributesImpl) $__result__);
386: $_ngcc_current_state = 5;
387: }
388: break;
389: }
390: }
391:
392: public boolean accepted() {
393: return ((($_ngcc_current_state == 5) || (($_ngcc_current_state == 1) || ($_ngcc_current_state == 0))));
394: }
395:
396: private WildcardImpl makeResult() {
397: if (modeValue == null)
398: modeValue = "strict";
399:
400: int mode = -1;
401: if (modeValue.equals("strict"))
402: mode = XSWildcard.STRTICT;
403: if (modeValue.equals("lax"))
404: mode = XSWildcard.LAX;
405: if (modeValue.equals("skip"))
406: mode = XSWildcard.SKIP;
407: if (mode == -1)
408: throw new InternalError();
409:
410: if (ns == null || ns.equals("##any"))
411: return new WildcardImpl.Any($runtime.document, annotation,
412: locator, fa, mode);
413:
414: if (ns.equals("##other"))
415: return new WildcardImpl.Other($runtime.document,
416: annotation, locator, fa, $runtime.currentSchema
417: .getTargetNamespace(), mode);
418:
419: StringTokenizer tokens = new StringTokenizer(ns);
420: HashSet s = new HashSet();
421: while (tokens.hasMoreTokens()) {
422: String ns = tokens.nextToken();
423: if (ns.equals("##local"))
424: ns = "";
425: if (ns.equals("##targetNamespace"))
426: ns = $runtime.currentSchema.getTargetNamespace();
427: s.add(ns);
428: }
429:
430: return new WildcardImpl.Finite($runtime.document, annotation,
431: locator, fa, s, mode);
432: }
433:
434: }
|