Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.tools.internal.ws.wsdl.parser; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; |
aoqi@0 | 29 | import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensionHandler; |
aoqi@0 | 30 | import com.sun.tools.internal.ws.resources.WsdlMessages; |
aoqi@0 | 31 | import com.sun.tools.internal.ws.util.xml.XmlUtil; |
aoqi@0 | 32 | import com.sun.tools.internal.ws.wscompile.ErrorReceiverFilter; |
aoqi@0 | 33 | import com.sun.tools.internal.ws.wscompile.WsimportOptions; |
aoqi@0 | 34 | import com.sun.tools.internal.ws.wsdl.document.Binding; |
aoqi@0 | 35 | import com.sun.tools.internal.ws.wsdl.document.BindingFault; |
aoqi@0 | 36 | import com.sun.tools.internal.ws.wsdl.document.BindingInput; |
aoqi@0 | 37 | import com.sun.tools.internal.ws.wsdl.document.BindingOperation; |
aoqi@0 | 38 | import com.sun.tools.internal.ws.wsdl.document.BindingOutput; |
aoqi@0 | 39 | import com.sun.tools.internal.ws.wsdl.document.Definitions; |
aoqi@0 | 40 | import com.sun.tools.internal.ws.wsdl.document.Documentation; |
aoqi@0 | 41 | import com.sun.tools.internal.ws.wsdl.document.Fault; |
aoqi@0 | 42 | import com.sun.tools.internal.ws.wsdl.document.Import; |
aoqi@0 | 43 | import com.sun.tools.internal.ws.wsdl.document.Input; |
aoqi@0 | 44 | import com.sun.tools.internal.ws.wsdl.document.Message; |
aoqi@0 | 45 | import com.sun.tools.internal.ws.wsdl.document.MessagePart; |
aoqi@0 | 46 | import com.sun.tools.internal.ws.wsdl.document.Operation; |
aoqi@0 | 47 | import com.sun.tools.internal.ws.wsdl.document.OperationStyle; |
aoqi@0 | 48 | import com.sun.tools.internal.ws.wsdl.document.Output; |
aoqi@0 | 49 | import com.sun.tools.internal.ws.wsdl.document.Port; |
aoqi@0 | 50 | import com.sun.tools.internal.ws.wsdl.document.PortType; |
aoqi@0 | 51 | import com.sun.tools.internal.ws.wsdl.document.Service; |
aoqi@0 | 52 | import com.sun.tools.internal.ws.wsdl.document.WSDLConstants; |
aoqi@0 | 53 | import com.sun.tools.internal.ws.wsdl.document.WSDLDocument; |
aoqi@0 | 54 | import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBindingsConstants; |
aoqi@0 | 55 | import com.sun.tools.internal.ws.wsdl.document.schema.SchemaConstants; |
aoqi@0 | 56 | import com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds; |
aoqi@0 | 57 | import com.sun.tools.internal.ws.wsdl.framework.Entity; |
aoqi@0 | 58 | import com.sun.tools.internal.ws.wsdl.framework.ParserListener; |
aoqi@0 | 59 | import com.sun.tools.internal.ws.wsdl.framework.TWSDLParserContextImpl; |
aoqi@0 | 60 | import com.sun.xml.internal.ws.util.ServiceFinder; |
aoqi@0 | 61 | import org.w3c.dom.Attr; |
aoqi@0 | 62 | import org.w3c.dom.Document; |
aoqi@0 | 63 | import org.w3c.dom.Element; |
aoqi@0 | 64 | import org.w3c.dom.NodeList; |
aoqi@0 | 65 | import org.xml.sax.InputSource; |
aoqi@0 | 66 | import org.xml.sax.Locator; |
aoqi@0 | 67 | import org.xml.sax.SAXException; |
aoqi@0 | 68 | |
aoqi@0 | 69 | import java.io.IOException; |
aoqi@0 | 70 | import java.util.ArrayList; |
aoqi@0 | 71 | import java.util.HashMap; |
aoqi@0 | 72 | import java.util.Iterator; |
aoqi@0 | 73 | import java.util.Map; |
aoqi@0 | 74 | import org.w3c.dom.Node; |
aoqi@0 | 75 | |
aoqi@0 | 76 | /** |
aoqi@0 | 77 | * A parser for WSDL documents. This parser is used only at the tool time. |
aoqi@0 | 78 | * Extensions should extend TWSDLExtensionHandler, so that it will be called during |
aoqi@0 | 79 | * parsing wsdl to handle wsdl extenisbility elements. Generally these extensions |
aoqi@0 | 80 | * will effect the artifacts generated during WSDL processing. |
aoqi@0 | 81 | * |
aoqi@0 | 82 | * @see com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser which will be used for WSDL parsing |
aoqi@0 | 83 | * at runtime. |
aoqi@0 | 84 | * |
aoqi@0 | 85 | * @author WS Development Team |
aoqi@0 | 86 | */ |
aoqi@0 | 87 | public class WSDLParser { |
aoqi@0 | 88 | private final ErrorReceiverFilter errReceiver; |
aoqi@0 | 89 | private WsimportOptions options; |
aoqi@0 | 90 | |
aoqi@0 | 91 | //wsdl extension handlers |
aoqi@0 | 92 | private final Map extensionHandlers; |
aoqi@0 | 93 | private MetadataFinder forest; |
aoqi@0 | 94 | private ArrayList<ParserListener> listeners; |
aoqi@0 | 95 | |
aoqi@0 | 96 | public WSDLParser(WsimportOptions options, ErrorReceiverFilter errReceiver, MetadataFinder forest) { |
aoqi@0 | 97 | this.extensionHandlers = new HashMap(); |
aoqi@0 | 98 | this.options = options; |
aoqi@0 | 99 | this.errReceiver = errReceiver; |
aoqi@0 | 100 | if (forest == null) { |
aoqi@0 | 101 | forest = new MetadataFinder(new WSDLInternalizationLogic(), options, errReceiver); |
aoqi@0 | 102 | forest.parseWSDL(); |
aoqi@0 | 103 | if (forest.isMexMetadata) { |
aoqi@0 | 104 | errReceiver.reset(); |
aoqi@0 | 105 | } |
aoqi@0 | 106 | } |
aoqi@0 | 107 | this.forest = forest; |
aoqi@0 | 108 | // register handlers for default extensions |
aoqi@0 | 109 | register(new SOAPExtensionHandler(extensionHandlers)); |
aoqi@0 | 110 | register(new HTTPExtensionHandler(extensionHandlers)); |
aoqi@0 | 111 | register(new MIMEExtensionHandler(extensionHandlers)); |
aoqi@0 | 112 | register(new JAXWSBindingExtensionHandler(extensionHandlers)); |
aoqi@0 | 113 | register(new SOAP12ExtensionHandler(extensionHandlers)); |
aoqi@0 | 114 | |
aoqi@0 | 115 | // MemberSubmission Addressing not supported by WsImport anymore see JAX_WS-1040 for details |
aoqi@0 | 116 | //register(new MemberSubmissionAddressingExtensionHandler(extensionHandlers, errReceiver, options.isExtensionMode())); |
aoqi@0 | 117 | |
aoqi@0 | 118 | register(new W3CAddressingExtensionHandler(extensionHandlers, errReceiver)); |
aoqi@0 | 119 | register(new W3CAddressingMetadataExtensionHandler(extensionHandlers, errReceiver)); |
aoqi@0 | 120 | register(new Policy12ExtensionHandler()); |
aoqi@0 | 121 | register(new Policy15ExtensionHandler()); |
aoqi@0 | 122 | for (TWSDLExtensionHandler te : ServiceFinder.find(TWSDLExtensionHandler.class)) { |
aoqi@0 | 123 | register(te); |
aoqi@0 | 124 | } |
aoqi@0 | 125 | |
aoqi@0 | 126 | } |
aoqi@0 | 127 | |
aoqi@0 | 128 | //TODO RK remove this after tests are fixed. |
aoqi@0 | 129 | WSDLParser(WsimportOptions options, ErrorReceiverFilter errReceiver) { |
aoqi@0 | 130 | this(options,errReceiver,null); |
aoqi@0 | 131 | } |
aoqi@0 | 132 | private void register(TWSDLExtensionHandler h) { |
aoqi@0 | 133 | extensionHandlers.put(h.getNamespaceURI(), h); |
aoqi@0 | 134 | } |
aoqi@0 | 135 | |
aoqi@0 | 136 | public void addParserListener(ParserListener l) { |
aoqi@0 | 137 | if (listeners == null) { |
aoqi@0 | 138 | listeners = new ArrayList<ParserListener>(); |
aoqi@0 | 139 | } |
aoqi@0 | 140 | listeners.add(l); |
aoqi@0 | 141 | } |
aoqi@0 | 142 | |
aoqi@0 | 143 | public WSDLDocument parse() throws SAXException, IOException { |
aoqi@0 | 144 | // parse external binding files |
aoqi@0 | 145 | for (InputSource value : options.getWSDLBindings()) { |
aoqi@0 | 146 | errReceiver.pollAbort(); |
aoqi@0 | 147 | Document root = forest.parse(value, false); |
aoqi@0 | 148 | if(root==null) continue; // error must have been reported |
aoqi@0 | 149 | Element binding = root.getDocumentElement(); |
aoqi@0 | 150 | if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS) |
aoqi@0 | 151 | || !binding.getLocalName().equals("bindings")){ |
aoqi@0 | 152 | errReceiver.error(forest.locatorTable.getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE( |
aoqi@0 | 153 | binding.getNamespaceURI(), |
aoqi@0 | 154 | binding.getLocalName())); |
aoqi@0 | 155 | continue; |
aoqi@0 | 156 | } |
aoqi@0 | 157 | |
aoqi@0 | 158 | NodeList nl = binding.getElementsByTagNameNS( |
aoqi@0 | 159 | "http://java.sun.com/xml/ns/javaee", "handler-chains"); |
aoqi@0 | 160 | for(int i = 0; i < nl.getLength(); i++){ |
aoqi@0 | 161 | options.addHandlerChainConfiguration((Element) nl.item(i)); |
aoqi@0 | 162 | } |
aoqi@0 | 163 | |
aoqi@0 | 164 | } |
aoqi@0 | 165 | return buildWSDLDocument(); |
aoqi@0 | 166 | } |
aoqi@0 | 167 | |
aoqi@0 | 168 | public MetadataFinder getDOMForest() { |
aoqi@0 | 169 | return forest; |
aoqi@0 | 170 | } |
aoqi@0 | 171 | |
aoqi@0 | 172 | private WSDLDocument buildWSDLDocument(){ |
aoqi@0 | 173 | /** |
aoqi@0 | 174 | * Currently we are working off first WSDL document |
aoqi@0 | 175 | * TODO: add support of creating WSDLDocument from fromjava.collection of WSDL documents |
aoqi@0 | 176 | */ |
aoqi@0 | 177 | |
aoqi@0 | 178 | String location = forest.getRootWSDL(); |
aoqi@0 | 179 | |
aoqi@0 | 180 | //It means that WSDL is not found, an error might have been reported, lets try to recover |
aoqi@0 | 181 | if(location == null) |
aoqi@0 | 182 | return null; |
aoqi@0 | 183 | |
aoqi@0 | 184 | Document root = forest.get(location); |
aoqi@0 | 185 | |
aoqi@0 | 186 | if(root == null) |
aoqi@0 | 187 | return null; |
aoqi@0 | 188 | |
aoqi@0 | 189 | WSDLDocument document = new WSDLDocument(forest, errReceiver); |
aoqi@0 | 190 | document.setSystemId(location); |
aoqi@0 | 191 | TWSDLParserContextImpl context = new TWSDLParserContextImpl(forest, document, listeners, errReceiver); |
aoqi@0 | 192 | |
aoqi@0 | 193 | Definitions definitions = parseDefinitions(context, root); |
aoqi@0 | 194 | document.setDefinitions(definitions); |
aoqi@0 | 195 | return document; |
aoqi@0 | 196 | } |
aoqi@0 | 197 | |
aoqi@0 | 198 | private Definitions parseDefinitions(TWSDLParserContextImpl context, Document root) { |
aoqi@0 | 199 | context.pushWSDLLocation(); |
aoqi@0 | 200 | context.setWSDLLocation(context.getDocument().getSystemId()); |
aoqi@0 | 201 | |
aoqi@0 | 202 | new Internalizer(forest, options, errReceiver).transform(); |
aoqi@0 | 203 | |
aoqi@0 | 204 | Definitions definitions = parseDefinitionsNoImport(context, root); |
aoqi@0 | 205 | if(definitions == null){ |
aoqi@0 | 206 | Locator locator = forest.locatorTable.getStartLocation(root.getDocumentElement()); |
aoqi@0 | 207 | errReceiver.error(locator, WsdlMessages.PARSING_NOT_AWSDL(locator.getSystemId())); |
aoqi@0 | 208 | |
aoqi@0 | 209 | } |
aoqi@0 | 210 | processImports(context); |
aoqi@0 | 211 | context.popWSDLLocation(); |
aoqi@0 | 212 | return definitions; |
aoqi@0 | 213 | } |
aoqi@0 | 214 | |
aoqi@0 | 215 | private void processImports(TWSDLParserContextImpl context) { |
aoqi@0 | 216 | for(String location : forest.getExternalReferences()){ |
aoqi@0 | 217 | if (!context.getDocument().isImportedDocument(location)){ |
aoqi@0 | 218 | Document doc = forest.get(location); |
aoqi@0 | 219 | if(doc == null) |
aoqi@0 | 220 | continue; |
aoqi@0 | 221 | Definitions importedDefinitions = parseDefinitionsNoImport(context, doc); |
aoqi@0 | 222 | if(importedDefinitions == null) |
aoqi@0 | 223 | continue; |
aoqi@0 | 224 | context.getDocument().addImportedEntity(importedDefinitions); |
aoqi@0 | 225 | context.getDocument().addImportedDocument(location); |
aoqi@0 | 226 | } |
aoqi@0 | 227 | } |
aoqi@0 | 228 | } |
aoqi@0 | 229 | |
aoqi@0 | 230 | private Definitions parseDefinitionsNoImport( |
aoqi@0 | 231 | TWSDLParserContextImpl context, |
aoqi@0 | 232 | Document doc) { |
aoqi@0 | 233 | Element e = doc.getDocumentElement(); |
aoqi@0 | 234 | //at this poinjt we expect a wsdl or schema document to be fully qualified |
aoqi@0 | 235 | if(e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e.getLocalName().equals("definitions"))){ |
aoqi@0 | 236 | return null; |
aoqi@0 | 237 | } |
aoqi@0 | 238 | context.push(); |
aoqi@0 | 239 | context.registerNamespaces(e); |
aoqi@0 | 240 | |
aoqi@0 | 241 | Definitions definitions = new Definitions(context.getDocument(), forest.locatorTable.getStartLocation(e)); |
aoqi@0 | 242 | String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME); |
aoqi@0 | 243 | definitions.setName(name); |
aoqi@0 | 244 | |
aoqi@0 | 245 | String targetNamespaceURI = |
aoqi@0 | 246 | XmlUtil.getAttributeOrNull(e, Constants.ATTR_TARGET_NAMESPACE); |
aoqi@0 | 247 | |
aoqi@0 | 248 | definitions.setTargetNamespaceURI(targetNamespaceURI); |
aoqi@0 | 249 | |
aoqi@0 | 250 | boolean gotDocumentation = false; |
aoqi@0 | 251 | boolean gotTypes = false; |
aoqi@0 | 252 | |
aoqi@0 | 253 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 254 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 255 | if (e2 == null) |
aoqi@0 | 256 | break; |
aoqi@0 | 257 | |
aoqi@0 | 258 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 259 | if (gotDocumentation) { |
aoqi@0 | 260 | errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 261 | return null; |
aoqi@0 | 262 | } |
aoqi@0 | 263 | gotDocumentation = true; |
aoqi@0 | 264 | if(definitions.getDocumentation() == null) |
aoqi@0 | 265 | definitions.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 266 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_TYPES)) { |
aoqi@0 | 267 | if (gotTypes && !options.isExtensionMode()) { |
aoqi@0 | 268 | errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS)); |
aoqi@0 | 269 | return null; |
aoqi@0 | 270 | } |
aoqi@0 | 271 | gotTypes = true; |
aoqi@0 | 272 | //add all the wsdl:type elements to latter make a list of all the schema elements |
aoqi@0 | 273 | // that will be needed to create jaxb model |
aoqi@0 | 274 | if(!options.isExtensionMode()) |
aoqi@0 | 275 | validateSchemaImports(e2); |
aoqi@0 | 276 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_MESSAGE)) { |
aoqi@0 | 277 | Message message = parseMessage(context, definitions, e2); |
aoqi@0 | 278 | definitions.add(message); |
aoqi@0 | 279 | } else if ( |
aoqi@0 | 280 | XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT_TYPE)) { |
aoqi@0 | 281 | PortType portType = parsePortType(context, definitions, e2); |
aoqi@0 | 282 | definitions.add(portType); |
aoqi@0 | 283 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_BINDING)) { |
aoqi@0 | 284 | Binding binding = parseBinding(context, definitions, e2); |
aoqi@0 | 285 | definitions.add(binding); |
aoqi@0 | 286 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_SERVICE)) { |
aoqi@0 | 287 | Service service = parseService(context, definitions, e2); |
aoqi@0 | 288 | definitions.add(service); |
aoqi@0 | 289 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_IMPORT)) { |
aoqi@0 | 290 | definitions.add(parseImport(context, definitions, e2)); |
aoqi@0 | 291 | } else if (XmlUtil.matchesTagNS(e2, SchemaConstants.QNAME_IMPORT)) { |
aoqi@0 | 292 | errReceiver.warning(forest.locatorTable.getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003()); |
aoqi@0 | 293 | } else { |
aoqi@0 | 294 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 295 | checkNotWsdlElement(e2); |
aoqi@0 | 296 | if (!handleExtension(context, definitions, e2)) { |
aoqi@0 | 297 | checkNotWsdlRequired(e2); |
aoqi@0 | 298 | } |
aoqi@0 | 299 | } |
aoqi@0 | 300 | } |
aoqi@0 | 301 | |
aoqi@0 | 302 | context.pop(); |
aoqi@0 | 303 | context.fireDoneParsingEntity( |
aoqi@0 | 304 | WSDLConstants.QNAME_DEFINITIONS, |
aoqi@0 | 305 | definitions); |
aoqi@0 | 306 | return definitions; |
aoqi@0 | 307 | } |
aoqi@0 | 308 | |
aoqi@0 | 309 | private Message parseMessage( |
aoqi@0 | 310 | TWSDLParserContextImpl context, |
aoqi@0 | 311 | Definitions definitions, |
aoqi@0 | 312 | Element e) { |
aoqi@0 | 313 | context.push(); |
aoqi@0 | 314 | context.registerNamespaces(e); |
aoqi@0 | 315 | Message message = new Message(definitions, forest.locatorTable.getStartLocation(e), errReceiver); |
aoqi@0 | 316 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 317 | message.setName(name); |
aoqi@0 | 318 | |
aoqi@0 | 319 | boolean gotDocumentation = false; |
aoqi@0 | 320 | |
aoqi@0 | 321 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 322 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 323 | if (e2 == null) |
aoqi@0 | 324 | break; |
aoqi@0 | 325 | |
aoqi@0 | 326 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 327 | if (gotDocumentation) { |
aoqi@0 | 328 | Util.fail( |
aoqi@0 | 329 | "parsing.onlyOneDocumentationAllowed", |
aoqi@0 | 330 | e.getLocalName()); |
aoqi@0 | 331 | } |
aoqi@0 | 332 | gotDocumentation = true; |
aoqi@0 | 333 | message.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 334 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PART)) { |
aoqi@0 | 335 | MessagePart part = parseMessagePart(context, e2); |
aoqi@0 | 336 | message.add(part); |
aoqi@0 | 337 | } else { |
aoqi@0 | 338 | //Ignore any extensibility elements, WS-I BP 1.1 Profiled WSDL 1.1 schema allows extension elements here. |
aoqi@0 | 339 | /*Util.fail( |
aoqi@0 | 340 | "parsing.invalidElement", |
aoqi@0 | 341 | e2.getTagName(), |
aoqi@0 | 342 | e2.getNamespaceURI()); |
aoqi@0 | 343 | */ |
aoqi@0 | 344 | } |
aoqi@0 | 345 | } |
aoqi@0 | 346 | |
aoqi@0 | 347 | context.pop(); |
aoqi@0 | 348 | context.fireDoneParsingEntity(WSDLConstants.QNAME_MESSAGE, message); |
aoqi@0 | 349 | return message; |
aoqi@0 | 350 | } |
aoqi@0 | 351 | |
aoqi@0 | 352 | private MessagePart parseMessagePart(TWSDLParserContextImpl context, Element e) { |
aoqi@0 | 353 | context.push(); |
aoqi@0 | 354 | context.registerNamespaces(e); |
aoqi@0 | 355 | MessagePart part = new MessagePart(forest.locatorTable.getStartLocation(e)); |
aoqi@0 | 356 | String partName = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 357 | part.setName(partName); |
aoqi@0 | 358 | |
aoqi@0 | 359 | String elementAttr = |
aoqi@0 | 360 | XmlUtil.getAttributeOrNull(e, Constants.ATTR_ELEMENT); |
aoqi@0 | 361 | String typeAttr = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TYPE); |
aoqi@0 | 362 | |
aoqi@0 | 363 | if (elementAttr != null) { |
aoqi@0 | 364 | if (typeAttr != null) { |
aoqi@0 | 365 | errReceiver.error(context.getLocation(e), WsdlMessages.PARSING_ONLY_ONE_OF_ELEMENT_OR_TYPE_REQUIRED(partName)); |
aoqi@0 | 366 | |
aoqi@0 | 367 | } |
aoqi@0 | 368 | |
aoqi@0 | 369 | part.setDescriptor(context.translateQualifiedName(context.getLocation(e), elementAttr)); |
aoqi@0 | 370 | part.setDescriptorKind(SchemaKinds.XSD_ELEMENT); |
aoqi@0 | 371 | } else if (typeAttr != null) { |
aoqi@0 | 372 | part.setDescriptor(context.translateQualifiedName(context.getLocation(e), typeAttr)); |
aoqi@0 | 373 | part.setDescriptorKind(SchemaKinds.XSD_TYPE); |
aoqi@0 | 374 | } else { |
aoqi@0 | 375 | // XXX-NOTE - this is wrong; for extensibility purposes, |
aoqi@0 | 376 | // any attribute can be specified on a <part> element, so |
aoqi@0 | 377 | // we need to put an extensibility hook here |
aoqi@0 | 378 | errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ELEMENT_OR_TYPE_REQUIRED(partName)); |
aoqi@0 | 379 | } |
aoqi@0 | 380 | |
aoqi@0 | 381 | context.pop(); |
aoqi@0 | 382 | context.fireDoneParsingEntity(WSDLConstants.QNAME_PART, part); |
aoqi@0 | 383 | return part; |
aoqi@0 | 384 | } |
aoqi@0 | 385 | |
aoqi@0 | 386 | private PortType parsePortType( |
aoqi@0 | 387 | TWSDLParserContextImpl context, |
aoqi@0 | 388 | Definitions definitions, |
aoqi@0 | 389 | Element e) { |
aoqi@0 | 390 | context.push(); |
aoqi@0 | 391 | context.registerNamespaces(e); |
aoqi@0 | 392 | PortType portType = new PortType(definitions, forest.locatorTable.getStartLocation(e), errReceiver); |
aoqi@0 | 393 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 394 | portType.setName(name); |
aoqi@0 | 395 | |
aoqi@0 | 396 | boolean gotDocumentation = false; |
aoqi@0 | 397 | |
aoqi@0 | 398 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 399 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 400 | if (e2 == null) |
aoqi@0 | 401 | break; |
aoqi@0 | 402 | |
aoqi@0 | 403 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 404 | if (gotDocumentation) { |
aoqi@0 | 405 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 406 | } |
aoqi@0 | 407 | gotDocumentation = true; |
aoqi@0 | 408 | if(portType.getDocumentation() == null) |
aoqi@0 | 409 | portType.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 410 | } else if ( |
aoqi@0 | 411 | XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_OPERATION)) { |
aoqi@0 | 412 | Operation op = parsePortTypeOperation(context, e2); |
aoqi@0 | 413 | op.setParent(portType); |
aoqi@0 | 414 | portType.add(op); |
aoqi@0 | 415 | } else { |
aoqi@0 | 416 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 417 | checkNotWsdlElement(e2); |
aoqi@0 | 418 | if (!handleExtension(context, portType, e2)) { |
aoqi@0 | 419 | checkNotWsdlRequired(e2); |
aoqi@0 | 420 | } |
aoqi@0 | 421 | }/*else { |
aoqi@0 | 422 | Util.fail( |
aoqi@0 | 423 | "parsing.invalidElement", |
aoqi@0 | 424 | e2.getTagName(), |
aoqi@0 | 425 | e2.getNamespaceURI()); |
aoqi@0 | 426 | }*/ |
aoqi@0 | 427 | } |
aoqi@0 | 428 | |
aoqi@0 | 429 | context.pop(); |
aoqi@0 | 430 | context.fireDoneParsingEntity(WSDLConstants.QNAME_PORT_TYPE, portType); |
aoqi@0 | 431 | return portType; |
aoqi@0 | 432 | } |
aoqi@0 | 433 | |
aoqi@0 | 434 | private Operation parsePortTypeOperation( |
aoqi@0 | 435 | TWSDLParserContextImpl context, |
aoqi@0 | 436 | Element e) { |
aoqi@0 | 437 | context.push(); |
aoqi@0 | 438 | context.registerNamespaces(e); |
aoqi@0 | 439 | |
aoqi@0 | 440 | Operation operation = new Operation(forest.locatorTable.getStartLocation(e)); |
aoqi@0 | 441 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 442 | operation.setName(name); |
aoqi@0 | 443 | String parameterOrderAttr = |
aoqi@0 | 444 | XmlUtil.getAttributeOrNull(e, Constants.ATTR_PARAMETER_ORDER); |
aoqi@0 | 445 | operation.setParameterOrder(parameterOrderAttr); |
aoqi@0 | 446 | |
aoqi@0 | 447 | boolean gotDocumentation = false; |
aoqi@0 | 448 | |
aoqi@0 | 449 | boolean gotInput = false; |
aoqi@0 | 450 | boolean gotOutput = false; |
aoqi@0 | 451 | boolean gotFault = false; |
aoqi@0 | 452 | boolean inputBeforeOutput = false; |
aoqi@0 | 453 | |
aoqi@0 | 454 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 455 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 456 | if (e2 == null) |
aoqi@0 | 457 | break; |
aoqi@0 | 458 | |
aoqi@0 | 459 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 460 | if (gotDocumentation) { |
aoqi@0 | 461 | errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e2.getLocalName())); |
aoqi@0 | 462 | } |
aoqi@0 | 463 | gotDocumentation = true; |
aoqi@0 | 464 | if(operation.getDocumentation() == null) |
aoqi@0 | 465 | operation.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 466 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_INPUT)) { |
aoqi@0 | 467 | if (gotInput) { |
aoqi@0 | 468 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(Constants.TAG_INPUT, |
aoqi@0 | 469 | Constants.TAG_OPERATION, |
aoqi@0 | 470 | name)); |
aoqi@0 | 471 | } |
aoqi@0 | 472 | |
aoqi@0 | 473 | context.push(); |
aoqi@0 | 474 | context.registerNamespaces(e2); |
aoqi@0 | 475 | Input input = new Input(forest.locatorTable.getStartLocation(e2), errReceiver); |
aoqi@0 | 476 | input.setParent(operation); |
aoqi@0 | 477 | String messageAttr = |
aoqi@0 | 478 | Util.getRequiredAttribute(e2, Constants.ATTR_MESSAGE); |
aoqi@0 | 479 | input.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr)); |
aoqi@0 | 480 | String nameAttr = |
aoqi@0 | 481 | XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME); |
aoqi@0 | 482 | input.setName(nameAttr); |
aoqi@0 | 483 | operation.setInput(input); |
aoqi@0 | 484 | gotInput = true; |
aoqi@0 | 485 | if (gotOutput) { |
aoqi@0 | 486 | inputBeforeOutput = false; |
aoqi@0 | 487 | } |
aoqi@0 | 488 | |
aoqi@0 | 489 | // check for extensiblity attributes |
aoqi@0 | 490 | for (Iterator iter2 = XmlUtil.getAllAttributes(e2); |
aoqi@0 | 491 | iter2.hasNext(); |
aoqi@0 | 492 | ) { |
aoqi@0 | 493 | Attr e3 = (Attr)iter2.next(); |
aoqi@0 | 494 | if (e3.getLocalName().equals(Constants.ATTR_MESSAGE) || |
aoqi@0 | 495 | e3.getLocalName().equals(Constants.ATTR_NAME)) |
aoqi@0 | 496 | continue; |
aoqi@0 | 497 | |
aoqi@0 | 498 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 499 | checkNotWsdlAttribute(e3); |
aoqi@0 | 500 | handleExtension(context, input, e3, e2); |
aoqi@0 | 501 | } |
aoqi@0 | 502 | |
aoqi@0 | 503 | // verify that there is at most one child element and it is a documentation element |
aoqi@0 | 504 | boolean gotDocumentation2 = false; |
aoqi@0 | 505 | for (Iterator iter2 = XmlUtil.getAllChildren(e2); |
aoqi@0 | 506 | iter2.hasNext(); |
aoqi@0 | 507 | ) { |
aoqi@0 | 508 | Element e3 = Util.nextElement(iter2); |
aoqi@0 | 509 | if (e3 == null) |
aoqi@0 | 510 | break; |
aoqi@0 | 511 | |
aoqi@0 | 512 | if (XmlUtil |
aoqi@0 | 513 | .matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 514 | if (gotDocumentation2) { |
aoqi@0 | 515 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 516 | } |
aoqi@0 | 517 | gotDocumentation2 = true; |
aoqi@0 | 518 | input.setDocumentation(getDocumentationFor(e3)); |
aoqi@0 | 519 | } else { |
aoqi@0 | 520 | errReceiver.error(forest.locatorTable.getStartLocation(e3), WsdlMessages.PARSING_INVALID_ELEMENT(e3.getTagName(), |
aoqi@0 | 521 | e3.getNamespaceURI())); |
aoqi@0 | 522 | } |
aoqi@0 | 523 | } |
aoqi@0 | 524 | context.pop(); |
aoqi@0 | 525 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_OUTPUT)) { |
aoqi@0 | 526 | if (gotOutput) { |
aoqi@0 | 527 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(Constants.TAG_INPUT, |
aoqi@0 | 528 | Constants.TAG_OPERATION, |
aoqi@0 | 529 | name)); |
aoqi@0 | 530 | } |
aoqi@0 | 531 | |
aoqi@0 | 532 | context.push(); |
aoqi@0 | 533 | context.registerNamespaces(e2); |
aoqi@0 | 534 | Output output = new Output(forest.locatorTable.getStartLocation(e2), errReceiver); |
aoqi@0 | 535 | output.setParent(operation); |
aoqi@0 | 536 | String messageAttr = |
aoqi@0 | 537 | Util.getRequiredAttribute(e2, Constants.ATTR_MESSAGE); |
aoqi@0 | 538 | output.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr)); |
aoqi@0 | 539 | String nameAttr = |
aoqi@0 | 540 | XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME); |
aoqi@0 | 541 | output.setName(nameAttr); |
aoqi@0 | 542 | operation.setOutput(output); |
aoqi@0 | 543 | gotOutput = true; |
aoqi@0 | 544 | if (gotInput) { |
aoqi@0 | 545 | inputBeforeOutput = true; |
aoqi@0 | 546 | } |
aoqi@0 | 547 | |
aoqi@0 | 548 | // check for extensiblity attributes |
aoqi@0 | 549 | for (Iterator iter2 = XmlUtil.getAllAttributes(e2); |
aoqi@0 | 550 | iter2.hasNext(); |
aoqi@0 | 551 | ) { |
aoqi@0 | 552 | Attr e3 = (Attr)iter2.next(); |
aoqi@0 | 553 | if (e3.getLocalName().equals(Constants.ATTR_MESSAGE) || |
aoqi@0 | 554 | e3.getLocalName().equals(Constants.ATTR_NAME)) |
aoqi@0 | 555 | continue; |
aoqi@0 | 556 | |
aoqi@0 | 557 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 558 | checkNotWsdlAttribute(e3); |
aoqi@0 | 559 | handleExtension(context, output, e3, e2); |
aoqi@0 | 560 | } |
aoqi@0 | 561 | |
aoqi@0 | 562 | // verify that there is at most one child element and it is a documentation element |
aoqi@0 | 563 | boolean gotDocumentation2 = false; |
aoqi@0 | 564 | for (Iterator iter2 = XmlUtil.getAllChildren(e2); |
aoqi@0 | 565 | iter2.hasNext(); |
aoqi@0 | 566 | ) { |
aoqi@0 | 567 | Element e3 = Util.nextElement(iter2); |
aoqi@0 | 568 | if (e3 == null) |
aoqi@0 | 569 | break; |
aoqi@0 | 570 | |
aoqi@0 | 571 | if (XmlUtil |
aoqi@0 | 572 | .matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 573 | if (gotDocumentation2) { |
aoqi@0 | 574 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 575 | } |
aoqi@0 | 576 | gotDocumentation2 = true; |
aoqi@0 | 577 | output.setDocumentation(getDocumentationFor(e3)); |
aoqi@0 | 578 | } else { |
aoqi@0 | 579 | errReceiver.error(forest.locatorTable.getStartLocation(e3), WsdlMessages.PARSING_INVALID_ELEMENT(e3.getTagName(), |
aoqi@0 | 580 | e3.getNamespaceURI())); |
aoqi@0 | 581 | } |
aoqi@0 | 582 | } |
aoqi@0 | 583 | context.pop(); |
aoqi@0 | 584 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_FAULT)) { |
aoqi@0 | 585 | context.push(); |
aoqi@0 | 586 | context.registerNamespaces(e2); |
aoqi@0 | 587 | Fault fault = new Fault(forest.locatorTable.getStartLocation(e2)); |
aoqi@0 | 588 | fault.setParent(operation); |
aoqi@0 | 589 | String messageAttr = |
aoqi@0 | 590 | Util.getRequiredAttribute(e2, Constants.ATTR_MESSAGE); |
aoqi@0 | 591 | fault.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr)); |
aoqi@0 | 592 | String nameAttr = |
aoqi@0 | 593 | XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME); |
aoqi@0 | 594 | fault.setName(nameAttr); |
aoqi@0 | 595 | operation.addFault(fault); |
aoqi@0 | 596 | gotFault = true; |
aoqi@0 | 597 | |
aoqi@0 | 598 | // check for extensiblity attributes |
aoqi@0 | 599 | for (Iterator iter2 = XmlUtil.getAllAttributes(e2); |
aoqi@0 | 600 | iter2.hasNext(); |
aoqi@0 | 601 | ) { |
aoqi@0 | 602 | Attr e3 = (Attr)iter2.next(); |
aoqi@0 | 603 | if (e3.getLocalName().equals(Constants.ATTR_MESSAGE) || |
aoqi@0 | 604 | e3.getLocalName().equals(Constants.ATTR_NAME)) |
aoqi@0 | 605 | continue; |
aoqi@0 | 606 | |
aoqi@0 | 607 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 608 | checkNotWsdlAttribute(e3); |
aoqi@0 | 609 | handleExtension(context, fault, e3, e2); |
aoqi@0 | 610 | } |
aoqi@0 | 611 | |
aoqi@0 | 612 | // verify that there is at most one child element and it is a documentation element |
aoqi@0 | 613 | boolean gotDocumentation2 = false; |
aoqi@0 | 614 | for (Iterator iter2 = XmlUtil.getAllChildren(e2); |
aoqi@0 | 615 | iter2.hasNext(); |
aoqi@0 | 616 | ) { |
aoqi@0 | 617 | Element e3 = Util.nextElement(iter2); |
aoqi@0 | 618 | if (e3 == null) |
aoqi@0 | 619 | break; |
aoqi@0 | 620 | |
aoqi@0 | 621 | if (XmlUtil |
aoqi@0 | 622 | .matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 623 | if (gotDocumentation2) { |
aoqi@0 | 624 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 625 | } |
aoqi@0 | 626 | gotDocumentation2 = true; |
aoqi@0 | 627 | if(fault.getDocumentation() == null) |
aoqi@0 | 628 | fault.setDocumentation(getDocumentationFor(e3)); |
aoqi@0 | 629 | } else { |
aoqi@0 | 630 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 631 | checkNotWsdlElement(e3); |
aoqi@0 | 632 | if (!handleExtension(context, fault, e3)) { |
aoqi@0 | 633 | checkNotWsdlRequired(e3); |
aoqi@0 | 634 | } |
aoqi@0 | 635 | }/*else { |
aoqi@0 | 636 | Util.fail( |
aoqi@0 | 637 | "parsing.invalidElement", |
aoqi@0 | 638 | e3.getTagName(), |
aoqi@0 | 639 | e3.getNamespaceURI()); |
aoqi@0 | 640 | }*/ |
aoqi@0 | 641 | } |
aoqi@0 | 642 | context.pop(); |
aoqi@0 | 643 | } else { |
aoqi@0 | 644 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 645 | checkNotWsdlElement(e2); |
aoqi@0 | 646 | if (!handleExtension(context, operation, e2)) { |
aoqi@0 | 647 | checkNotWsdlRequired(e2); |
aoqi@0 | 648 | } |
aoqi@0 | 649 | }/*else { |
aoqi@0 | 650 | Util.fail( |
aoqi@0 | 651 | "parsing.invalidElement", |
aoqi@0 | 652 | e2.getTagName(), |
aoqi@0 | 653 | e2.getNamespaceURI()); |
aoqi@0 | 654 | }*/ |
aoqi@0 | 655 | } |
aoqi@0 | 656 | |
aoqi@0 | 657 | if (gotInput && !gotOutput && !gotFault) { |
aoqi@0 | 658 | operation.setStyle(OperationStyle.ONE_WAY); |
aoqi@0 | 659 | } else if (gotInput && gotOutput && inputBeforeOutput) { |
aoqi@0 | 660 | operation.setStyle(OperationStyle.REQUEST_RESPONSE); |
aoqi@0 | 661 | } else if (gotInput && gotOutput && !inputBeforeOutput) { |
aoqi@0 | 662 | operation.setStyle(OperationStyle.SOLICIT_RESPONSE); |
aoqi@0 | 663 | } else if (gotOutput && !gotInput && !gotFault) { |
aoqi@0 | 664 | operation.setStyle(OperationStyle.NOTIFICATION); |
aoqi@0 | 665 | } else { |
aoqi@0 | 666 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name)); |
aoqi@0 | 667 | } |
aoqi@0 | 668 | |
aoqi@0 | 669 | context.pop(); |
aoqi@0 | 670 | context.fireDoneParsingEntity(WSDLConstants.QNAME_OPERATION, operation); |
aoqi@0 | 671 | return operation; |
aoqi@0 | 672 | } |
aoqi@0 | 673 | |
aoqi@0 | 674 | private Binding parseBinding( |
aoqi@0 | 675 | TWSDLParserContextImpl context, |
aoqi@0 | 676 | Definitions definitions, |
aoqi@0 | 677 | Element e) { |
aoqi@0 | 678 | context.push(); |
aoqi@0 | 679 | context.registerNamespaces(e); |
aoqi@0 | 680 | Binding binding = new Binding(definitions, forest.locatorTable.getStartLocation(e), errReceiver); |
aoqi@0 | 681 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 682 | binding.setName(name); |
aoqi@0 | 683 | String typeAttr = Util.getRequiredAttribute(e, Constants.ATTR_TYPE); |
aoqi@0 | 684 | binding.setPortType(context.translateQualifiedName(context.getLocation(e), typeAttr)); |
aoqi@0 | 685 | |
aoqi@0 | 686 | boolean gotDocumentation = false; |
aoqi@0 | 687 | |
aoqi@0 | 688 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 689 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 690 | if (e2 == null) |
aoqi@0 | 691 | break; |
aoqi@0 | 692 | |
aoqi@0 | 693 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 694 | if (gotDocumentation) { |
aoqi@0 | 695 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 696 | } |
aoqi@0 | 697 | gotDocumentation = true; |
aoqi@0 | 698 | binding.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 699 | } else if ( |
aoqi@0 | 700 | XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_OPERATION)) { |
aoqi@0 | 701 | BindingOperation op = parseBindingOperation(context, e2); |
aoqi@0 | 702 | binding.add(op); |
aoqi@0 | 703 | } else { |
aoqi@0 | 704 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 705 | checkNotWsdlElement(e2); |
aoqi@0 | 706 | if (!handleExtension(context, binding, e2)) { |
aoqi@0 | 707 | checkNotWsdlRequired(e2); |
aoqi@0 | 708 | } |
aoqi@0 | 709 | } |
aoqi@0 | 710 | } |
aoqi@0 | 711 | |
aoqi@0 | 712 | context.pop(); |
aoqi@0 | 713 | context.fireDoneParsingEntity(WSDLConstants.QNAME_BINDING, binding); |
aoqi@0 | 714 | return binding; |
aoqi@0 | 715 | } |
aoqi@0 | 716 | |
aoqi@0 | 717 | private BindingOperation parseBindingOperation( |
aoqi@0 | 718 | TWSDLParserContextImpl context, |
aoqi@0 | 719 | Element e) { |
aoqi@0 | 720 | context.push(); |
aoqi@0 | 721 | context.registerNamespaces(e); |
aoqi@0 | 722 | BindingOperation operation = new BindingOperation(forest.locatorTable.getStartLocation(e)); |
aoqi@0 | 723 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 724 | operation.setName(name); |
aoqi@0 | 725 | |
aoqi@0 | 726 | boolean gotDocumentation = false; |
aoqi@0 | 727 | |
aoqi@0 | 728 | boolean gotInput = false; |
aoqi@0 | 729 | boolean gotOutput = false; |
aoqi@0 | 730 | boolean gotFault = false; |
aoqi@0 | 731 | boolean inputBeforeOutput = false; |
aoqi@0 | 732 | |
aoqi@0 | 733 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 734 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 735 | if (e2 == null) |
aoqi@0 | 736 | break; |
aoqi@0 | 737 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 738 | if (gotDocumentation) { |
aoqi@0 | 739 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 740 | } |
aoqi@0 | 741 | gotDocumentation = true; |
aoqi@0 | 742 | operation.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 743 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_INPUT)) { |
aoqi@0 | 744 | if (gotInput) { |
aoqi@0 | 745 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(Constants.TAG_INPUT, |
aoqi@0 | 746 | Constants.TAG_OPERATION, |
aoqi@0 | 747 | name)); |
aoqi@0 | 748 | } |
aoqi@0 | 749 | |
aoqi@0 | 750 | /* Here we check for the use scenario */ |
aoqi@0 | 751 | context.push(); |
aoqi@0 | 752 | context.registerNamespaces(e2); |
aoqi@0 | 753 | BindingInput input = new BindingInput(forest.locatorTable.getStartLocation(e2)); |
aoqi@0 | 754 | String nameAttr = |
aoqi@0 | 755 | XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME); |
aoqi@0 | 756 | input.setName(nameAttr); |
aoqi@0 | 757 | operation.setInput(input); |
aoqi@0 | 758 | gotInput = true; |
aoqi@0 | 759 | if (gotOutput) { |
aoqi@0 | 760 | inputBeforeOutput = false; |
aoqi@0 | 761 | } |
aoqi@0 | 762 | |
aoqi@0 | 763 | // verify that there is at most one child element and it is a documentation element |
aoqi@0 | 764 | boolean gotDocumentation2 = false; |
aoqi@0 | 765 | for (Iterator iter2 = XmlUtil.getAllChildren(e2); |
aoqi@0 | 766 | iter2.hasNext(); |
aoqi@0 | 767 | ) { |
aoqi@0 | 768 | Element e3 = Util.nextElement(iter2); |
aoqi@0 | 769 | if (e3 == null) |
aoqi@0 | 770 | break; |
aoqi@0 | 771 | |
aoqi@0 | 772 | if (XmlUtil |
aoqi@0 | 773 | .matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 774 | if (gotDocumentation2) { |
aoqi@0 | 775 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 776 | } |
aoqi@0 | 777 | gotDocumentation2 = true; |
aoqi@0 | 778 | input.setDocumentation(getDocumentationFor(e3)); |
aoqi@0 | 779 | } else { |
aoqi@0 | 780 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 781 | checkNotWsdlElement(e3); |
aoqi@0 | 782 | if (!handleExtension(context, input, e3)) { |
aoqi@0 | 783 | checkNotWsdlRequired(e3); |
aoqi@0 | 784 | } |
aoqi@0 | 785 | } |
aoqi@0 | 786 | } |
aoqi@0 | 787 | context.pop(); |
aoqi@0 | 788 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_OUTPUT)) { |
aoqi@0 | 789 | if (gotOutput) { |
aoqi@0 | 790 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(Constants.TAG_INPUT, |
aoqi@0 | 791 | Constants.TAG_OPERATION, |
aoqi@0 | 792 | name)); |
aoqi@0 | 793 | } |
aoqi@0 | 794 | |
aoqi@0 | 795 | context.push(); |
aoqi@0 | 796 | context.registerNamespaces(e2); |
aoqi@0 | 797 | BindingOutput output = new BindingOutput(forest.locatorTable.getStartLocation(e2)); |
aoqi@0 | 798 | String nameAttr = |
aoqi@0 | 799 | XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME); |
aoqi@0 | 800 | output.setName(nameAttr); |
aoqi@0 | 801 | operation.setOutput(output); |
aoqi@0 | 802 | gotOutput = true; |
aoqi@0 | 803 | if (gotInput) { |
aoqi@0 | 804 | inputBeforeOutput = true; |
aoqi@0 | 805 | } |
aoqi@0 | 806 | |
aoqi@0 | 807 | // verify that there is at most one child element and it is a documentation element |
aoqi@0 | 808 | boolean gotDocumentation2 = false; |
aoqi@0 | 809 | for (Iterator iter2 = XmlUtil.getAllChildren(e2); |
aoqi@0 | 810 | iter2.hasNext(); |
aoqi@0 | 811 | ) { |
aoqi@0 | 812 | |
aoqi@0 | 813 | Element e3 = Util.nextElement(iter2); |
aoqi@0 | 814 | if (e3 == null) |
aoqi@0 | 815 | break; |
aoqi@0 | 816 | |
aoqi@0 | 817 | if (XmlUtil |
aoqi@0 | 818 | .matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 819 | if (gotDocumentation2) { |
aoqi@0 | 820 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 821 | } |
aoqi@0 | 822 | gotDocumentation2 = true; |
aoqi@0 | 823 | output.setDocumentation(getDocumentationFor(e3)); |
aoqi@0 | 824 | } else { |
aoqi@0 | 825 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 826 | checkNotWsdlElement(e3); |
aoqi@0 | 827 | if (!handleExtension(context, output, e3)) { |
aoqi@0 | 828 | checkNotWsdlRequired(e3); |
aoqi@0 | 829 | } |
aoqi@0 | 830 | } |
aoqi@0 | 831 | } |
aoqi@0 | 832 | context.pop(); |
aoqi@0 | 833 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_FAULT)) { |
aoqi@0 | 834 | context.push(); |
aoqi@0 | 835 | context.registerNamespaces(e2); |
aoqi@0 | 836 | BindingFault fault = new BindingFault(forest.locatorTable.getStartLocation(e2)); |
aoqi@0 | 837 | String nameAttr = |
aoqi@0 | 838 | Util.getRequiredAttribute(e2, Constants.ATTR_NAME); |
aoqi@0 | 839 | fault.setName(nameAttr); |
aoqi@0 | 840 | operation.addFault(fault); |
aoqi@0 | 841 | gotFault = true; |
aoqi@0 | 842 | |
aoqi@0 | 843 | // verify that there is at most one child element and it is a documentation element |
aoqi@0 | 844 | boolean gotDocumentation2 = false; |
aoqi@0 | 845 | for (Iterator iter2 = XmlUtil.getAllChildren(e2); |
aoqi@0 | 846 | iter2.hasNext(); |
aoqi@0 | 847 | ) { |
aoqi@0 | 848 | Element e3 = Util.nextElement(iter2); |
aoqi@0 | 849 | if (e3 == null) |
aoqi@0 | 850 | break; |
aoqi@0 | 851 | |
aoqi@0 | 852 | if (XmlUtil |
aoqi@0 | 853 | .matchesTagNS(e3, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 854 | if (gotDocumentation2) { |
aoqi@0 | 855 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 856 | } |
aoqi@0 | 857 | gotDocumentation2 = true; |
aoqi@0 | 858 | if(fault.getDocumentation() == null) |
aoqi@0 | 859 | fault.setDocumentation(getDocumentationFor(e3)); |
aoqi@0 | 860 | } else { |
aoqi@0 | 861 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 862 | checkNotWsdlElement(e3); |
aoqi@0 | 863 | if (!handleExtension(context, fault, e3)) { |
aoqi@0 | 864 | checkNotWsdlRequired(e3); |
aoqi@0 | 865 | } |
aoqi@0 | 866 | } |
aoqi@0 | 867 | } |
aoqi@0 | 868 | context.pop(); |
aoqi@0 | 869 | } else { |
aoqi@0 | 870 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 871 | checkNotWsdlElement(e2); |
aoqi@0 | 872 | if (!handleExtension(context, operation, e2)) { |
aoqi@0 | 873 | checkNotWsdlRequired(e2); |
aoqi@0 | 874 | } |
aoqi@0 | 875 | } |
aoqi@0 | 876 | } |
aoqi@0 | 877 | |
aoqi@0 | 878 | if (gotInput && !gotOutput && !gotFault) { |
aoqi@0 | 879 | operation.setStyle(OperationStyle.ONE_WAY); |
aoqi@0 | 880 | } else if (gotInput && gotOutput && inputBeforeOutput) { |
aoqi@0 | 881 | operation.setStyle(OperationStyle.REQUEST_RESPONSE); |
aoqi@0 | 882 | } else if (gotInput && gotOutput && !inputBeforeOutput) { |
aoqi@0 | 883 | operation.setStyle(OperationStyle.SOLICIT_RESPONSE); |
aoqi@0 | 884 | } else if (gotOutput && !gotInput && !gotFault) { |
aoqi@0 | 885 | operation.setStyle(OperationStyle.NOTIFICATION); |
aoqi@0 | 886 | } else { |
aoqi@0 | 887 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name)); |
aoqi@0 | 888 | } |
aoqi@0 | 889 | |
aoqi@0 | 890 | context.pop(); |
aoqi@0 | 891 | context.fireDoneParsingEntity(WSDLConstants.QNAME_OPERATION, operation); |
aoqi@0 | 892 | return operation; |
aoqi@0 | 893 | } |
aoqi@0 | 894 | |
aoqi@0 | 895 | private Import parseImport( |
aoqi@0 | 896 | TWSDLParserContextImpl context, |
aoqi@0 | 897 | Definitions definitions, |
aoqi@0 | 898 | Element e) { |
aoqi@0 | 899 | context.push(); |
aoqi@0 | 900 | context.registerNamespaces(e); |
aoqi@0 | 901 | Import anImport = new Import(forest.locatorTable.getStartLocation(e)); |
aoqi@0 | 902 | String namespace = |
aoqi@0 | 903 | Util.getRequiredAttribute(e, Constants.ATTR_NAMESPACE); |
aoqi@0 | 904 | anImport.setNamespace(namespace); |
aoqi@0 | 905 | String location = Util.getRequiredAttribute(e, Constants.ATTR_LOCATION); |
aoqi@0 | 906 | anImport.setLocation(location); |
aoqi@0 | 907 | |
aoqi@0 | 908 | // according to the schema in the WSDL 1.1 spec, an import can have a documentation element |
aoqi@0 | 909 | boolean gotDocumentation = false; |
aoqi@0 | 910 | |
aoqi@0 | 911 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 912 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 913 | if (e2 == null) |
aoqi@0 | 914 | break; |
aoqi@0 | 915 | |
aoqi@0 | 916 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 917 | if (gotDocumentation) { |
aoqi@0 | 918 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 919 | } |
aoqi@0 | 920 | gotDocumentation = true; |
aoqi@0 | 921 | anImport.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 922 | } else { |
aoqi@0 | 923 | errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_INVALID_ELEMENT(e2.getTagName(), |
aoqi@0 | 924 | e2.getNamespaceURI())); |
aoqi@0 | 925 | } |
aoqi@0 | 926 | } |
aoqi@0 | 927 | context.pop(); |
aoqi@0 | 928 | context.fireDoneParsingEntity(WSDLConstants.QNAME_IMPORT, anImport); |
aoqi@0 | 929 | return anImport; |
aoqi@0 | 930 | } |
aoqi@0 | 931 | |
aoqi@0 | 932 | private Service parseService( |
aoqi@0 | 933 | TWSDLParserContextImpl context, |
aoqi@0 | 934 | Definitions definitions, |
aoqi@0 | 935 | Element e) { |
aoqi@0 | 936 | context.push(); |
aoqi@0 | 937 | context.registerNamespaces(e); |
aoqi@0 | 938 | Service service = new Service(definitions, forest.locatorTable.getStartLocation(e), errReceiver); |
aoqi@0 | 939 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 940 | service.setName(name); |
aoqi@0 | 941 | |
aoqi@0 | 942 | boolean gotDocumentation = false; |
aoqi@0 | 943 | |
aoqi@0 | 944 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 945 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 946 | if (e2 == null) |
aoqi@0 | 947 | break; |
aoqi@0 | 948 | |
aoqi@0 | 949 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 950 | if (gotDocumentation) { |
aoqi@0 | 951 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 952 | } |
aoqi@0 | 953 | gotDocumentation = true; |
aoqi@0 | 954 | if (service.getDocumentation() == null) { |
aoqi@0 | 955 | service.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 956 | } |
aoqi@0 | 957 | } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT)) { |
aoqi@0 | 958 | Port port = parsePort(context, definitions, e2); |
aoqi@0 | 959 | service.add(port); |
aoqi@0 | 960 | } else { |
aoqi@0 | 961 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 962 | checkNotWsdlElement(e2); |
aoqi@0 | 963 | if (!handleExtension(context, service, e2)) { |
aoqi@0 | 964 | checkNotWsdlRequired(e2); |
aoqi@0 | 965 | } |
aoqi@0 | 966 | } |
aoqi@0 | 967 | } |
aoqi@0 | 968 | |
aoqi@0 | 969 | context.pop(); |
aoqi@0 | 970 | context.fireDoneParsingEntity(WSDLConstants.QNAME_SERVICE, service); |
aoqi@0 | 971 | return service; |
aoqi@0 | 972 | } |
aoqi@0 | 973 | |
aoqi@0 | 974 | private Port parsePort( |
aoqi@0 | 975 | TWSDLParserContextImpl context, |
aoqi@0 | 976 | Definitions definitions, |
aoqi@0 | 977 | Element e) { |
aoqi@0 | 978 | context.push(); |
aoqi@0 | 979 | context.registerNamespaces(e); |
aoqi@0 | 980 | |
aoqi@0 | 981 | Port port = new Port(definitions, forest.locatorTable.getStartLocation(e), errReceiver); |
aoqi@0 | 982 | String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME); |
aoqi@0 | 983 | port.setName(name); |
aoqi@0 | 984 | |
aoqi@0 | 985 | String bindingAttr = |
aoqi@0 | 986 | Util.getRequiredAttribute(e, Constants.ATTR_BINDING); |
aoqi@0 | 987 | port.setBinding(context.translateQualifiedName(context.getLocation(e), bindingAttr)); |
aoqi@0 | 988 | |
aoqi@0 | 989 | boolean gotDocumentation = false; |
aoqi@0 | 990 | |
aoqi@0 | 991 | for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) { |
aoqi@0 | 992 | Element e2 = Util.nextElement(iter); |
aoqi@0 | 993 | if (e2 == null) { |
aoqi@0 | 994 | break; |
aoqi@0 | 995 | } |
aoqi@0 | 996 | |
aoqi@0 | 997 | if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) { |
aoqi@0 | 998 | if (gotDocumentation) { |
aoqi@0 | 999 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName())); |
aoqi@0 | 1000 | } |
aoqi@0 | 1001 | gotDocumentation = true; |
aoqi@0 | 1002 | if (port.getDocumentation() == null) { |
aoqi@0 | 1003 | port.setDocumentation(getDocumentationFor(e2)); |
aoqi@0 | 1004 | } |
aoqi@0 | 1005 | } else { |
aoqi@0 | 1006 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 1007 | checkNotWsdlElement(e2); |
aoqi@0 | 1008 | if (!handleExtension(context, port, e2)) { |
aoqi@0 | 1009 | checkNotWsdlRequired(e2); |
aoqi@0 | 1010 | } |
aoqi@0 | 1011 | } |
aoqi@0 | 1012 | } |
aoqi@0 | 1013 | |
aoqi@0 | 1014 | context.pop(); |
aoqi@0 | 1015 | context.fireDoneParsingEntity(WSDLConstants.QNAME_PORT, port); |
aoqi@0 | 1016 | return port; |
aoqi@0 | 1017 | } |
aoqi@0 | 1018 | |
aoqi@0 | 1019 | private void validateSchemaImports(Element typesElement){ |
aoqi@0 | 1020 | for (Iterator iter = XmlUtil.getAllChildren(typesElement); iter.hasNext();) { |
aoqi@0 | 1021 | Element e = Util.nextElement(iter); |
aoqi@0 | 1022 | if (e == null) { |
aoqi@0 | 1023 | break; |
aoqi@0 | 1024 | } |
aoqi@0 | 1025 | if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_IMPORT)) { |
aoqi@0 | 1026 | errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.WARNING_WSI_R_2003()); |
aoqi@0 | 1027 | }else{ |
aoqi@0 | 1028 | checkNotWsdlElement(e); |
aoqi@0 | 1029 | // if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_SCHEMA)) { |
aoqi@0 | 1030 | // forest.getInlinedSchemaElement().add(e); |
aoqi@0 | 1031 | // } |
aoqi@0 | 1032 | |
aoqi@0 | 1033 | } |
aoqi@0 | 1034 | } |
aoqi@0 | 1035 | } |
aoqi@0 | 1036 | |
aoqi@0 | 1037 | |
aoqi@0 | 1038 | private boolean handleExtension( |
aoqi@0 | 1039 | TWSDLParserContextImpl context, |
aoqi@0 | 1040 | TWSDLExtensible entity, |
aoqi@0 | 1041 | Element e) { |
aoqi@0 | 1042 | TWSDLExtensionHandler h = |
aoqi@0 | 1043 | (TWSDLExtensionHandler) extensionHandlers.get(e.getNamespaceURI()); |
aoqi@0 | 1044 | if (h == null) { |
aoqi@0 | 1045 | context.fireIgnoringExtension(e, (Entity) entity); |
aoqi@0 | 1046 | errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_UNKNOWN_EXTENSIBILITY_ELEMENT_OR_ATTRIBUTE(e.getLocalName(), e.getNamespaceURI())); |
aoqi@0 | 1047 | return false; |
aoqi@0 | 1048 | } else { |
aoqi@0 | 1049 | return h.doHandleExtension(context, entity, e); |
aoqi@0 | 1050 | } |
aoqi@0 | 1051 | } |
aoqi@0 | 1052 | |
aoqi@0 | 1053 | private boolean handleExtension( |
aoqi@0 | 1054 | TWSDLParserContextImpl context, |
aoqi@0 | 1055 | TWSDLExtensible entity, |
aoqi@0 | 1056 | Node n, |
aoqi@0 | 1057 | Element e) { |
aoqi@0 | 1058 | TWSDLExtensionHandler h = |
aoqi@0 | 1059 | (TWSDLExtensionHandler) extensionHandlers.get(n.getNamespaceURI()); |
aoqi@0 | 1060 | if (h == null) { |
aoqi@0 | 1061 | context.fireIgnoringExtension(e, (Entity) entity); |
aoqi@0 | 1062 | errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_UNKNOWN_EXTENSIBILITY_ELEMENT_OR_ATTRIBUTE(n.getLocalName(), n.getNamespaceURI())); |
aoqi@0 | 1063 | return false; |
aoqi@0 | 1064 | } else { |
aoqi@0 | 1065 | return h.doHandleExtension(context, entity, e); |
aoqi@0 | 1066 | } |
aoqi@0 | 1067 | } |
aoqi@0 | 1068 | |
aoqi@0 | 1069 | private void checkNotWsdlElement(Element e) { |
aoqi@0 | 1070 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 1071 | if (e.getNamespaceURI() != null && e.getNamespaceURI().equals(Constants.NS_WSDL)) { |
aoqi@0 | 1072 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_INVALID_WSDL_ELEMENT(e.getTagName())); |
aoqi@0 | 1073 | } |
aoqi@0 | 1074 | } |
aoqi@0 | 1075 | |
aoqi@0 | 1076 | private void checkNotWsdlAttribute(Attr a) { |
aoqi@0 | 1077 | // possible extensibility element -- must live outside the WSDL namespace |
aoqi@0 | 1078 | if (Constants.NS_WSDL.equals(a.getNamespaceURI())) { |
aoqi@0 | 1079 | errReceiver.error(forest.locatorTable.getStartLocation(a.getOwnerElement()), WsdlMessages.PARSING_INVALID_WSDL_ELEMENT(a.getLocalName())); |
aoqi@0 | 1080 | } |
aoqi@0 | 1081 | } |
aoqi@0 | 1082 | |
aoqi@0 | 1083 | private void checkNotWsdlRequired(Element e) { |
aoqi@0 | 1084 | // check the wsdl:required attribute, fail if set to "true" |
aoqi@0 | 1085 | String required = |
aoqi@0 | 1086 | XmlUtil.getAttributeNSOrNull( |
aoqi@0 | 1087 | e, |
aoqi@0 | 1088 | Constants.ATTR_REQUIRED, |
aoqi@0 | 1089 | Constants.NS_WSDL); |
aoqi@0 | 1090 | if (required != null && required.equals(Constants.TRUE) && !options.isExtensionMode()) { |
aoqi@0 | 1091 | errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_REQUIRED_EXTENSIBILITY_ELEMENT(e.getTagName(), |
aoqi@0 | 1092 | e.getNamespaceURI())); |
aoqi@0 | 1093 | } |
aoqi@0 | 1094 | } |
aoqi@0 | 1095 | |
aoqi@0 | 1096 | private Documentation getDocumentationFor(Element e) { |
aoqi@0 | 1097 | String s = XmlUtil.getTextForNode(e); |
aoqi@0 | 1098 | if (s == null) { |
aoqi@0 | 1099 | return null; |
aoqi@0 | 1100 | } else { |
aoqi@0 | 1101 | return new Documentation(s); |
aoqi@0 | 1102 | } |
aoqi@0 | 1103 | } |
aoqi@0 | 1104 | } |