KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > schema > loader > AttributeTypeHandler


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.schema.loader;
24
25 import org.xml.sax.Attributes JavaDoc;
26 import org.xml.sax.SAXException JavaDoc;
27 import org.xquark.schema.*;
28 import org.xquark.util.DefaultElementHandler;
29 import org.xquark.util.ElementHandler;
30
31 class AttributeTypeHandler extends DefaultElementHandler implements SchemaConstants
32 {
33 private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
34 private static final String JavaDoc RCSName = "$Name: $";
35     private Loader loader = null;
36   private AttributeDeclaration decl;
37
38     AttributeTypeHandler(Loader loader, AttributeDeclaration decl) {
39         this.loader = loader;
40         this.decl = decl;
41     }
42     
43   // schema 2001-05
44
// May 17,2001
45
public ElementHandler startElement(String JavaDoc namespaceURI, String JavaDoc localName, Attributes JavaDoc atts)
46     throws SAXException JavaDoc
47     {
48         if ( namespaceURI.equals(XMLSCHEMA_URI) ) {
49         if (localName.equals(SIMPLE_TYPE_TAG)) {
50           if ( decl instanceof AttributeDeclarationRef ) {
51             String JavaDoc errCode = "src-attribute.3.2";
52             String JavaDoc errMsg = "Error while processing localName -> " + localName;
53             loader.reportLoadingError(errMsg, new SchemaException(errCode));
54           }
55           if (decl.getType() != null) {
56             String JavaDoc errCode = "src-attribute.4";
57             String JavaDoc errMsg = "Error while processing localName -> " + localName;
58             loader.reportLoadingError(errMsg, new SchemaException(errCode));
59           }
60           SimpleType type = null;
61           try {
62             type = loader.buildSimpleType(atts);
63           }
64           catch ( SchemaException se ) {
65             String JavaDoc errMsg = "Error while processing localName -> " + localName;
66             loader.reportLoadingError(errMsg, se);
67           }
68           decl.setType(type);
69           return new SimpleTypeHandler(loader, type, false, false);
70         }
71         
72         else if (localName.equals(ANNOTATION_TAG)) {
73           return new AnnotationHandler();
74         }
75         }
76         loader.notifyUnknownElement(namespaceURI, localName);
77         return this;
78     }
79 }
80     
81
Popular Tags