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