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