01: /*
02: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package com.sun.tools.internal.ws.wsdl.parser;
27:
28: import java.io.IOException;
29:
30: import org.w3c.dom.Element;
31:
32: import com.sun.tools.internal.ws.wsdl.document.schema.Schema;
33: import com.sun.tools.internal.ws.wsdl.document.schema.SchemaConstants;
34: import com.sun.tools.internal.ws.wsdl.framework.Extensible;
35: import com.sun.tools.internal.ws.wsdl.framework.Extension;
36: import com.sun.tools.internal.ws.wsdl.framework.ParserContext;
37: import com.sun.tools.internal.ws.wsdl.framework.WriterContext;
38: import com.sun.tools.internal.ws.util.xml.XmlUtil;
39:
40: /**
41: * The XML Schema extension handler for WSDL.
42: *
43: * @author WS Development Team
44: */
45: public class SchemaExtensionHandler extends ExtensionHandler {
46:
47: public SchemaExtensionHandler() {
48: }
49:
50: public String getNamespaceURI() {
51: return Constants.NS_XSD;
52: }
53:
54: public boolean doHandleExtension(ParserContext context,
55: Extensible parent, Element e) {
56: if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_SCHEMA)) {
57: SchemaParser parser = new SchemaParser();
58: parent.addExtension(parser.parseSchema(context, e, null));
59: return true;
60: } else {
61: return false;
62: }
63: }
64:
65: public void doHandleExtension(WriterContext context,
66: Extension extension) throws IOException {
67: if (extension instanceof Schema) {
68: SchemaWriter writer = new SchemaWriter();
69: writer.writeSchema(context, (Schema) extension);
70: } else {
71: // unknown extension
72: throw new IllegalArgumentException();
73: }
74: }
75: }
|