You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2008/01/07 18:36:43 UTC
svn commit: r609714 [2/8] - in /webservices/woden/branches/woden65: ./
ant-test/ src/org/apache/woden/ src/org/apache/woden/ant/
src/org/apache/woden/internal/ src/org/apache/woden/internal/resolver/
src/org/apache/woden/internal/util/dom/ src/org/apac...
Modified: webservices/woden/branches/woden65/src/org/apache/woden/ant/ValidateWSDL20.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/ant/ValidateWSDL20.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/ant/ValidateWSDL20.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/ant/ValidateWSDL20.java Mon Jan 7 09:36:13 2008
@@ -101,6 +101,8 @@
// base URI for the catalog
private String baseURI;
+ // implementation name.
+ private String implName;
// default extension for Component Model interchange format output
private static final String CMEXT_DEFAULT = ".wsdlcm";
@@ -231,6 +233,17 @@
this.report = report;
}
+
+ /**
+ * Sets the implementation name to test against.
+ *
+ * @param implName The name of the implementation.
+ */
+ public void setImplName(String implName) {
+ this.implName = implName;
+ }
+
+
public void execute() throws BuildException {
// check the cm input attributes and set defaults if necessary
@@ -263,11 +276,18 @@
WSDLReader reader = null;
- // create a reader
+ // create a reader (with specified implementation if given).
try {
-
- WSDLFactory factory = WSDLFactory.newInstance();
- reader = factory.newWSDLReader();
+ //If an implementation name is given use that to test against, else use the default one.
+ if (implName != null && !implName.equals("")) {
+ System.out.println("Using woden with implementation from " + implName);
+ WSDLFactory factory = WSDLFactory.newInstance(implName);
+ reader = factory.newWSDLReader();
+ } else {
+ System.out.println("Using default woden implementation.");
+ WSDLFactory factory = WSDLFactory.newInstance();
+ reader = factory.newWSDLReader();
+ }
} catch (WSDLException e) {
@@ -302,6 +322,8 @@
String[] files = directoryScanner.getIncludedFiles();
reportWriter = Report.openReport(report);
+ reader.getErrorReporter().setErrorHandler(reportWriter);
+
// use the same reader for all the WSDL files
for (int i = 0; i < files.length; i++) {
@@ -312,11 +334,9 @@
System.out.println("validating " + wsdlLoc);
reportWriter.beginWsdl(wsdlLoc);
-
try {
// <-- the Description component
- Description descComp = reader
- .readWSDL(wsdlLoc, reportWriter);
+ Description descComp = reader.readWSDL(wsdlLoc);
if (isCm()) {
// write the Component Model interchange format output file
@@ -329,7 +349,7 @@
}
} catch (Exception e) {
-
+ //The test may still pass if there is an exception here.
if (isFailOnError()) {
reportWriter.endWsdl();
Modified: webservices/woden/branches/woden65/src/org/apache/woden/ant/WsdlCm.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/ant/WsdlCm.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/ant/WsdlCm.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/ant/WsdlCm.java Mon Jan 7 09:36:13 2008
@@ -117,9 +117,12 @@
// <-- enable WSDL 2.0 validation (optional)
reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
-
+
+ //Add errorHandler
+ reader.getErrorReporter().setErrorHandler(reportWriter);
+
// <-- the Description component
- Description descComp = reader.readWSDL(wsdlLoc, reportWriter);
+ Description descComp = reader.readWSDL(wsdlLoc);
File xml = new File(wsdlCmLoc);
FileOutputStream fos = new FileOutputStream(xml);
Added: webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLFactory.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLFactory.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLFactory.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLFactory.java Mon Jan 7 09:36:13 2008
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.extensions.PopulatedExtensionRegistry;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+
+/**
+ * This abstract class contains properties and methods common
+ * to WSDLFactory implementations.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public abstract class BaseWSDLFactory extends WSDLFactory {
+
+ protected WSDLContext fWsdlContext;
+
+ protected BaseWSDLFactory() throws WSDLException {
+ ErrorReporter errRpt = new ErrorReporterImpl();
+ ExtensionRegistry extReg = new PopulatedExtensionRegistry(errRpt);
+ ((ErrorReporterImpl)errRpt).setExtensionRegistry(extReg);
+ fWsdlContext = new WSDLContext(this, errRpt, extReg);
+ }
+
+ abstract public WSDLReader newWSDLReader() throws WSDLException;
+
+ public ExtensionRegistry newPopulatedExtensionRegistry() throws WSDLException {
+ return new PopulatedExtensionRegistry(fWsdlContext.errorReporter);
+ }
+
+ //TODO change the name of this API method to newDescriptionElement()
+ public DescriptionElement newDescription() {
+ return new DescriptionImpl(fWsdlContext);
+ }
+
+ /*
+ * Package private method used by the Woden implementation to create a description
+ * element object with a wsdl context different to the default context provided
+ * provided by this wsdl factory. For example, a wsdl reader or writer may pass
+ * its own context object to this method.
+ */
+ DescriptionElement newDescriptionElement(WSDLContext wsdlContext) {
+ return new DescriptionImpl(wsdlContext);
+ }
+
+}
Propchange: webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLReader.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLReader.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLReader.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLReader.java Mon Jan 7 09:36:13 2008
@@ -39,6 +39,7 @@
import org.apache.woden.resolver.URIResolver;
import org.apache.woden.schema.Schema;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.enumeration.Direction;
import org.apache.woden.wsdl20.enumeration.MessageLabel;
import org.apache.woden.wsdl20.extensions.ExtensionDeserializer;
@@ -75,7 +76,7 @@
* this class is currently WSDL version-independent and XML parser-independent;
* should try to keep it that way.
*
- * @author jkaputin@apache.org
+ * @author John Kaputin (jkaputin@apache.org)
*/
public abstract class BaseWSDLReader implements WSDLReader {
@@ -84,10 +85,10 @@
private String fFactoryImplName = null; //TODO deprecate/remove?
private URIResolver fResolver = null;
- final protected WSDLContext fWsdlContext;
+ protected WSDLContext fWsdlContext;
final protected ReaderFeatures features;
- BaseWSDLReader(WSDLContext wsdlContext) throws WSDLException {
+ protected BaseWSDLReader(WSDLContext wsdlContext) throws WSDLException {
fWsdlContext = wsdlContext;
//TODO decide what to do with fact impl name...re- only known use case is to change newDescription factory method
fFactoryImplName = fWsdlContext.wsdlFactory.getClass().getName();
@@ -157,18 +158,8 @@
*
* @return Returns a.
*/
- protected WSDLFactory getFactory() throws WSDLException
- {
+ protected WSDLFactory getFactory() throws WSDLException {
return fWsdlContext.wsdlFactory;
- /*
- if(fFactory == null)
- {
- fFactory = (fFactoryImplName != null)
- ? WSDLFactory.newInstance(fFactoryImplName)
- : WSDLFactory.newInstance();
- }
- return fFactory;
- */
}
/**
@@ -202,12 +193,14 @@
throw new NullPointerException(msg);
}
- fWsdlContext.setExtensionRegistry(extReg);
+ fWsdlContext = new WSDLContext(
+ fWsdlContext.wsdlFactory,
+ fWsdlContext.errorReporter,
+ extReg);
}
- public ExtensionRegistry getExtensionRegistry()
- {
- return fWsdlContext.getExtensionRegistry();
+ public ExtensionRegistry getExtensionRegistry() {
+ return fWsdlContext.extensionRegistry;
}
/**
@@ -372,7 +365,9 @@
ErrorReporter.SEVERITY_FATAL_ERROR);
}
- DescriptionElement desc = getFactory().newDescription();
+ //Get a new description in the context of this reader
+ DescriptionElement desc =
+ ((BaseWSDLFactory)getFactory()).newDescriptionElement(fWsdlContext);
if(wsdlModules == null)
{
@@ -381,18 +376,6 @@
wsdlModules = new HashMap();
}
- /*JKctx
- if(getExtensionRegistry() != null)
- {
- desc.setExtensionRegistry(getExtensionRegistry());
- }
-
- if(getErrorReporter() != null)
- {
- (desc.getExtensionRegistry()).setErrorReporter(getErrorReporter());
- }
- */
-
desc.setDocumentBaseURI(getURI(documentBaseURI));
String targetNamespace =
@@ -713,15 +696,24 @@
String element = faultEl.getAttributeValue(Constants.ATTR_ELEMENT);
if(element != null)
{
- try {
- QName qname = faultEl.getQName(element);
- fault.setElementName(qname);
- } catch (WSDLException e) {
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL505",
- new Object[] {element, faultEl.getQName()},
- ErrorReporter.SEVERITY_ERROR);
+ if(element.equals(Constants.NMTOKEN_ANY)) {
+ fault.setElement(QNameTokenUnion.ANY);
+ } else if(element.equals(Constants.NMTOKEN_NONE)) {
+ fault.setElement(QNameTokenUnion.NONE);
+ } else if(element.equals(Constants.NMTOKEN_OTHER)) {
+ fault.setElement(QNameTokenUnion.OTHER);
+ } else {
+ //It is not one of the allowed xs:Token values, so it must be an xs:QName
+ try {
+ QName qname = faultEl.getQName(element);
+ fault.setElement(new QNameTokenUnion(qname));
+ } catch (WSDLException e) {
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL505",
+ new Object[] {element, faultEl.getQName()},
+ ErrorReporter.SEVERITY_ERROR);
+ }
}
}
@@ -972,19 +964,17 @@
String element = msgRefEl.getAttributeValue(Constants.ATTR_ELEMENT);
if(element != null)
{
- if(element.equals(Constants.NMTOKEN_ANY) ||
- element.equals(Constants.NMTOKEN_NONE) ||
- element.equals(Constants.NMTOKEN_OTHER))
- {
- message.setMessageContentModel(element);
- }
- else
- {
- //element is not #any, #none or #other, so it must be an element qname
- message.setMessageContentModel(Constants.NMTOKEN_ELEMENT);
+ if(element.equals(Constants.NMTOKEN_ANY)) {
+ message.setElement(QNameTokenUnion.ANY);
+ } else if(element.equals(Constants.NMTOKEN_NONE)) {
+ message.setElement(QNameTokenUnion.NONE);
+ } else if(element.equals(Constants.NMTOKEN_OTHER)) {
+ message.setElement(QNameTokenUnion.OTHER);
+ } else {
+ //It is not one of the allowed xs:Token values, so it must be an xs:QName
try {
- QName qname = msgRefEl.getQName(element);
- message.setElementName(qname);
+ QNameTokenUnion qname = new QNameTokenUnion(msgRefEl.getQName(element));
+ message.setElement(qname);
} catch (WSDLException e) {
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
@@ -994,12 +984,6 @@
}
}
}
- else
- {
- //Per mapping defined in WSDL 2.0 Part 2 spec section 2.5.3,
- //if element attribute not present, message content model is #other
- message.setMessageContentModel(Constants.NMTOKEN_OTHER);
- }
parseExtensionAttributes(msgRefEl, InterfaceMessageReferenceElement.class, message, desc);
@@ -1549,7 +1533,7 @@
try
{
- if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL20))
+ if (namespaceURI == null || namespaceURI.equals(Constants.NS_STRING_WSDL20))
{
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
@@ -1559,19 +1543,7 @@
return null;
}
- ExtensionRegistry extReg = fWsdlContext.getExtensionRegistry();
-
- /*JKctx
- if (extReg == null)
- {
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL014",
- new Object[] {elementType, parentType.getName()},
- ErrorReporter.SEVERITY_ERROR);
- return null;
- }
- */
+ ExtensionRegistry extReg = fWsdlContext.extensionRegistry;
ExtensionDeserializer extDS = extReg.queryDeserializer(parentType, elementType);
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java Mon Jan 7 09:36:13 2008
@@ -53,7 +53,7 @@
private String fFactoryImplName = null; //TODO deprecate/remove?
- final protected WSDLContext fWsdlContext;
+ protected WSDLContext fWsdlContext;
final protected WriterFeatures features;
public BaseWSDLWriter(WSDLContext wsdlContext){
@@ -115,12 +115,15 @@
throw new NullPointerException(msg);
}
- fWsdlContext.setExtensionRegistry(extReg);
+ fWsdlContext = new WSDLContext(
+ fWsdlContext.wsdlFactory,
+ fWsdlContext.errorReporter,
+ extReg);
}
public ExtensionRegistry getExtensionRegistry()
{
- return fWsdlContext.getExtensionRegistry();
+ return fWsdlContext.extensionRegistry;
}
public void setFeature(String name, boolean value)
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLFactory.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLFactory.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLFactory.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLFactory.java Mon Jan 7 09:36:13 2008
@@ -17,26 +17,17 @@
package org.apache.woden.internal;
import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
import org.apache.woden.WSDLReader;
import org.apache.woden.WSDLWriter;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.extensions.PopulatedExtensionRegistry;
-import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
-import org.apache.woden.wsdl20.xml.DescriptionElement;
/**
* @author John Kaputin (jkaputin@apache.org)
*/
-public class DOMWSDLFactory extends WSDLFactory {
-
- private WSDLContext fWsdlContext;
+public class DOMWSDLFactory extends BaseWSDLFactory {
public DOMWSDLFactory() throws WSDLException {
- fWsdlContext = new WSDLContext(this, new ErrorReporterImpl());
- ExtensionRegistry extReg = newPopulatedExtensionRegistry();
- fWsdlContext.setExtensionRegistry(extReg);
+ super();
}
public WSDLReader newWSDLReader() throws WSDLException {
@@ -48,13 +39,4 @@
return new DOMWSDLWriter(fWsdlContext);
}
- public DescriptionElement newDescription() {
- return new DescriptionImpl(fWsdlContext);
- }
-
- public ExtensionRegistry newPopulatedExtensionRegistry()
- {
- return new PopulatedExtensionRegistry(fWsdlContext);
- }
-
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLReader.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLReader.java Mon Jan 7 09:36:13 2008
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Hashtable;
import java.util.Map;
@@ -42,6 +43,7 @@
import org.apache.woden.internal.wsdl20.Constants;
import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidator;
import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidator;
+import org.apache.woden.internal.xpointer.DOMXMLElementEvaluator;
import org.apache.woden.schema.Schema;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
@@ -51,6 +53,8 @@
import org.apache.woden.wsdl20.xml.TypesElement;
import org.apache.woden.wsdl20.xml.WSDLElement;
import org.apache.woden.xml.XMLAttr;
+import org.apache.woden.xpointer.InvalidXPointerException;
+import org.apache.woden.xpointer.XPointer;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaException;
@@ -121,18 +125,7 @@
InputSource inputSource = new InputSource(resolveURI(wsdlURL));
return readWSDL(wsdlURL, inputSource);
}
-
- /* (non-Javadoc)
- * @see org.apache.woden.WSDLReader#readWSDL(java.lang.String, org.apache.woden.ErrorHandler)
- */
- public Description readWSDL(String wsdlURI, ErrorHandler errorHandler) throws WSDLException
- {
- if(errorHandler != null)
- getErrorReporter().setErrorHandler(errorHandler);
-
- return readWSDL(wsdlURI);
- }
-
+
/* (non-Javadoc)
* @see org.apache.woden.WSDLReader#readWSDL(org.apache.woden.WSDLSource)
*/
@@ -181,18 +174,6 @@
}
}
- /* (non-Javadoc)
- * @see org.apache.woden.WSDLReader#readWSDL(org.apache.woden.WSDLSource, org.apache.woden.ErrorHandler)
- */
- public Description readWSDL(WSDLSource wsdlSource, ErrorHandler errorHandler)
- throws WSDLException {
-
- if(errorHandler != null)
- getErrorReporter().setErrorHandler(errorHandler);
-
- return readWSDL(wsdlSource);
- }
-
/*
* Helper method for readWSDL(WSDLSource)
*/
@@ -228,27 +209,63 @@
/*
* Helper method for readWSDL(WSDLSource)
*/
- private Description readWSDL(String wsdlURL, Document domDoc)
+ private Description readWSDL(String wsdlURI, Document domDoc)
throws WSDLException {
- return readWSDL(wsdlURL, domDoc.getDocumentElement());
+ //Try to find an element the XPointer points to if a Fragment Identifier exists.
+ URI uri = null;
+ try {
+ uri = new URI(wsdlURI);
+ } catch (URISyntaxException e) {
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL506", new Object[] {null, wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ }
+
+ String fragment = uri.getFragment();
+
+
+ if (fragment == null) { //No fragment identifier so just use the root element.
+ return readWSDL(wsdlURI, domDoc.getDocumentElement());//Use document root if no WSDL20 root found.
+ } else {
+ XPointer xpointer;
+ try {
+ xpointer = new XPointer(fragment);
+ } catch(InvalidXPointerException e) {
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL530", new Object[] {fragment, wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ }
+ Element root = domDoc.getDocumentElement();
+
+ DOMXMLElementEvaluator evaluator = new DOMXMLElementEvaluator(xpointer, root, getErrorReporter());
+ Element result = evaluator.evaluateElement();
+
+ if (result != null) { //Element from XPointer evaluation.
+ return readWSDL(wsdlURI, result);
+ } else {
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL531", new Object[] {fragment, wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg);
+ }
+ }
}
/*
* Helper method for readWSDL(WSDLSource)
*/
- private Description readWSDL(String wsdlURL, InputSource inputSource)
+ private Description readWSDL(String wsdlURI, InputSource inputSource)
throws WSDLException {
try
{
- Document wsdlDocument = getDocument(inputSource, wsdlURL);
+ Document wsdlDocument = getDocument(inputSource, wsdlURI);
- return readWSDL(wsdlURL, wsdlDocument);
+ return readWSDL(wsdlURI, wsdlDocument);
} catch (IOException e) {
String msg = getErrorReporter().getFormattedMessage(
- "WSDL503", new Object[] {wsdlURL});
+ "WSDL503", new Object[] {wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
}
@@ -441,15 +458,15 @@
QName attrType = new QName(namespaceURI, localName, (prefix != null ? prefix : ""));
String attrValue = domAttr.getValue();
- if (namespaceURI != null && !namespaceURI.equals(Constants.NS_URI_WSDL20))
+ if (namespaceURI != null && !namespaceURI.equals(Constants.NS_STRING_WSDL20))
{
- if (!namespaceURI.equals(Constants.NS_URI_XMLNS) &&
- !namespaceURI.equals(Constants.NS_URI_XSI)) //TODO handle xsi attrs elsewhere, without need to register
+ if (!namespaceURI.equals(Constants.NS_STRING_XMLNS) &&
+ !namespaceURI.equals(Constants.NS_STRING_XSI)) //TODO handle xsi attrs elsewhere, without need to register
{
//TODO reg namespaces at appropriate element scope, not just at desc.
//DOMUtils.registerUniquePrefix(prefix, namespaceURI, desc);
- ExtensionRegistry extReg = fWsdlContext.getExtensionRegistry();
+ ExtensionRegistry extReg = fWsdlContext.extensionRegistry;
XMLAttr xmlAttr = extReg.createExtAttribute(wsdlClass, attrType, extEl, attrValue);
if(xmlAttr != null) //TODO use an 'UnknownAttr' class in place of null
{
@@ -490,10 +507,7 @@
throws WSDLException {
Element elem = (Element)xmlElem.getSource();
-
- //TODO remove this cast when support for NS decls is expanded from DescriptionElement to all WSDLElements
- DescriptionElement desc = (DescriptionElement)wsdlElem;
-
+
NamedNodeMap attrs = elem.getAttributes();
int size = attrs.getLength();
@@ -504,15 +518,15 @@
String localPart = attr.getLocalName();
String value = attr.getValue();
- if ((Constants.NS_URI_XMLNS).equals(namespaceURI))
+ if ((Constants.NS_STRING_XMLNS).equals(namespaceURI))
{
if (!(Constants.ATTR_XMLNS).equals(localPart))
{
- desc.addNamespace(localPart, getURI(value)); //a prefixed namespace
+ wsdlElem.addNamespace(localPart, getURI(value)); //a prefixed namespace
}
else
{
- desc.addNamespace(null, getURI(value)); //the default namespace
+ wsdlElem.addNamespace(null, getURI(value)); //the default namespace
}
}
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java Mon Jan 7 09:36:13 2008
@@ -21,28 +21,39 @@
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
import java.net.URI;
-import java.net.URISyntaxException;
import javax.xml.namespace.QName;
-import org.apache.woden.wsdl20.*;
-import org.apache.woden.wsdl20.xml.*;
-import org.apache.woden.xml.XMLAttr;
-import org.apache.woden.wsdl20.extensions.*;
+
import org.apache.woden.WSDLException;
+import org.apache.woden.internal.util.dom.DOM2Writer;
+import org.apache.woden.internal.util.dom.DOMUtils;
+import org.apache.woden.internal.wsdl20.Constants;
import org.apache.woden.schema.ImportedSchema;
import org.apache.woden.schema.InlinedSchema;
-import org.apache.woden.internal.wsdl20.Constants;
-import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.woden.types.NamespaceDeclaration;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.enumeration.Direction;
-import org.apache.woden.internal.util.dom.DOM2Writer;
-import org.apache.woden.internal.util.dom.DOMUtils;
+import org.apache.woden.wsdl20.extensions.ExtensionElement;
import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
-import org.apache.woden.wsdl20.extensions.*;
+import org.apache.woden.wsdl20.extensions.ExtensionSerializer;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.DocumentationElement;
+import org.apache.woden.wsdl20.xml.EndpointElement;
+import org.apache.woden.wsdl20.xml.ImportElement;
+import org.apache.woden.wsdl20.xml.IncludeElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+import org.apache.woden.wsdl20.xml.ServiceElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.woden.wsdl20.xml.WSDLElement;
+import org.apache.woden.xml.XMLAttr;
+import org.apache.ws.commons.schema.XmlSchema;
/**
* This is a concrete class derived from BaseWSDLWriter
@@ -127,23 +138,19 @@
if (desEle == null){
return;
}
- if (DOMUtils.getPrefix(Constants.NS_URI_WSDL20,desEle) == null){
+ if (desEle.getNamespacePrefix(Constants.NS_URI_WSDL20) == null){
String prefix = "wsdl";
int subscript = 0;
- while (desEle.getNamespace(prefix) != null){
+ while (desEle.getNamespaceURI(prefix) != null){
prefix = "wsdl" + subscript++;
}
- try{
- desEle.addNamespace(prefix, new URI(Constants.NS_URI_WSDL20));
- }catch(URISyntaxException exp){
- // TODO
- }
+ desEle.addNamespace(prefix, Constants.NS_URI_WSDL20);
}
String tagName =DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
Constants.ELEM_DESCRIPTION, desEle);
pw.print('<' + tagName);
String targetNamespace = desEle.getTargetNamespace().toString();
- Map namespaces = desEle.getNamespaces();
+ NamespaceDeclaration[] namespaces = desEle.getDeclaredNamespaces();
DOMUtils.printAttribute(Constants.ATTR_TARGET_NAMESPACE,
targetNamespace,
pw);
@@ -170,20 +177,19 @@
* @param namespaces a java.util.Map contains namespace of WSDL Description.
* @param pw the Writer to write the xml to.
*/
- protected void printNamespaceDeclarations(Map namespaces, PrintWriter pw)
+ protected void printNamespaceDeclarations(NamespaceDeclaration[] namespaces, PrintWriter pw)
throws WSDLException {
if (namespaces != null){
- Set keys = namespaces.keySet();
- Iterator keyIterator = keys.iterator();
- while (keyIterator.hasNext()){
- String prefix = (String)keyIterator.next();
+ int len = namespaces.length;
+ for(int i=0; i<len; i++){
+ String prefix = namespaces[i].getPrefix();
if (prefix == null){
prefix = "";
}
DOMUtils.printAttribute(Constants.ATTR_XMLNS +
(!prefix.equals("") ? ":" + prefix : ""),
- (String)namespaces.get(prefix).toString(),
+ namespaces[i].getNamespaceURI().toString(),
pw);
}
}
@@ -225,7 +231,7 @@
location,
pw);
}
- printExtensibilityAttributes(importEle.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(importEle.getExtensionAttributes(), importEle, pw);
pw.println('>');
printDocumentations(importEle.getDocumentationElements(), des, pw);
printExtensibilityElements(importEle.getClass(), importEle.getExtensionElements(), des, pw);
@@ -264,7 +270,7 @@
location,
pw);
}
- printExtensibilityAttributes(includeEle.getExtensionAttributes(),des, pw);
+ printExtensibilityAttributes(includeEle.getExtensionAttributes(),includeEle, pw);
pw.println('>');
printDocumentations(includeEle.getDocumentationElements(), des, pw);
printExtensibilityElements(includeEle.getClass(), includeEle.getExtensionElements(), des, pw);
@@ -331,7 +337,7 @@
}
- printExtensibilityAttributes(intrface.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(intrface.getExtensionAttributes(), intrface, pw);
pw.println('>');
printDocumentations(intrface.getDocumentationElements(), des, pw);
printOperations(intrface.getInterfaceOperationElements(), des, pw);
@@ -394,7 +400,7 @@
- printExtensibilityAttributes(operation.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(operation.getExtensionAttributes(), operation, pw);
pw.println('>');
printDocumentations(operation.getDocumentationElements(), des, pw);
printInterfaceMessageReferenceElement(operation.getInterfaceMessageReferenceElements(),des, pw);
@@ -435,29 +441,38 @@
if(msgDirection==Direction.IN){
tagName=DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
Constants.ELEM_INPUT,
- des);
+ msgRef);
}else if(msgDirection==Direction.OUT){
tagName=DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
Constants.ELEM_OUTPUT,
- des); }
+ msgRef); }
pw.print(" <" + tagName);
String msglable=msgRef.getMessageLabel().toString();
DOMUtils.printAttribute(Constants.ATTR_MESSAGE_LABEL, msglable, pw);
- QName element=msgRef.getElementName();
- URI ns=des.getNamespace(element.getPrefix());
- String attrName;
- if(ns!=null){
- attrName=
- DOMUtils.getQualifiedValue(des.getNamespace(element.getPrefix()).toString(),
- element.getLocalPart(), des);
- }else{
- attrName=element.getLocalPart();
+ QNameTokenUnion qtu = msgRef.getElement();
+ if(qtu != null) {
+ if(qtu.isQName()) {
+ QName element=qtu.getQName();
+ URI ns=msgRef.getNamespaceURI(element.getPrefix());
+ String attrName;
+ if(ns!=null){
+ attrName=
+ DOMUtils.getQualifiedValue(msgRef.getNamespaceURI(element.getPrefix()).toString(),
+ element.getLocalPart(), msgRef);
+ }else{
+ attrName=element.getLocalPart();
+ }
+ DOMUtils.printAttribute(Constants.ATTR_ELEMENT, attrName, pw);
+ } else {
+ //qtu is a Token
+ DOMUtils.printAttribute(Constants.ATTR_ELEMENT, qtu.getToken(), pw);
+ }
}
- DOMUtils.printAttribute(Constants.ATTR_ELEMENT, attrName, pw);
- printExtensibilityAttributes(msgRef.getExtensionAttributes(), des, pw);
+
+ printExtensibilityAttributes(msgRef.getExtensionAttributes(), msgRef, pw);
pw.println('>');
printDocumentations(msgRef.getDocumentationElements(), des, pw);
printExtensibilityElements(msgRef.getClass(), msgRef.getExtensionElements(), des, pw);
@@ -487,12 +502,12 @@
if(msgDirection==Direction.IN){
tagName=DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
Constants.ELEM_INFAULT,
- des);
+ faulRef);
}else if(msgDirection==Direction.OUT){
tagName=DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
Constants.ELEM_OUTFAULT,
- des);
+ faulRef);
}
@@ -505,13 +520,13 @@
QName attrQName=faulRef.getRef();
String attrName=
- DOMUtils.getQualifiedValue(des.getNamespace(attrQName.getPrefix()).toString(),
+ DOMUtils.getQualifiedValue(faulRef.getNamespaceURI(attrQName.getPrefix()).toString(),
attrQName.getLocalPart(),
- des);
+ faulRef);
DOMUtils.printAttribute(Constants.ATTR_ELEMENT, attrName, pw);
- printExtensibilityAttributes(faulRef.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(faulRef.getExtensionAttributes(), faulRef, pw);
pw.println('>');
printDocumentations(faulRef.getDocumentationElements(), des, pw);
printExtensibilityElements(faulRef.getClass(), faulRef.getExtensionElements(), des, pw);
@@ -575,7 +590,7 @@
- printExtensibilityAttributes(binding.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(binding.getExtensionAttributes(), binding, pw);
pw.println('>');
printBindingOperationElements(
binding.getBindingOperationElements(),des,pw);
@@ -620,7 +635,7 @@
des,
pw);
- printExtensibilityAttributes(fault.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(fault.getExtensionAttributes(), fault, pw);
pw.println("/>");
}
@@ -661,7 +676,7 @@
des,
pw);
- printExtensibilityAttributes(operation.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(operation.getExtensionAttributes(), operation, pw);
pw.println("/>");
}
@@ -708,7 +723,7 @@
}
- printExtensibilityAttributes(service.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(service.getExtensionAttributes(), service, pw);
pw.println('>');
printEndpoint(service.getEndpointElements(), des, pw);
printDocumentations(service.getDocumentationElements(), des, pw);
@@ -760,7 +775,7 @@
}
- printExtensibilityAttributes(endPoint.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(endPoint.getExtensionAttributes(), endPoint, pw);
pw.println('>');
printDocumentations(endPoint.getDocumentationElements(), des, pw);
printExtensibilityElements(endPoint.getClass(), endPoint.getExtensionElements(), des, pw);
@@ -790,7 +805,7 @@
Constants.ELEM_TYPES,
des);
pw.print("<" + tagName);
- printExtensibilityAttributes(types.getExtensionAttributes(), des, pw);
+ printExtensibilityAttributes(types.getExtensionAttributes(), types, pw);
pw.println('>');
ExtensionElement[] extElements = types.getExtensionElements();
printExtensibilityElements(types.getClass(), extElements, des, pw);
@@ -867,7 +882,7 @@
for(int ind=0;ind<extensibilityElements.length;ind++){
ExtensionElement ext =extensibilityElements[ind];
QName elementType = ext.getExtensionType();
- ExtensionRegistry extReg = fWsdlContext.getExtensionRegistry();
+ ExtensionRegistry extReg = fWsdlContext.extensionRegistry;
if (extReg == null){
throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
"No ExtensionRegistry set for this " +
@@ -896,7 +911,7 @@
*/
protected void printExtensibilityAttributes(
XMLAttr[] attrExts,
- DescriptionElement des,
+ WSDLElement ownerElem,
PrintWriter pw)
throws WSDLException
{
@@ -911,8 +926,8 @@
if(ns!=null){
String attrPrefix=ns.getPrefix();
attrName=
- DOMUtils.getQualifiedValue(des.getNamespace(attrPrefix).toString(),
- attrLocalName, des);
+ DOMUtils.getQualifiedValue(ownerElem.getNamespaceURI(attrPrefix).toString(),
+ attrLocalName, ownerElem);
}else{
attrName=attrLocalName;
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMXMLElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMXMLElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMXMLElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/DOMXMLElement.java Mon Jan 7 09:36:13 2008
@@ -244,7 +244,7 @@
String namespaceURI = (prefix == null)
? getAttribute (tempEl, Constants.ATTR_XMLNS)
- : getAttributeNS (tempEl, Constants.NS_URI_XMLNS, prefix);
+ : getAttributeNS (tempEl, Constants.NS_STRING_XMLNS, prefix);
if (namespaceURI != null)
{
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/ErrorReporterImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/ErrorReporterImpl.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/ErrorReporterImpl.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/ErrorReporterImpl.java Mon Jan 7 09:36:13 2008
@@ -17,14 +17,14 @@
package org.apache.woden.internal;
import java.util.Locale;
+
import org.apache.woden.ErrorHandler;
import org.apache.woden.ErrorInfo;
import org.apache.woden.ErrorLocator;
import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
-import org.apache.woden.internal.ErrorInfoImpl;
-import org.apache.woden.internal.MessageFormatter;
import org.apache.woden.internal.util.PropertyUtils;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
/**
@@ -52,7 +52,7 @@
* via <code>setLocale</code> and a custom error handler implementation
* may be configured as a system property.
*
- * @author jkaputin@apache.org
+ * @author John Kaputin (jkaputin@apache.org)
*/
public class ErrorReporterImpl implements ErrorReporter {
@@ -71,6 +71,14 @@
protected static final String CONTINUE_AFTER_FATAL_ERROR =
"org.apache.woden.continue-after-fatal-error";
+ /*
+ * This property specifies the resource bundle containing the core Woden error messages.
+ *
+ * TODO extract these errors to a new public (non-internal) bundle.
+ * TODO define a public constants file with this type of info.
+ */
+ static final private String CORE_RESOURCE_BUNDLE = "org.apache.woden.internal.Messages";
+
//Used for localization of error messages.
private Locale fLocale;
@@ -81,7 +89,10 @@
private ErrorHandler fDefaultErrorHandler;
//Custom error handler to use instead of the default error handler
- private ErrorHandler fErrorHandler;
+ private ErrorHandler fErrorHandler;
+
+ //ExtensionRegistry contains names of user-registered error message ResourceBundles
+ private ExtensionRegistry fExtensionRegistry;
/*
* The default constructor sets the instance variables. It uses default
@@ -180,7 +191,8 @@
Exception exception)
throws WSDLException
{
- String message = fMessageFormatter.formatMessage(fLocale, errorId, arguments);
+ String[] names = getResourceBundleNames();
+ String message = fMessageFormatter.formatMessage(fLocale, errorId, arguments, names);
reportError(errLoc, errorId, message, severity, exception);
}
@@ -283,7 +295,21 @@
*/
public String getFormattedMessage(String key, Object[] arguments)
{
- String message = fMessageFormatter.formatMessage(fLocale, key, arguments);
+ String[] names = getResourceBundleNames();
+ String message = fMessageFormatter.formatMessage(fLocale, key, arguments, names);
return message;
+ }
+
+ //Package private as this is only
+ void setExtensionRegistry(ExtensionRegistry extensionRegistry) {
+ fExtensionRegistry = extensionRegistry;
+ }
+
+ private String[] getResourceBundleNames() {
+ if(fExtensionRegistry != null) {
+ return fExtensionRegistry.queryResourceBundleNames();
+ } else {
+ return new String[] {CORE_RESOURCE_BUNDLE};
+ }
}
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/MessageFormatter.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/MessageFormatter.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/MessageFormatter.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/MessageFormatter.java Mon Jan 7 09:36:13 2008
@@ -43,25 +43,37 @@
* @return the formatted message text
*
* @throws NullPointerException if key is null
- * @throws MissingResourceException if no object for the given key can be found
- * @throws ClassCastException if the object found for the given key is not a string
+ * @throws MissingResourceException if a resource bundle or the specified key cannot be found
+ * @throws ClassCastException if the object found for the specified key is not a string
* @throws IllegalArgumentException if the args don't match the message.
*/
- public String formatMessage(Locale locale, String key, Object[] args) {
+ public String formatMessage(Locale locale, String key, Object[] args, String[] bundleNames) {
ResourceBundle bundle = null;
+ MissingResourceException mre = null;
- if (locale == null) {
- bundle = ResourceBundle.getBundle("org.apache.woden.internal.Messages");
- } else {
- bundle = ResourceBundle.getBundle("org.apache.woden.internal.Messages",
- locale);
+ for(int i=0; i<bundleNames.length; i++) {
+ String bundleName = bundleNames[i];
+ try {
+ if (locale == null) {
+ bundle = ResourceBundle.getBundle(bundleName);
+ } else {
+ bundle = ResourceBundle.getBundle(bundleName, locale);
+ }
+ String unformattedMsg = bundle.getString(key);
+ String formattedMsg = MessageFormat.format(unformattedMsg, args);
+ return formattedMsg;
+ } catch (MissingResourceException e) {
+ if(i == (bundleNames.length -1)) {
+ mre = e; //key not found in any bundles
+ } else {
+ continue; //try the next bundle
+ }
+ }
}
+ throw mre;
- String unformattedMsg = bundle.getString(key);
- String formattedMsg = MessageFormat.format(unformattedMsg, args);
- return formattedMsg;
}
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/Messages.properties?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/Messages.properties (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/Messages.properties Mon Jan 7 09:36:13 2008
@@ -54,7 +54,9 @@
WSDL017=WSDL source represented by the type "{0}" cannot be read by the WSDLReader implementation class "{1}".
WSDL018=WSDL cannot be represented by the type "{0}" in the WSDLSource implementation class "{1}".
WSDL019=A WSDL element cannot be represented by the type "{0}" in the XMLElement implementation class "{1}".
-
+WSDL020=Woden extension registrar class "{0}" not found.
+WSDL021=Class "{0}" does not implement the Woden ExtensionRegistrar interface.
+WSDL022=Unable to instantiate the Woden extension registrar class "{0}".
# ------------ Parsing errors -------------------
WSDL500={0} Parsing error in document located at {1}.
@@ -79,6 +81,9 @@
WSDL524=URI resolution failed on URI "{0}".
WSDL523=Cannot add a new TypesElement as one already exists in the DescriptionElement.
+WSDL530=The XPointer "{0}" from the context URI "{1}" is invalid.
+WSDL531=The XPointer "{0}" from the context URI "{1}" failed to resolve any xml element.
+
# ------------ TODO determine if these errors are needed -------------------
# TODO - replace WSDL5xx error codes with reference numbers from the asserts
@@ -263,8 +268,9 @@
MessageLabel-1024.ref = 2.5.1
MessageLabel-1024.assertion = The value of this property MUST match the name of a placeholder message defined by the message exchange pattern.
-QName-0002 =
-QName-0002.assertion = Furthermore, all QName references, whether to the same of to difference namespace MUST resolve to components (see 2.1.9 QName resolution).
+QName-resolution-1064 = The QName ''{0}'' referred to in a ''{1}'' could not be resolved to a ''{2}''.
+QName-resolution-1064.ref = 2.17
+QName-resolution-1064.assertion = A Description component MUST NOT have such broken references.
# For each Service component in the {services} property of a Description component, the {name} property MUST be unique.
Service-1060 = A service with the name ''{0}'' has already been defined for the description component. All services defined in the description component must have unique names.
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLFactory.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLFactory.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLFactory.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLFactory.java Mon Jan 7 09:36:13 2008
@@ -17,22 +17,13 @@
package org.apache.woden.internal;
import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
import org.apache.woden.WSDLReader;
import org.apache.woden.WSDLWriter;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.extensions.PopulatedExtensionRegistry;
-import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
-import org.apache.woden.wsdl20.xml.DescriptionElement;
-public class OMWSDLFactory extends WSDLFactory {
+public class OMWSDLFactory extends BaseWSDLFactory {
- private WSDLContext fWsdlContext;
-
public OMWSDLFactory() throws WSDLException {
- fWsdlContext = new WSDLContext(this, new ErrorReporterImpl());
- ExtensionRegistry extReg = newPopulatedExtensionRegistry();
- fWsdlContext.setExtensionRegistry(extReg);
+ super();
}
//Returns an OMWSDLReader
@@ -40,19 +31,9 @@
return new OMWSDLReader(fWsdlContext);
}
-// Returns an DOMWSDLWriter
+// Returns an OMWSDLWriter
public WSDLWriter newWSDLWriter() throws WSDLException{
return new OMWSDLWriter(fWsdlContext);
- }
-
-
-
- public DescriptionElement newDescription() {
- return new DescriptionImpl(fWsdlContext);
- }
-
- public ExtensionRegistry newPopulatedExtensionRegistry() {
- return new PopulatedExtensionRegistry(fWsdlContext);
}
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLReader.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLReader.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLReader.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLReader.java Mon Jan 7 09:36:13 2008
@@ -20,7 +20,9 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Arrays;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -43,10 +45,14 @@
import org.apache.woden.internal.util.om.OMQNameUtils;
import org.apache.woden.internal.util.om.OMUtils;
import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.internal.xpointer.OMXMLElementEvaluator;
import org.apache.woden.schema.Schema;
+import org.apache.woden.types.NamespaceDeclaration;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.xml.DescriptionElement;
import org.apache.woden.wsdl20.xml.WSDLElement;
+import org.apache.woden.xpointer.InvalidXPointerException;
+import org.apache.woden.xpointer.XPointer;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaException;
@@ -70,27 +76,70 @@
URL url;
try {
url = StringUtils.getURL(null, wsdlURI);
- }
- catch (MalformedURLException e) {
+ } catch (MalformedURLException e) {
String msg = getErrorReporter().getFormattedMessage(
"WSDL502", new Object[] {null, wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
String wsdlURL = url.toString();
- OMElement wsdlDescription = null;
+ OMElement root = null;
+
+ // perform URI Resolution here
try {
- // perform URI Resolution here
- wsdlDescription = OMUtils.getElement(resolveURI(wsdlURL));
- } catch (IOException e) {
- String msg = getErrorReporter().getFormattedMessage("WSDL503",
- new Object[] { wsdlURL });
+ root = OMUtils.getElement(resolveURI(wsdlURL));
+ } catch (IOException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL503", new Object[] {wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ } catch (URISyntaxException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL502", new Object[] {null, wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ } catch (XMLStreamException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL500", new Object[] {"XML", wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ }
+ //Try to find an element the XPointer points to if a Fragment Identifier exists.
+ URI uri = null;
+ try {
+ uri = new URI(wsdlURI);
+ } catch (URISyntaxException e) {
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL506", new Object[] {wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
- XMLElement descEl = createXMLElement(wsdlDescription);
- DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
- return descElem.toComponent();
+ String fragment = uri.getFragment();
+
+ if (fragment == null) { //No fragment identifier so just use the root element.
+ XMLElement descEl = createXMLElement(root);
+ DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
+ return descElem.toComponent();
+ } else {
+ XPointer xpointer;
+ try {
+ xpointer = new XPointer(fragment);
+ } catch(InvalidXPointerException e) {
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL530", new Object[] {fragment, wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ }
+
+ OMXMLElementEvaluator evaluator = new OMXMLElementEvaluator(xpointer, root, getErrorReporter());
+ OMElement result = evaluator.evaluateElement();
+
+ if (result != null) { //Element from XPointer evaluation.
+ XMLElement descEl = createXMLElement(result);
+ DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
+ return descElem.toComponent();
+ } else {
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL531", new Object[] {fragment, wsdlURI});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg);
+ }
+ }
}
/*
@@ -196,6 +245,14 @@
//not previously imported, so retrieve it now.
try {
importedSchemaDoc = OMUtils.getElement(schemaURL);
+ } catch (URISyntaxException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL502", new Object[] {null, schemaURL});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ } catch (XMLStreamException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL500", new Object[] {"XML", schemaURL});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
} catch (IOException e4) {
//schema retrieval failed (e.g. 'not found')
@@ -278,7 +335,13 @@
//Set the baseURI and the namespaces from the DescriptionElement in the XMLSchemaCollection
xsc.setBaseUri(baseURI);
- NamespaceMap namespaces = new NamespaceMap(desc.getNamespaces());
+
+ NamespaceMap namespaces = new NamespaceMap();
+ Iterator it = Arrays.asList(desc.getDeclaredNamespaces()).iterator();
+ while(it.hasNext()) {
+ NamespaceDeclaration d = (NamespaceDeclaration)it.next();
+ namespaces.add(d.getPrefix(), d.getNamespaceURI().toString());
+ }
xsc.setNamespaceContext(namespaces);
// Plug in the selected woden URI Resolver
@@ -324,16 +387,6 @@
throws WSDLException {
}
-
- public Description readWSDL(String wsdlURI,
- ErrorHandler errorHandler)
- throws WSDLException {
- if(errorHandler != null)
- getErrorReporter().setErrorHandler(errorHandler);
-
- return readWSDL(wsdlURI);
- }
-
///////////////////////////////////////
// METHODS FOR READING FROM A SOURCE
///////////////////////////////////////
@@ -344,15 +397,6 @@
return null;
}
-
- //TODO
- public Description readWSDL(WSDLSource wsdlSource,
- ErrorHandler errorHandler)
- throws WSDLException {
- return null;
- }
-
-
//////////////////////////
// HELPER METHODS
//////////////////////////
@@ -418,9 +462,15 @@
// not previously imported or included, so retrieve the WSDL.
try {
docEl = OMUtils.getElement(locationStr);
- }
- catch (IOException e)
- {
+ } catch (URISyntaxException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL502", new Object[] {null, locationStr});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ } catch (XMLStreamException e){
+ String msg = getErrorReporter().getFormattedMessage(
+ "WSDL500", new Object[] {"XML", locationStr});
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ } catch (IOException e) {
// document retrieval failed (e.g. 'not found')
getErrorReporter().reportError(
new ErrorLocatorImpl(), // TODO line&col nos.
@@ -478,9 +528,6 @@
throws WSDLException {
OMElement omDescription = (OMElement)xmlElem.getSource();
- //TODO remove this cast when support for NS decls is expanded from DescriptionElement to all WSDLElements
- DescriptionElement desc = (DescriptionElement)wsdlElem;
-
Iterator namespaces = omDescription.getAllDeclaredNamespaces();
while(namespaces.hasNext()){
OMNamespace namespace = (OMNamespace)namespaces.next();
@@ -488,10 +535,10 @@
String value = namespace.getNamespaceURI();
if (!(Constants.ATTR_XMLNS).equals(localPart)){
- desc.addNamespace(localPart, getURI(value)); //a prefixed namespace
+ wsdlElem.addNamespace(localPart, getURI(value)); //a prefixed namespace
}
else{
- desc.addNamespace(null, getURI(value)); //the default namespace
+ wsdlElem.addNamespace(null, getURI(value)); //the default namespace
}
}
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/WSDLContext.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/WSDLContext.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/WSDLContext.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/WSDLContext.java Mon Jan 7 09:36:13 2008
@@ -33,21 +33,14 @@
public class WSDLContext {
final public WSDLFactory wsdlFactory;
final public ErrorReporter errorReporter;
- private ExtensionRegistry extensionRegistry;
+ final public ExtensionRegistry extensionRegistry;
- //package private ctor - should only be created by WSDLFactory impl class
+ //package private ctor
WSDLContext(WSDLFactory wsdlFactory,
- ErrorReporter errorReporter) {
+ ErrorReporter errorReporter,
+ ExtensionRegistry extensionRegistry) {
this.wsdlFactory = wsdlFactory;
this.errorReporter = errorReporter;
- }
-
- //package private - should only be called by WSDLReader.setExtensionRegistry impls
- void setExtensionRegistry(ExtensionRegistry extensionRegistry) {
this.extensionRegistry = extensionRegistry;
- }
-
- public ExtensionRegistry getExtensionRegistry() {
- return this.extensionRegistry;
}
}
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SchemaResolverAdapter.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SchemaResolverAdapter.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SchemaResolverAdapter.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SchemaResolverAdapter.java Mon Jan 7 09:36:13 2008
@@ -16,12 +16,14 @@
*/
package org.apache.woden.internal.resolver;
-import java.io.File;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import org.apache.woden.XMLElement;
+import org.apache.woden.internal.util.StringUtils;
import org.xml.sax.InputSource;
/**
@@ -91,6 +93,7 @@
/* IOException
* WSDLException
* URISyntaxException
+ * MalformedURLException
*/
throw new RuntimeException(e);
}
@@ -134,16 +137,14 @@
*/
private URI buildUri(String targetNamespace,
String schemaLocation,
- String baseUri) throws URISyntaxException {
+ String baseUri) throws URISyntaxException, MalformedURLException {
if (baseUri != null)
{
-
- File baseFile = new File(baseUri);
- if (baseFile.exists()) baseUri = baseFile.toURI().toString();
-
- return new URI(baseUri).resolve(new URI(schemaLocation));
-
+ URL ctxUrl = new URL(baseUri);
+ URL schemaUrl = StringUtils.getURL(ctxUrl,schemaLocation);
+ URI uri = new URI(schemaUrl.toString());
+ return uri;
}
return new URI(schemaLocation);
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SimpleURIResolver.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SimpleURIResolver.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SimpleURIResolver.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/resolver/SimpleURIResolver.java Mon Jan 7 09:36:13 2008
@@ -175,18 +175,8 @@
*/
private Properties loadCatalog(URL catalogLocation, Properties catalog) {
if (catalogLocation != null) {
- URI catalogURI = null;
- try {
- catalogURI = new URI(catalogLocation.toString());
- } catch (URISyntaxException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- try
- {
- if (catalogURI != null) {
- catalog.load(catalogURI.toURL().openStream());
- }
+ try {
+ catalog.load(catalogLocation.openStream());
}
catch (IllegalArgumentException e) {
e.printStackTrace();
Modified: webservices/woden/branches/woden65/src/org/apache/woden/internal/util/dom/DOMUtils.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/util/dom/DOMUtils.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/util/dom/DOMUtils.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/util/dom/DOMUtils.java Mon Jan 7 09:36:13 2008
@@ -16,21 +16,17 @@
*/
package org.apache.woden.internal.util.dom;
+import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.ListIterator;
import java.util.Vector;
-import java.util.Map;
-import java.io.PrintWriter;
import javax.xml.namespace.QName;
-import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.internal.ErrorReporterImpl;
-import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.WSDLElement;
import org.w3c.dom.Attr;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Element;
@@ -250,271 +246,6 @@
return nkids;
}
- /**
- * Given a prefix and a node, return the namespace URI that the prefix
- * has been associated with. This method is useful in resolving the
- * namespace URI of attribute values which are being interpreted as
- * QNames. If prefix is null, this method will return the default
- * namespace.
- *
- * @param context the starting node (looks up recursively from here)
- * @param prefix the prefix to find an xmlns:prefix=uri for
- *
- * @return the namespace URI or null if not found
- */
- public static String getNamespaceURIFromPrefix (Node context,
- String prefix) {
- short nodeType = context.getNodeType ();
- Node tempNode = null;
-
- switch (nodeType)
- {
- case Node.ATTRIBUTE_NODE :
- {
- tempNode = ((Attr) context).getOwnerElement ();
- break;
- }
- case Node.ELEMENT_NODE :
- {
- tempNode = context;
- break;
- }
- default :
- {
- tempNode = context.getParentNode ();
- break;
- }
- }
-
- while (tempNode != null && tempNode.getNodeType () == Node.ELEMENT_NODE)
- {
- Element tempEl = (Element) tempNode;
- String namespaceURI = (prefix == null)
- ? getAttribute (tempEl, ATTR_XMLNS)
- : getAttributeNS (tempEl, NS_URI_XMLNS, prefix);
-
- if (namespaceURI != null)
- {
- return namespaceURI;
- }
- else
- {
- tempNode = tempEl.getParentNode ();
- }
- }
-
- return null;
- }
-
- /*
- * this is a new version of the original getQName method from WSDL4J, with the invocation
- * of registerUniquePrefix commented out and the 'desc' arg removed from the arg list.
- * TODO pending modification to original method post-M2 (see todo comments below).
- */
- public static QName getQName(String prefixedValue,
- Element contextEl)
- throws WSDLException
- {
- int index = prefixedValue.indexOf(':');
- String prefix = (index != -1)
- ? prefixedValue.substring(0, index)
- : null;
- String localPart = prefixedValue.substring(index + 1);
- String namespaceURI = getNamespaceURIFromPrefix(contextEl, prefix);
-
- if (namespaceURI != null)
- {
- //TODO investigate changing the registration of namespaces and prefixes (i.e. namespace decls)
- //so it can happen within any WSDL element, not just Description (current behaviour is copied from WSDL4J)
- //registerUniquePrefix(prefix, namespaceURI, desc);
-
- //TODO when passing prefix to QName ctor, what if it was modified by
- //registerUniquePrefix because of a name clash (pass original or modification)?
- return new QName(namespaceURI,
- localPart,
- prefix != null ? prefix : emptyString);
- }
- else
- {
- //TODO use ErrorReporter here or in callers to report the problem
-
- String faultCode = (prefix == null)
- ? WSDLException.NO_PREFIX_SPECIFIED
- : WSDLException.UNBOUND_PREFIX;
-
- WSDLException wsdlExc = new WSDLException(faultCode,
- "Unable to determine " +
- "namespace of '" +
- prefixedValue + "'.");
-
- wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(contextEl));
-
- throw wsdlExc;
- }
- }
-
- /*
- * this is the original version of the getQName method, per WSDL4J. See to do comment below
- * about changing register unique prefix behaviour. TODO TBD post-M2 (JK)
- */
- public static QName getQName(String prefixedValue,
- Element contextEl,
- DescriptionElement desc)
- throws WSDLException
- {
- int index = prefixedValue.indexOf(':');
- String prefix = (index != -1)
- ? prefixedValue.substring(0, index)
- : null;
- String localPart = prefixedValue.substring(index + 1);
- String namespaceURI = getNamespaceURIFromPrefix(contextEl, prefix);
-
- if (namespaceURI != null)
- {
- //TODO investigate changing the registration of namespaces and prefixes (i.e. namespace decls)
- //so it can happen within any WSDL element, not just Description (current behaviour is copied from WSDL4J)
- registerUniquePrefix(prefix, namespaceURI, desc);
-
- //TODO when passing prefix to QName ctor, what if it was modified by
- //registerUniquePrefix because of a name clash (pass original or modification)?
- return new QName(namespaceURI,
- localPart,
- prefix != null ? prefix : emptyString);
- }
- else
- {
- //TODO use ErrorReporter here or in callers to report the problem
-
- String faultCode = (prefix == null)
- ? WSDLException.NO_PREFIX_SPECIFIED
- : WSDLException.UNBOUND_PREFIX;
-
- WSDLException wsdlExc = new WSDLException(faultCode,
- "Unable to determine " +
- "namespace of '" +
- prefixedValue + "'.");
-
- wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(contextEl));
-
- throw wsdlExc;
- }
- }
-
- public static void registerUniquePrefix(String prefix,
- String namespaceURI,
- DescriptionElement desc)
- throws WSDLException
- {
- URI nsUri = desc.getNamespace(prefix);
- String tempNSUri = nsUri != null ? nsUri.toString() : null;
-
- if (tempNSUri != null && tempNSUri.equals(namespaceURI))
- {
- return;
- }
-
- while (tempNSUri != null && !tempNSUri.equals(namespaceURI))
- {
- prefix += "_";
- nsUri = desc.getNamespace(prefix);
- tempNSUri = nsUri != null ? nsUri.toString() : null;
- }
-
- URI uri = null;
- try {
- uri = new URI(namespaceURI);
- } catch (URISyntaxException e) {
- //TODO make sure custom err handler is used, if configured
- new ErrorReporterImpl().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL506",
- new Object[] {namespaceURI},
- ErrorReporter.SEVERITY_ERROR,
- e);
- }
-
- desc.addNamespace(prefix, uri);
- }
-
- /**
- * This method should be used for elements that support extension attributes
- * because it does not track the remaining attributes to test for unexpected
- * attributes.
- */
- /*
- public static QName getQualifiedAttributeValue(Element el,
- String attrName,
- String elDesc,
- boolean isRequired,
- Definition def)
- throws WSDLException
- {
- String attrValue = DOMUtils.getAttribute(el, attrName);
-
- if (attrValue != null)
- {
- return getQName(attrValue, el, def);
- }
- else if (isRequired)
- {
- WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
- "The '" + attrName +
- "' attribute must be " +
- "specified for every " +
- elDesc + " element.");
-
- wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
-
- throw wsdlExc;
- }
- else
- {
- return null;
- }
- }
- /*
-
- /**
- * This method should be used for elements that do not support extension attributes
- * because it tracks the remaining attributes so that eventually any
- * unexpected attributes can be identified.
- */
- /*
- public static QName getQualifiedAttributeValue(Element el,
- String attrName,
- String elDesc,
- boolean isRequired,
- Definition def,
- List remainingAttrs)
- throws WSDLException
- {
- String attrValue = null;
-
- attrValue = DOMUtils.getAttribute(el, attrName, remainingAttrs);
-
- if (attrValue != null)
- {
- return getQName(attrValue, el, def);
- }
- else if (isRequired)
- {
- WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
- "The '" + attrName +
- "' attribute must be " +
- "specified for every " +
- elDesc + " element.");
-
- wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
-
- throw wsdlExc;
- }
- else
- {
- return null;
- }
- }
- */
-
public static void throwWSDLException(Element location) throws WSDLException
{
String elName = DOMQNameUtils.newQName(location).toString();
@@ -553,7 +284,6 @@
throw wsdlExc;
}
-
public static void printAttribute(String name,
String value,
PrintWriter pw)
@@ -564,14 +294,13 @@
}
}
-
/**
* Prints attributes with qualified names.
*/
-
+ /*
public static void printQualifiedAttribute(QName name,
String value,
- DescriptionElement desEle,
+ Definition def,
PrintWriter pw)
throws WSDLException
{
@@ -579,7 +308,7 @@
{
printAttribute(getQualifiedValue(name.getNamespaceURI(),
name.getLocalPart(),
- desEle),
+ def),
value,
pw);
}
@@ -587,7 +316,7 @@
public static void printQualifiedAttribute(QName name,
QName value,
- DescriptionElement desEle,
+ Definition def,
PrintWriter pw)
throws WSDLException
{
@@ -595,17 +324,18 @@
{
printAttribute(getQualifiedValue(name.getNamespaceURI(),
name.getLocalPart(),
- desEle),
+ def),
getQualifiedValue(value.getNamespaceURI(),
value.getLocalPart(),
- desEle),
+ def),
pw);
}
}
+ */
public static void printQualifiedAttribute(String name,
QName value,
- DescriptionElement desEle,
+ WSDLElement elem,
PrintWriter pw)
throws WSDLException
{
@@ -614,63 +344,64 @@
printAttribute(name,
getQualifiedValue(value.getNamespaceURI(),
value.getLocalPart(),
- desEle),
+ elem),
pw);
}
}
- public static String getQualifiedValue(String namespaceURI,
+ public static String getQualifiedValue(URI namespaceURI,
String localPart,
- DescriptionElement desEle)
+ WSDLElement elem)
throws WSDLException
{
String prefix = null;
- if (namespaceURI != null && !namespaceURI.equals(""))
+ if (namespaceURI != null && !namespaceURI.toString().equals(""))
{
- prefix = getPrefix(namespaceURI, desEle);
+ prefix = elem.getNamespacePrefix(namespaceURI);
}
+
+ String qv = ((prefix != null && !prefix.equals("")) ? prefix + ":" : "") + localPart;
+
+ return qv;
+ }
- return ((prefix != null && !prefix.equals(""))
- ? prefix + ":"
- : "") + localPart;
+ public static String getQualifiedValue(String namespaceURI,
+ String localPart,
+ WSDLElement elem)
+ throws WSDLException
+ {
+ URI nsUri = null;
+ if(namespaceURI != null) {
+ try {
+ nsUri = new URI(namespaceURI);
+ } catch (URISyntaxException e) {
+ // TODO handle this correctly
+ throw new RuntimeException(e);
+ }
+ }
+ return getQualifiedValue(nsUri,localPart,elem);
}
+ /*
public static String getPrefix(String namespaceURI,
- DescriptionElement desEle)
+ Definition def)
throws WSDLException
{
- String prefix =null;
- Map nsm=desEle.getNamespaces();
- java.util.Iterator entryIterator = nsm.entrySet().iterator();
-
-
- while (entryIterator.hasNext())
- {
- Map.Entry entry = (Map.Entry)entryIterator.next();
- String currPrefix = (String)entry.getKey();
- String assocNamespaceURI = entry.getValue().toString();
-
- if(namespaceURI.equals(assocNamespaceURI)){
-
- prefix=currPrefix;
-
- }
- }
-
- if (prefix == null)
- {
- throw new WSDLException(WSDLException.OTHER_ERROR,
- "Can't find prefix for '" + namespaceURI +
- "'. Namespace prefixes must be set on the" +
- " Definition object using the " +
- "addNamespace(...) method.");
-
- }
+ String prefix = def.getPrefix(namespaceURI);
+ if (prefix == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Can't find prefix for '" + namespaceURI +
+ "'. Namespace prefixes must be set on the" +
+ " Definition object using the " +
+ "addNamespace(...) method.");
+ }
- return prefix;
+ return prefix;
}
+ */
public static String cleanString(String orig)
{
@@ -739,7 +470,6 @@
return strBuf.toString();
}
-
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org