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 2007/08/23 13:01:35 UTC
svn commit: r568932 [10/36] - in
/incubator/woden/trunk/java/src/org/apache/woden: ./ ant/ internal/
internal/resolver/ internal/schema/ internal/util/ internal/util/dom/
internal/util/om/ internal/wsdl20/ internal/wsdl20/extensions/
internal/wsdl20/ex...
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java Thu Aug 23 04:01:23 2007
@@ -1,499 +1,499 @@
-/**
+/**
* 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 java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.woden.ErrorHandler;
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.WSDLSource;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.resolver.OMSchemaResolverAdapter;
-import org.apache.woden.internal.schema.ImportedSchemaImpl;
-import org.apache.woden.internal.schema.InlinedSchemaImpl;
-import org.apache.woden.internal.schema.SchemaConstants;
-import org.apache.woden.internal.util.StringUtils;
-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.schema.Schema;
-import org.apache.woden.wsdl20.Description;
-import org.apache.woden.wsdl20.xml.DescriptionElement;
-import org.apache.woden.wsdl20.xml.WSDLElement;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaException;
-import org.apache.ws.commons.schema.utils.NamespaceMap;
-import org.xml.sax.InputSource;
-
-/**
- * Implements WSDL reader behaviour for OM based parsing
- */
-public class OMWSDLReader extends BaseWSDLReader{
-
- //A map of imported schema definitions keyed by schema location URI
- private Map fImportedSchemas = new Hashtable();
-
- OMWSDLReader(WSDLContext wsdlContext) throws WSDLException {
- super(wsdlContext);
- }
-
- public Description readWSDL(String wsdlURI) throws WSDLException {
- //This conversion to a URL is necessary to import the schema
- URL url;
- try {
- url = StringUtils.getURL(null, wsdlURI);
- }
- 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;
- try {
- // perform URI Resolution here
- wsdlDescription = OMUtils.getElement(resolveURI(wsdlURL));
- } catch (IOException e) {
- String msg = getErrorReporter().getFormattedMessage("WSDL503",
- new Object[] { wsdlURL });
- throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
- }
-
- XMLElement descEl = createXMLElement(wsdlDescription);
- DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
- return descElem.toComponent();
- }
-
- /*
- * Parse the <xs:import> element and retrieve the imported
- * schema document if schemaLocation specified. Failure to retrieve
- * the schema will only matter if any WSDL components contain elements or
- * constraints that refer to the schema, and typically this will be
- * determined later by WSDL validation. So just report any such errors
- * and return the SchemaImport object (i.e. with a null schema property).
- *
- * WSDL 2.0 spec validation:
- * - namespace attribute is REQUIRED
- * - imported schema MUST have a targetNamespace
- * - namespace and targetNamespace MUST be the same
- */
- protected Schema parseSchemaImport(XMLElement importEl,
- DescriptionElement desc)
- throws WSDLException {
-
- ImportedSchemaImpl schema = new ImportedSchemaImpl();
-
- String ns = importEl.getAttributeValue(Constants.ATTR_NAMESPACE);
-
- if(ns != null) {
- schema.setNamespace(getURI(ns));
- }
-
- String sloc = importEl.getAttributeValue(SchemaConstants.ATTR_SCHEMA_LOCATION);
- if(sloc != null) {
- schema.setSchemaLocation(getURI(sloc));
- }
-
- if(schema.getNamespace() == null){
- //The namespace attribute is REQUIRED on xs:import, so don't continue.
- schema.setReferenceable(false);
- return schema;
- }
-
- if(schema.getSchemaLocation() == null){
- //This is a namespace-only import, no schema document to be retrieved so don't continue.
-
- /* TODO investigate whether/how to try to resolve the imported namespace to known schema
- * components from that namespace (e.g. via a URI catalog resolver). Currently, any attempt
- * to resolve a QName against schema components from this namespace will search ALL
- * schemas imported from this namespace (see methods in TypesImpl).
- */
-
- return schema;
- }
-
- //Now try to retrieve the schema import using schemaLocation
-
- OMElement importedSchemaDoc = null;
- URI contextURI = null;
- String schemaLoc = null;
- URL url = null;
-
- try{
- /*
- * For simple resolvers, we resolve the parent (Description) URI
- * to be used as the context. This allows for relative locationURIs
- * to be resolved implicitly - they are considered to be located
- * relative to the resolved parent. Therefore, relative URIs such as these
- * need not be listed in the catalog file.
- */
-
- /* TODO
- * OASIS-style catalogs have a convenience notation to define root URIs
- * thus grouping related URLs together. In this case the context URI here
- * should be left alone, but the resultant locationURL resolved instead.
- *
- * Implement a boolean system property like org.apache.woden.resolver.useRelativeURLs
- * (set by the resolver ctor). SimpleURIResolver (et al) should set this to true,
- * OASISCatalogResolver should set to false.
- */
- // contextURI = desc.getDocumentBaseURI();
- contextURI = resolveURI(desc.getDocumentBaseURI());
- URL contextURL = (contextURI != null) ? contextURI.toURL() : null;
- schemaLoc = schema.getSchemaLocation().toString();
- url = StringUtils.getURL(contextURL, schemaLoc);
-
- }
- catch (MalformedURLException e) {
-
- String baseLoc = contextURI != null ? contextURI.toString() : null;
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL502",
- new Object[] {baseLoc, schemaLoc},
- ErrorReporter.SEVERITY_ERROR);
-
- //can't continue schema retrieval with a bad URL.
- schema.setReferenceable(false);
- return schema;
- }
-
- String schemaURL = url.toString();
-
- //If the schema has already been imported, reuse it.
- XmlSchema schemaDef = (XmlSchema)fImportedSchemas.get(schemaURL);
-
- if(schemaDef == null){
- //not previously imported, so retrieve it now.
- try {
- importedSchemaDoc = OMUtils.getElement(schemaURL);
- } catch (IOException e4) {
-
- //schema retrieval failed (e.g. 'not found')
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL504",
- new Object[] {schemaURL},
- ErrorReporter.SEVERITY_WARNING,
- e4);
-
- //cannot continue without an imported schema
- schema.setReferenceable(false);
- return schema;
- }
-
- /*
- * First get the schema element and serialize that into a byte array.
- * This is used in getting an InputSource which is later used as an argument
- * to the XMLSchemaCollection object.
- */
- String schemaElStr = null;
- try {
- schemaElStr = importedSchemaDoc.toStringWithConsume();
- }
- catch (XMLStreamException e) {
- e.printStackTrace();
- }
- byte[] schemaElbytes = schemaElStr.getBytes();
- InputSource schemaSource = new InputSource(new ByteArrayInputStream(schemaElbytes));
- schemaSource.setSystemId(schemaURL);
-
- try {
- XmlSchemaCollection xsc = new XmlSchemaCollection();
-
- // Plug in the selected woden URI Resolver
- xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), importEl));
-
- schemaDef = xsc.read(schemaSource, null);
- fImportedSchemas.put(schemaURL, schemaDef);
- }
- catch (XmlSchemaException e){
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL522",
- new Object[] {schemaURL},
- ErrorReporter.SEVERITY_WARNING,
- e);
- }
- }
- if(schemaDef != null) {
- schema.setSchemaDefinition(schemaDef);
- }
- else {
- schema.setReferenceable(false);
- }
- return schema;
- }
-
-
- protected Schema parseSchemaInline(XMLElement schemaElement,
- DescriptionElement desc)
- throws WSDLException{
-
- InlinedSchemaImpl schema = new InlinedSchemaImpl();
- schema.setId(schemaElement.getAttributeValue(Constants.ATTR_ID));
- String tns = schemaElement.getAttributeValue(Constants.ATTR_TARGET_NAMESPACE);
- if(tns != null) {
- schema.setNamespace(getURI(tns));
- }
-
- String baseURI = desc.getDocumentBaseURI() != null ?
- desc.getDocumentBaseURI().toString() : null;
-
- XmlSchema schemaDef = null;
-
- try {
- OMElement omSchemaElem = (OMElement)schemaElement.getSource();
- InputSource schemaSource = OMUtils.getInputSource(omSchemaElem);
- XmlSchemaCollection xsc = new XmlSchemaCollection();
-
- //Set the baseURI and the namespaces from the DescriptionElement in the XMLSchemaCollection
- xsc.setBaseUri(baseURI);
- NamespaceMap namespaces = new NamespaceMap(desc.getNamespaces());
- xsc.setNamespaceContext(namespaces);
-
- // Plug in the selected woden URI Resolver
- xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), schemaElement));
-
- schemaDef = xsc.read(schemaSource, null);
- }
- catch (XmlSchemaException e){
-
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL521",
- new Object[] {baseURI},
- ErrorReporter.SEVERITY_WARNING,
- e);
- }
- catch (RuntimeException e)
- {
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL521",
- new Object[] {baseURI},
- ErrorReporter.SEVERITY_ERROR,
- e);
- }
-
- if(schemaDef != null) {
- schema.setSchemaDefinition(schemaDef);
- }
- else {
- schema.setReferenceable(false);
- }
-
- return schema;
- }
-
-
- //TODO
- protected void parseExtensionAttributes(XMLElement domEl,
- Class wsdlClass,
- WSDLElement wsdlObj,
- DescriptionElement desc)
- 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
- ///////////////////////////////////////
-
- //TODO
- public Description readWSDL(WSDLSource wsdlSource)
- throws WSDLException {
- return null;
- }
-
-
- //TODO
- public Description readWSDL(WSDLSource wsdlSource,
- ErrorHandler errorHandler)
- throws WSDLException {
- return null;
- }
-
-
- //////////////////////////
- // HELPER METHODS
- //////////////////////////
-
-
- /*
- * Retrieve a WSDL document by resolving the location URI specified
- * on a WSDL <import> or <include> element.
- *
- * TODO add support for a URL Catalog Resolver
- */
- protected DescriptionElement getWSDLFromLocation(String locationURI,
- DescriptionElement desc,
- Map wsdlModules)
- throws WSDLException{
- DescriptionElement referencedDesc = null;
- OMElement docEl;
- URL locationURL = null;
- URI contextURI = null;
-
- try{
- /*
- * For simple resolvers, we resolve the parent (Description) URI
- * to be used as the context. This allows for relative locationURIs
- * to be resolved implicitly - they are considered to be located
- * relative to the resolved parent. Therefore, relative URIs such as these
- * need not be listed in the catalog file.
- */
-
- /* TODO
- * OASIS-style catalogs have a convenience notation to define root URIs
- * thus grouping related URLs together. In this case the context URI here
- * should be left alone, but the resultant locationURL resolved instead.
- *
- * Implement a boolean system property like org.apache.woden.resolver.useRelativeURLs
- * (set by the resolver ctor). SimpleURIResolver (et al) should set this to true,
- * OASISCatalogResolver should set to false.
- */
- // contextURI = desc.getDocumentBaseURI();
- contextURI = resolveURI(desc.getDocumentBaseURI());
- URL contextURL = (contextURI != null) ? contextURI.toURL() : null;
- locationURL = StringUtils.getURL(contextURL, locationURI);
- }
- catch (MalformedURLException e){
- String baseURI = contextURI != null ? contextURI.toString() : null;
-
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL502",
- new Object[] {baseURI, locationURI},
- ErrorReporter.SEVERITY_ERROR);
-
- //can't continue import with a bad URL.
- return null;
- }
-
- String locationStr = locationURL.toString();
-
- //Check if WSDL imported or included previously from this location.
- referencedDesc = (DescriptionElement)wsdlModules.get(locationStr);
-
- if(referencedDesc == null){
- // not previously imported or included, so retrieve the WSDL.
- try {
- docEl = OMUtils.getElement(locationStr);
- }
- catch (IOException e)
- {
- // document retrieval failed (e.g. 'not found')
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), // TODO line&col nos.
- "WSDL503",
- new Object[] {locationStr},
- ErrorReporter.SEVERITY_WARNING,
- e);
-
- // cannot continue without the referenced document
- return null;
- }
-
- //The referenced document should contain a WSDL <description>
- if(!OMQNameUtils.matches(Constants.Q_ELEM_DESCRIPTION, docEl)){
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL501",
- new Object[] {Constants.Q_ELEM_DESCRIPTION,
- OMQNameUtils.newQName(docEl)},
- ErrorReporter.SEVERITY_ERROR);
-
- //cannot continue without a <description> element
- return null;
- }
-
- XMLElement descEl = createXMLElement(docEl);
-
- referencedDesc = parseDescription(locationStr,
- descEl,
- wsdlModules);
-
- if(!wsdlModules.containsKey(locationStr)){
- wsdlModules.put(locationStr, referencedDesc);
- }
- }
-
- return referencedDesc;
- }
-
- //TODO
- public WSDLSource createWSDLSource() {
- return null;
- }
-
- protected XMLElement createXMLElement(Object elem) {
- OMXMLElement omXMLElement = new OMXMLElement(getErrorReporter());
- omXMLElement.setSource(elem);
- return omXMLElement;
-
- }
-
- protected void parseNamespaceDeclarations(
- XMLElement xmlElem,
- WSDLElement wsdlElem)
- 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();
- String localPart = namespace.getPrefix();
- String value = namespace.getNamespaceURI();
-
- if (!(Constants.ATTR_XMLNS).equals(localPart)){
- desc.addNamespace(localPart, getURI(value)); //a prefixed namespace
- }
- else{
- desc.addNamespace(null, getURI(value)); //the default namespace
- }
- }
- }
-
+ *
+ * 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 java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLSource;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.resolver.OMSchemaResolverAdapter;
+import org.apache.woden.internal.schema.ImportedSchemaImpl;
+import org.apache.woden.internal.schema.InlinedSchemaImpl;
+import org.apache.woden.internal.schema.SchemaConstants;
+import org.apache.woden.internal.util.StringUtils;
+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.schema.Schema;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.WSDLElement;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaException;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.xml.sax.InputSource;
+
+/**
+ * Implements WSDL reader behaviour for OM based parsing
+ */
+public class OMWSDLReader extends BaseWSDLReader{
+
+ //A map of imported schema definitions keyed by schema location URI
+ private Map fImportedSchemas = new Hashtable();
+
+ OMWSDLReader(WSDLContext wsdlContext) throws WSDLException {
+ super(wsdlContext);
+ }
+
+ public Description readWSDL(String wsdlURI) throws WSDLException {
+ //This conversion to a URL is necessary to import the schema
+ URL url;
+ try {
+ url = StringUtils.getURL(null, wsdlURI);
+ }
+ 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;
+ try {
+ // perform URI Resolution here
+ wsdlDescription = OMUtils.getElement(resolveURI(wsdlURL));
+ } catch (IOException e) {
+ String msg = getErrorReporter().getFormattedMessage("WSDL503",
+ new Object[] { wsdlURL });
+ throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+ }
+
+ XMLElement descEl = createXMLElement(wsdlDescription);
+ DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
+ return descElem.toComponent();
+ }
+
+ /*
+ * Parse the <xs:import> element and retrieve the imported
+ * schema document if schemaLocation specified. Failure to retrieve
+ * the schema will only matter if any WSDL components contain elements or
+ * constraints that refer to the schema, and typically this will be
+ * determined later by WSDL validation. So just report any such errors
+ * and return the SchemaImport object (i.e. with a null schema property).
+ *
+ * WSDL 2.0 spec validation:
+ * - namespace attribute is REQUIRED
+ * - imported schema MUST have a targetNamespace
+ * - namespace and targetNamespace MUST be the same
+ */
+ protected Schema parseSchemaImport(XMLElement importEl,
+ DescriptionElement desc)
+ throws WSDLException {
+
+ ImportedSchemaImpl schema = new ImportedSchemaImpl();
+
+ String ns = importEl.getAttributeValue(Constants.ATTR_NAMESPACE);
+
+ if(ns != null) {
+ schema.setNamespace(getURI(ns));
+ }
+
+ String sloc = importEl.getAttributeValue(SchemaConstants.ATTR_SCHEMA_LOCATION);
+ if(sloc != null) {
+ schema.setSchemaLocation(getURI(sloc));
+ }
+
+ if(schema.getNamespace() == null){
+ //The namespace attribute is REQUIRED on xs:import, so don't continue.
+ schema.setReferenceable(false);
+ return schema;
+ }
+
+ if(schema.getSchemaLocation() == null){
+ //This is a namespace-only import, no schema document to be retrieved so don't continue.
+
+ /* TODO investigate whether/how to try to resolve the imported namespace to known schema
+ * components from that namespace (e.g. via a URI catalog resolver). Currently, any attempt
+ * to resolve a QName against schema components from this namespace will search ALL
+ * schemas imported from this namespace (see methods in TypesImpl).
+ */
+
+ return schema;
+ }
+
+ //Now try to retrieve the schema import using schemaLocation
+
+ OMElement importedSchemaDoc = null;
+ URI contextURI = null;
+ String schemaLoc = null;
+ URL url = null;
+
+ try{
+ /*
+ * For simple resolvers, we resolve the parent (Description) URI
+ * to be used as the context. This allows for relative locationURIs
+ * to be resolved implicitly - they are considered to be located
+ * relative to the resolved parent. Therefore, relative URIs such as these
+ * need not be listed in the catalog file.
+ */
+
+ /* TODO
+ * OASIS-style catalogs have a convenience notation to define root URIs
+ * thus grouping related URLs together. In this case the context URI here
+ * should be left alone, but the resultant locationURL resolved instead.
+ *
+ * Implement a boolean system property like org.apache.woden.resolver.useRelativeURLs
+ * (set by the resolver ctor). SimpleURIResolver (et al) should set this to true,
+ * OASISCatalogResolver should set to false.
+ */
+ // contextURI = desc.getDocumentBaseURI();
+ contextURI = resolveURI(desc.getDocumentBaseURI());
+ URL contextURL = (contextURI != null) ? contextURI.toURL() : null;
+ schemaLoc = schema.getSchemaLocation().toString();
+ url = StringUtils.getURL(contextURL, schemaLoc);
+
+ }
+ catch (MalformedURLException e) {
+
+ String baseLoc = contextURI != null ? contextURI.toString() : null;
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL502",
+ new Object[] {baseLoc, schemaLoc},
+ ErrorReporter.SEVERITY_ERROR);
+
+ //can't continue schema retrieval with a bad URL.
+ schema.setReferenceable(false);
+ return schema;
+ }
+
+ String schemaURL = url.toString();
+
+ //If the schema has already been imported, reuse it.
+ XmlSchema schemaDef = (XmlSchema)fImportedSchemas.get(schemaURL);
+
+ if(schemaDef == null){
+ //not previously imported, so retrieve it now.
+ try {
+ importedSchemaDoc = OMUtils.getElement(schemaURL);
+ } catch (IOException e4) {
+
+ //schema retrieval failed (e.g. 'not found')
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL504",
+ new Object[] {schemaURL},
+ ErrorReporter.SEVERITY_WARNING,
+ e4);
+
+ //cannot continue without an imported schema
+ schema.setReferenceable(false);
+ return schema;
+ }
+
+ /*
+ * First get the schema element and serialize that into a byte array.
+ * This is used in getting an InputSource which is later used as an argument
+ * to the XMLSchemaCollection object.
+ */
+ String schemaElStr = null;
+ try {
+ schemaElStr = importedSchemaDoc.toStringWithConsume();
+ }
+ catch (XMLStreamException e) {
+ e.printStackTrace();
+ }
+ byte[] schemaElbytes = schemaElStr.getBytes();
+ InputSource schemaSource = new InputSource(new ByteArrayInputStream(schemaElbytes));
+ schemaSource.setSystemId(schemaURL);
+
+ try {
+ XmlSchemaCollection xsc = new XmlSchemaCollection();
+
+ // Plug in the selected woden URI Resolver
+ xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), importEl));
+
+ schemaDef = xsc.read(schemaSource, null);
+ fImportedSchemas.put(schemaURL, schemaDef);
+ }
+ catch (XmlSchemaException e){
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL522",
+ new Object[] {schemaURL},
+ ErrorReporter.SEVERITY_WARNING,
+ e);
+ }
+ }
+ if(schemaDef != null) {
+ schema.setSchemaDefinition(schemaDef);
+ }
+ else {
+ schema.setReferenceable(false);
+ }
+ return schema;
+ }
+
+
+ protected Schema parseSchemaInline(XMLElement schemaElement,
+ DescriptionElement desc)
+ throws WSDLException{
+
+ InlinedSchemaImpl schema = new InlinedSchemaImpl();
+ schema.setId(schemaElement.getAttributeValue(Constants.ATTR_ID));
+ String tns = schemaElement.getAttributeValue(Constants.ATTR_TARGET_NAMESPACE);
+ if(tns != null) {
+ schema.setNamespace(getURI(tns));
+ }
+
+ String baseURI = desc.getDocumentBaseURI() != null ?
+ desc.getDocumentBaseURI().toString() : null;
+
+ XmlSchema schemaDef = null;
+
+ try {
+ OMElement omSchemaElem = (OMElement)schemaElement.getSource();
+ InputSource schemaSource = OMUtils.getInputSource(omSchemaElem);
+ XmlSchemaCollection xsc = new XmlSchemaCollection();
+
+ //Set the baseURI and the namespaces from the DescriptionElement in the XMLSchemaCollection
+ xsc.setBaseUri(baseURI);
+ NamespaceMap namespaces = new NamespaceMap(desc.getNamespaces());
+ xsc.setNamespaceContext(namespaces);
+
+ // Plug in the selected woden URI Resolver
+ xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), schemaElement));
+
+ schemaDef = xsc.read(schemaSource, null);
+ }
+ catch (XmlSchemaException e){
+
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL521",
+ new Object[] {baseURI},
+ ErrorReporter.SEVERITY_WARNING,
+ e);
+ }
+ catch (RuntimeException e)
+ {
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL521",
+ new Object[] {baseURI},
+ ErrorReporter.SEVERITY_ERROR,
+ e);
+ }
+
+ if(schemaDef != null) {
+ schema.setSchemaDefinition(schemaDef);
+ }
+ else {
+ schema.setReferenceable(false);
+ }
+
+ return schema;
+ }
+
+
+ //TODO
+ protected void parseExtensionAttributes(XMLElement domEl,
+ Class wsdlClass,
+ WSDLElement wsdlObj,
+ DescriptionElement desc)
+ 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
+ ///////////////////////////////////////
+
+ //TODO
+ public Description readWSDL(WSDLSource wsdlSource)
+ throws WSDLException {
+ return null;
+ }
+
+
+ //TODO
+ public Description readWSDL(WSDLSource wsdlSource,
+ ErrorHandler errorHandler)
+ throws WSDLException {
+ return null;
+ }
+
+
+ //////////////////////////
+ // HELPER METHODS
+ //////////////////////////
+
+
+ /*
+ * Retrieve a WSDL document by resolving the location URI specified
+ * on a WSDL <import> or <include> element.
+ *
+ * TODO add support for a URL Catalog Resolver
+ */
+ protected DescriptionElement getWSDLFromLocation(String locationURI,
+ DescriptionElement desc,
+ Map wsdlModules)
+ throws WSDLException{
+ DescriptionElement referencedDesc = null;
+ OMElement docEl;
+ URL locationURL = null;
+ URI contextURI = null;
+
+ try{
+ /*
+ * For simple resolvers, we resolve the parent (Description) URI
+ * to be used as the context. This allows for relative locationURIs
+ * to be resolved implicitly - they are considered to be located
+ * relative to the resolved parent. Therefore, relative URIs such as these
+ * need not be listed in the catalog file.
+ */
+
+ /* TODO
+ * OASIS-style catalogs have a convenience notation to define root URIs
+ * thus grouping related URLs together. In this case the context URI here
+ * should be left alone, but the resultant locationURL resolved instead.
+ *
+ * Implement a boolean system property like org.apache.woden.resolver.useRelativeURLs
+ * (set by the resolver ctor). SimpleURIResolver (et al) should set this to true,
+ * OASISCatalogResolver should set to false.
+ */
+ // contextURI = desc.getDocumentBaseURI();
+ contextURI = resolveURI(desc.getDocumentBaseURI());
+ URL contextURL = (contextURI != null) ? contextURI.toURL() : null;
+ locationURL = StringUtils.getURL(contextURL, locationURI);
+ }
+ catch (MalformedURLException e){
+ String baseURI = contextURI != null ? contextURI.toString() : null;
+
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL502",
+ new Object[] {baseURI, locationURI},
+ ErrorReporter.SEVERITY_ERROR);
+
+ //can't continue import with a bad URL.
+ return null;
+ }
+
+ String locationStr = locationURL.toString();
+
+ //Check if WSDL imported or included previously from this location.
+ referencedDesc = (DescriptionElement)wsdlModules.get(locationStr);
+
+ if(referencedDesc == null){
+ // not previously imported or included, so retrieve the WSDL.
+ try {
+ docEl = OMUtils.getElement(locationStr);
+ }
+ catch (IOException e)
+ {
+ // document retrieval failed (e.g. 'not found')
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), // TODO line&col nos.
+ "WSDL503",
+ new Object[] {locationStr},
+ ErrorReporter.SEVERITY_WARNING,
+ e);
+
+ // cannot continue without the referenced document
+ return null;
+ }
+
+ //The referenced document should contain a WSDL <description>
+ if(!OMQNameUtils.matches(Constants.Q_ELEM_DESCRIPTION, docEl)){
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL501",
+ new Object[] {Constants.Q_ELEM_DESCRIPTION,
+ OMQNameUtils.newQName(docEl)},
+ ErrorReporter.SEVERITY_ERROR);
+
+ //cannot continue without a <description> element
+ return null;
+ }
+
+ XMLElement descEl = createXMLElement(docEl);
+
+ referencedDesc = parseDescription(locationStr,
+ descEl,
+ wsdlModules);
+
+ if(!wsdlModules.containsKey(locationStr)){
+ wsdlModules.put(locationStr, referencedDesc);
+ }
+ }
+
+ return referencedDesc;
+ }
+
+ //TODO
+ public WSDLSource createWSDLSource() {
+ return null;
+ }
+
+ protected XMLElement createXMLElement(Object elem) {
+ OMXMLElement omXMLElement = new OMXMLElement(getErrorReporter());
+ omXMLElement.setSource(elem);
+ return omXMLElement;
+
+ }
+
+ protected void parseNamespaceDeclarations(
+ XMLElement xmlElem,
+ WSDLElement wsdlElem)
+ 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();
+ String localPart = namespace.getPrefix();
+ String value = namespace.getNamespaceURI();
+
+ if (!(Constants.ATTR_XMLNS).equals(localPart)){
+ desc.addNamespace(localPart, getURI(value)); //a prefixed namespace
+ }
+ else{
+ desc.addNamespace(null, getURI(value)); //the default namespace
+ }
+ }
+ }
+
}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/OMXMLElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/OMXMLElement.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/OMXMLElement.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/OMXMLElement.java Thu Aug 23 04:01:23 2007
@@ -1,169 +1,169 @@
-/**
+/**
* 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 java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-
-public class OMXMLElement extends BaseXMLElement{
-
- public OMXMLElement(ErrorReporter errorReporter) {
- super(errorReporter);
- }
-
- /*
- * @see org.apache.woden.XMLElement#setSource(java.lang.Object)
- */
- public void setSource(Object elem) {
-
- if(elem instanceof OMElement) {
- fSource = elem;
- }
- else {
- String elemClass = (elem != null
- ? elem.getClass().getName()
- : null);
- String xmlElementClass = this.getClass().getName();
- String msg = fErrorReporter.getFormattedMessage(
- "WSDL019", new Object[] {elemClass, xmlElementClass});
- throw new IllegalArgumentException(msg);
- }
-
- }
-
- /*TODO complete this method if it's added to XMLElement.
- *
- public XMLAttribute[] getAttributes() {
-
- if (fSource instanceof OMElement){
- OMElement elem = (OMElement)fSource;
- List attrs = new Vector();
- Iterator iter = elem.getAllAttributes();
- while (iter.hasNext()){
- //No need to check for xmlns, since AXIOM knows that if it's prefixed
- // with xmlns, that it's not an attribute
- //TODO create an XMLAttribute from iter.next()
- //attrs.add(xmlAttribute);
- }
- }
-
- XMLElement[] array = new XMLElement[attrs.size()];
- attrs.toArray(array);
- return array;
- }
- */
-
- protected String doGetAttributeValue(String attrName) {
- OMElement elem = (OMElement)fSource;
- return elem.getAttributeValue(new QName(attrName));
- }
-
- protected URI doGetNamespaceURI() throws WSDLException {
- OMElement elem = (OMElement)fSource;
- String nsStr = elem.getNamespace().getNamespaceURI();
- URI uri = null;
- try {
- uri = new URI(nsStr);
- } catch (URISyntaxException e) {
- String msg = fErrorReporter.getFormattedMessage(
- "WSDL506",
- new Object[] {nsStr});
- throw new WSDLException(WSDLException.INVALID_WSDL, msg, e);
- }
- return uri;
- }
-
- protected String doGetLocalName() {
- OMElement elem = (OMElement)fSource;
- return elem.getLocalName();
- }
-
- protected QName doGetQName() {
- OMElement elem = (OMElement)fSource;
- return elem.getQName();
- }
-
- protected QName doGetQName(String prefixedValue) throws WSDLException {
- OMElement elem = (OMElement)fSource;
- int index = prefixedValue.indexOf(':');
- String prefix = (index != -1)
- ? prefixedValue.substring(0, index)
- : null;
- String localPart = prefixedValue.substring(index + 1);
- OMNamespace OMns = elem.findNamespaceURI(prefix);
- String namespaceURI = OMns != null ? OMns.getNamespaceURI() : null;
-
- if(prefix != null && namespaceURI == null) {
- String faultCode = WSDLException.UNBOUND_PREFIX;
- String msg = fErrorReporter.getFormattedMessage(
- "WSDL513",
- new Object[] {prefixedValue, elem.getQName()});
- WSDLException wsdlExc = new WSDLException(
- faultCode,
- msg);
- //TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
- throw wsdlExc;
- }
-
- return new QName(namespaceURI, localPart, (prefix != null ? prefix : ""));
- }
-
- protected XMLElement doGetFirstChildElement() {
- OMElement elem = (OMElement)fSource;
- OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
- omXMLElement.setSource(elem.getFirstElement());
- return omXMLElement;
- }
-
- protected XMLElement doGetNextSiblingElement() {
- OMElement elem = (OMElement)fSource;
- OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
- omXMLElement.setSource(elem.getNextOMSibling());
- return omXMLElement;
- }
-
- protected XMLElement[] doGetChildElements() {
-
- OMElement elem = (OMElement)fSource;
- Iterator elems = elem.getChildElements();
- List children = new Vector();
- Object next = elems.next();
- while(next != null)
- {
- OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
- omXMLElement.setSource(next);
- children.add(omXMLElement);
- next = elems.next();
- }
- XMLElement[] array = new XMLElement[children.size()];
- children.toArray(array);
- return array;
- }
-
-}
+ *
+ * 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 java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+
+public class OMXMLElement extends BaseXMLElement{
+
+ public OMXMLElement(ErrorReporter errorReporter) {
+ super(errorReporter);
+ }
+
+ /*
+ * @see org.apache.woden.XMLElement#setSource(java.lang.Object)
+ */
+ public void setSource(Object elem) {
+
+ if(elem instanceof OMElement) {
+ fSource = elem;
+ }
+ else {
+ String elemClass = (elem != null
+ ? elem.getClass().getName()
+ : null);
+ String xmlElementClass = this.getClass().getName();
+ String msg = fErrorReporter.getFormattedMessage(
+ "WSDL019", new Object[] {elemClass, xmlElementClass});
+ throw new IllegalArgumentException(msg);
+ }
+
+ }
+
+ /*TODO complete this method if it's added to XMLElement.
+ *
+ public XMLAttribute[] getAttributes() {
+
+ if (fSource instanceof OMElement){
+ OMElement elem = (OMElement)fSource;
+ List attrs = new Vector();
+ Iterator iter = elem.getAllAttributes();
+ while (iter.hasNext()){
+ //No need to check for xmlns, since AXIOM knows that if it's prefixed
+ // with xmlns, that it's not an attribute
+ //TODO create an XMLAttribute from iter.next()
+ //attrs.add(xmlAttribute);
+ }
+ }
+
+ XMLElement[] array = new XMLElement[attrs.size()];
+ attrs.toArray(array);
+ return array;
+ }
+ */
+
+ protected String doGetAttributeValue(String attrName) {
+ OMElement elem = (OMElement)fSource;
+ return elem.getAttributeValue(new QName(attrName));
+ }
+
+ protected URI doGetNamespaceURI() throws WSDLException {
+ OMElement elem = (OMElement)fSource;
+ String nsStr = elem.getNamespace().getNamespaceURI();
+ URI uri = null;
+ try {
+ uri = new URI(nsStr);
+ } catch (URISyntaxException e) {
+ String msg = fErrorReporter.getFormattedMessage(
+ "WSDL506",
+ new Object[] {nsStr});
+ throw new WSDLException(WSDLException.INVALID_WSDL, msg, e);
+ }
+ return uri;
+ }
+
+ protected String doGetLocalName() {
+ OMElement elem = (OMElement)fSource;
+ return elem.getLocalName();
+ }
+
+ protected QName doGetQName() {
+ OMElement elem = (OMElement)fSource;
+ return elem.getQName();
+ }
+
+ protected QName doGetQName(String prefixedValue) throws WSDLException {
+ OMElement elem = (OMElement)fSource;
+ int index = prefixedValue.indexOf(':');
+ String prefix = (index != -1)
+ ? prefixedValue.substring(0, index)
+ : null;
+ String localPart = prefixedValue.substring(index + 1);
+ OMNamespace OMns = elem.findNamespaceURI(prefix);
+ String namespaceURI = OMns != null ? OMns.getNamespaceURI() : null;
+
+ if(prefix != null && namespaceURI == null) {
+ String faultCode = WSDLException.UNBOUND_PREFIX;
+ String msg = fErrorReporter.getFormattedMessage(
+ "WSDL513",
+ new Object[] {prefixedValue, elem.getQName()});
+ WSDLException wsdlExc = new WSDLException(
+ faultCode,
+ msg);
+ //TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+ throw wsdlExc;
+ }
+
+ return new QName(namespaceURI, localPart, (prefix != null ? prefix : ""));
+ }
+
+ protected XMLElement doGetFirstChildElement() {
+ OMElement elem = (OMElement)fSource;
+ OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+ omXMLElement.setSource(elem.getFirstElement());
+ return omXMLElement;
+ }
+
+ protected XMLElement doGetNextSiblingElement() {
+ OMElement elem = (OMElement)fSource;
+ OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+ omXMLElement.setSource(elem.getNextOMSibling());
+ return omXMLElement;
+ }
+
+ protected XMLElement[] doGetChildElements() {
+
+ OMElement elem = (OMElement)fSource;
+ Iterator elems = elem.getChildElements();
+ List children = new Vector();
+ Object next = elems.next();
+ while(next != null)
+ {
+ OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+ omXMLElement.setSource(next);
+ children.add(omXMLElement);
+ next = elems.next();
+ }
+ XMLElement[] array = new XMLElement[children.size()];
+ children.toArray(array);
+ return array;
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/OMXMLElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/ReaderFeatures.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/ReaderFeatures.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/ReaderFeatures.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/ReaderFeatures.java Thu Aug 23 04:01:23 2007
@@ -1,84 +1,84 @@
-/**
+/**
* 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 java.util.Hashtable;
-
-import org.apache.woden.WSDLReader;
-
-/**
- * This class contains all supported Woden reader features and stores
- * their values for individual parser configurations.
- *
- * TODO: determine the required features (e.g. org.apache.woden.verbose) and
- * create an ID for each value.
- */
-public class ReaderFeatures
-{
-
- /**
- * This hashtable contains the values for the features.
- */
- protected Hashtable values = new Hashtable();
-
- private Boolean on = new Boolean(true);
- private Boolean off = new Boolean(false);
-
- public ReaderFeatures()
- {
- values.put(WSDLReader.FEATURE_VALIDATION, off);
- }
-
- /**
- * Get the value for the given feature.
- * @param featureId The ID of the feature for which the value is requested.
- * @return true if the feature is enabled, false otherwise.
- * @throws IllegalArgumentException if the feature is not supported.
- */
- public boolean getValue(String featureId) throws IllegalArgumentException
- {
- Boolean value = (Boolean)values.get(featureId);
- if(value == null)
- {
- throw new IllegalArgumentException("The feature " + featureId + " is not supported.");
- }
- return value.booleanValue();
- }
-
- /**
- * Set the value of the given feature
- * @param featureId The ID of the feature to set.
- * @param value The value to set for the feature.
- * @throws IllegalArgumentException if the feature is not supported.
- */
- public void setValue(String featureId, boolean value) throws IllegalArgumentException
- {
- // Check if the feature is supported.
- if(!values.containsKey(featureId))
- {
- throw new IllegalArgumentException("The feature " + featureId + " is not supported.");
- }
- if(value)
- {
- values.put(featureId, on);
- }
- else
- {
- values.put(featureId, off);
- }
- }
-}
+ *
+ * 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 java.util.Hashtable;
+
+import org.apache.woden.WSDLReader;
+
+/**
+ * This class contains all supported Woden reader features and stores
+ * their values for individual parser configurations.
+ *
+ * TODO: determine the required features (e.g. org.apache.woden.verbose) and
+ * create an ID for each value.
+ */
+public class ReaderFeatures
+{
+
+ /**
+ * This hashtable contains the values for the features.
+ */
+ protected Hashtable values = new Hashtable();
+
+ private Boolean on = new Boolean(true);
+ private Boolean off = new Boolean(false);
+
+ public ReaderFeatures()
+ {
+ values.put(WSDLReader.FEATURE_VALIDATION, off);
+ }
+
+ /**
+ * Get the value for the given feature.
+ * @param featureId The ID of the feature for which the value is requested.
+ * @return true if the feature is enabled, false otherwise.
+ * @throws IllegalArgumentException if the feature is not supported.
+ */
+ public boolean getValue(String featureId) throws IllegalArgumentException
+ {
+ Boolean value = (Boolean)values.get(featureId);
+ if(value == null)
+ {
+ throw new IllegalArgumentException("The feature " + featureId + " is not supported.");
+ }
+ return value.booleanValue();
+ }
+
+ /**
+ * Set the value of the given feature
+ * @param featureId The ID of the feature to set.
+ * @param value The value to set for the feature.
+ * @throws IllegalArgumentException if the feature is not supported.
+ */
+ public void setValue(String featureId, boolean value) throws IllegalArgumentException
+ {
+ // Check if the feature is supported.
+ if(!values.containsKey(featureId))
+ {
+ throw new IllegalArgumentException("The feature " + featureId + " is not supported.");
+ }
+ if(value)
+ {
+ values.put(featureId, on);
+ }
+ else
+ {
+ values.put(featureId, off);
+ }
+ }
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/ReaderFeatures.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java Thu Aug 23 04:01:23 2007
@@ -1,53 +1,53 @@
-/**
- * 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.WSDLFactory;
-import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
-
-/**
- * A container of objects shared across Woden within the context of a WSDLFactory.
- *
- * TODO may need to be API, if so interface is WSDLContext, class name is WSDLContextImpl, add getters and make variables private
- * TODO check for use cases that break the WSDLFactory context concept (ie WSDLReader.setFactoryImplName).
- * TODO decide if anything else should be kept here (e.g. woden feats & props, Description factory)
- *
- * @author John Kaputin (jkaputin@apache.org)
- */
-public class WSDLContext {
- final public WSDLFactory wsdlFactory;
- final public ErrorReporter errorReporter;
- private ExtensionRegistry extensionRegistry;
-
- //package private ctor - should only be created by WSDLFactory impl class
- WSDLContext(WSDLFactory wsdlFactory,
- ErrorReporter errorReporter) {
- 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;
- }
-}
+/**
+ * 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.WSDLFactory;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+
+/**
+ * A container of objects shared across Woden within the context of a WSDLFactory.
+ *
+ * TODO may need to be API, if so interface is WSDLContext, class name is WSDLContextImpl, add getters and make variables private
+ * TODO check for use cases that break the WSDLFactory context concept (ie WSDLReader.setFactoryImplName).
+ * TODO decide if anything else should be kept here (e.g. woden feats & props, Description factory)
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class WSDLContext {
+ final public WSDLFactory wsdlFactory;
+ final public ErrorReporter errorReporter;
+ private ExtensionRegistry extensionRegistry;
+
+ //package private ctor - should only be created by WSDLFactory impl class
+ WSDLContext(WSDLFactory wsdlFactory,
+ ErrorReporter errorReporter) {
+ 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;
+ }
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/DOMSchemaResolverAdapter.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/DOMSchemaResolverAdapter.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/DOMSchemaResolverAdapter.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/DOMSchemaResolverAdapter.java Thu Aug 23 04:01:23 2007
@@ -1,91 +1,91 @@
-/**
- * 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.resolver;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.woden.XMLElement;
-import org.apache.woden.resolver.URIResolver;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Class that adds DOM specific behaviour to the SchemaResolverAdapter class.
- *
- * TODO consider some approach other than inheritance as part of a broader consideration
- * of resolving imports and fragids.
- *
- * @author John Kaputin (jkaputin@apache.org)
- *
- */
-
-public class DOMSchemaResolverAdapter extends SchemaResolverAdapter {
-
- public DOMSchemaResolverAdapter(URIResolver actualResolver, XMLElement schemaElement) {
- super(actualResolver, schemaElement);
- }
-
- protected InputStream resolveFragId(String fragId) {
- Element contextEl = (Element)fContextElement.getSource();
- Document doc = contextEl.getOwnerDocument();
- String id = fragId.substring(1);
- Element schemaEl = doc.getElementById(id);
-
- if(schemaEl == null) {
- //the fragid does not identify any element
- //TODO suitable error message
- return null;
- }
-
- String localName = schemaEl.getLocalName();
- if(!localName.equals("schema")) {
- //the fragid does not point to a schema element
- //TODO suitable error message
- return null;
- }
-
- String prefix = schemaEl.getPrefix();
- if(prefix != null) {
- //check if we need to add a schema NS declaration
- String nsUri = schemaEl.getNamespaceURI();
- String schemaNSDecl = "xmlns:" + prefix;
- boolean isSchemaNSDeclared = schemaEl.hasAttribute(schemaNSDecl);
- if(!isSchemaNSDeclared) {
- schemaEl.setAttribute(schemaNSDecl, nsUri);
- }
- }
-
- //TODO need to check for other prefixes requiring NS decls to be added to the schema element
-
- OutputFormat format = new OutputFormat(doc);
- ByteArrayOutputStream oStream = new ByteArrayOutputStream();
- XMLSerializer serializer = new XMLSerializer(oStream, format);
- try {
- serializer.serialize(schemaEl);
- } catch (IOException e) {
- // TODO this conforms to parent, but needs an error message via ErrorReporter and maybe it should be handled differently?
- throw new RuntimeException(e);
- }
- ByteArrayInputStream iStream = new ByteArrayInputStream(oStream.toByteArray());
- return iStream;
- }
-}
+/**
+ * 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.resolver;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.woden.XMLElement;
+import org.apache.woden.resolver.URIResolver;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Class that adds DOM specific behaviour to the SchemaResolverAdapter class.
+ *
+ * TODO consider some approach other than inheritance as part of a broader consideration
+ * of resolving imports and fragids.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ *
+ */
+
+public class DOMSchemaResolverAdapter extends SchemaResolverAdapter {
+
+ public DOMSchemaResolverAdapter(URIResolver actualResolver, XMLElement schemaElement) {
+ super(actualResolver, schemaElement);
+ }
+
+ protected InputStream resolveFragId(String fragId) {
+ Element contextEl = (Element)fContextElement.getSource();
+ Document doc = contextEl.getOwnerDocument();
+ String id = fragId.substring(1);
+ Element schemaEl = doc.getElementById(id);
+
+ if(schemaEl == null) {
+ //the fragid does not identify any element
+ //TODO suitable error message
+ return null;
+ }
+
+ String localName = schemaEl.getLocalName();
+ if(!localName.equals("schema")) {
+ //the fragid does not point to a schema element
+ //TODO suitable error message
+ return null;
+ }
+
+ String prefix = schemaEl.getPrefix();
+ if(prefix != null) {
+ //check if we need to add a schema NS declaration
+ String nsUri = schemaEl.getNamespaceURI();
+ String schemaNSDecl = "xmlns:" + prefix;
+ boolean isSchemaNSDeclared = schemaEl.hasAttribute(schemaNSDecl);
+ if(!isSchemaNSDeclared) {
+ schemaEl.setAttribute(schemaNSDecl, nsUri);
+ }
+ }
+
+ //TODO need to check for other prefixes requiring NS decls to be added to the schema element
+
+ OutputFormat format = new OutputFormat(doc);
+ ByteArrayOutputStream oStream = new ByteArrayOutputStream();
+ XMLSerializer serializer = new XMLSerializer(oStream, format);
+ try {
+ serializer.serialize(schemaEl);
+ } catch (IOException e) {
+ // TODO this conforms to parent, but needs an error message via ErrorReporter and maybe it should be handled differently?
+ throw new RuntimeException(e);
+ }
+ ByteArrayInputStream iStream = new ByteArrayInputStream(oStream.toByteArray());
+ return iStream;
+ }
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/DOMSchemaResolverAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/EntityResolverAdapter.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/EntityResolverAdapter.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/EntityResolverAdapter.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/EntityResolverAdapter.java Thu Aug 23 04:01:23 2007
@@ -1,72 +1,72 @@
-/**
+/**
* 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.
- *
- * @author Graham Turrell
- */
-
-package org.apache.woden.internal.resolver;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class EntityResolverAdapter implements EntityResolver {
-
- private org.apache.woden.resolver.URIResolver fActualResolver;
-
- public EntityResolverAdapter(org.apache.woden.resolver.URIResolver actualResolver) {
- fActualResolver = actualResolver;
- }
-
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
-
- /* build the URI from args
- *
- */
- URI uri = null;
- try
- {
- // dumb placeholder:
- uri = new URI(systemId);
- }
- catch (URISyntaxException e)
- {
- throw new RuntimeException(e);
- }
-
- /* resolve with target resolver
- *
- */
- URI resolved = null;
- try
- {
- resolved = fActualResolver.resolveURI(uri);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
-
- // dumb placeholder:
- return (resolved == null)? null : new InputSource(resolved.toString());
- }
-
-}
+ *
+ * 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.
+ *
+ * @author Graham Turrell
+ */
+
+package org.apache.woden.internal.resolver;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class EntityResolverAdapter implements EntityResolver {
+
+ private org.apache.woden.resolver.URIResolver fActualResolver;
+
+ public EntityResolverAdapter(org.apache.woden.resolver.URIResolver actualResolver) {
+ fActualResolver = actualResolver;
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ /* build the URI from args
+ *
+ */
+ URI uri = null;
+ try
+ {
+ // dumb placeholder:
+ uri = new URI(systemId);
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ /* resolve with target resolver
+ *
+ */
+ URI resolved = null;
+ try
+ {
+ resolved = fActualResolver.resolveURI(uri);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ // dumb placeholder:
+ return (resolved == null)? null : new InputSource(resolved.toString());
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/EntityResolverAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/OMSchemaResolverAdapter.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/OMSchemaResolverAdapter.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/OMSchemaResolverAdapter.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/OMSchemaResolverAdapter.java Thu Aug 23 04:01:23 2007
@@ -1,82 +1,82 @@
-/**
- * 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.resolver;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Iterator;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.schema.SchemaConstants;
-import org.apache.woden.resolver.URIResolver;
-
-/**
- * Class that adds OM specific behaviour to the SchemaResolverAdapter class.
- *
- * TODO consider some approach other than inheritance as part of a broader consideration
- * of resolving imports and fragids.
- *
- * @author John Kaputin (jkaputin@apache.org)
- *
- */
-
-public class OMSchemaResolverAdapter extends SchemaResolverAdapter {
-
- public OMSchemaResolverAdapter(URIResolver actualResolver, XMLElement schemaElement) {
- super(actualResolver, schemaElement);
- }
-
- protected InputStream resolveFragId(String fragId) {
-
- String id = fragId.substring(1);
-
- OMElement contextEl = (OMElement)fContextElement.getSource();
- OMElement typesEl = (OMElement)contextEl.getParent();
- Iterator inlineSchemas = typesEl.
- getChildrenWithName(SchemaConstants.Q_ELEM_XSD_2001);
- OMElement identifiedSchema = null;
- String schemaId;
- while(inlineSchemas.hasNext()) {
- OMElement schema = (OMElement)inlineSchemas.next();
- schemaId = schema.getAttributeValue(SchemaConstants.Q_ATTR_ID);
- if(schemaId != null && schemaId.equals(id)) {
- identifiedSchema = schema;
- break;
- }
- }
-
- if(identifiedSchema == null) {
- //the fragid does not identify any element
- //TODO suitable error message
- return null;
- }
-
- String schemaString = null;
- try {
- schemaString = identifiedSchema.toStringWithConsume();
- } catch (XMLStreamException e) {
- // TODO this conforms to parent, but needs an error message via ErrorReporter and maybe it should be handled differently?
- throw new RuntimeException(e);
- }
- byte[] schemaBytes = schemaString.getBytes();
- InputStream iStream = new ByteArrayInputStream(schemaBytes);
- return iStream;
- }
-}
+/**
+ * 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.resolver;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.schema.SchemaConstants;
+import org.apache.woden.resolver.URIResolver;
+
+/**
+ * Class that adds OM specific behaviour to the SchemaResolverAdapter class.
+ *
+ * TODO consider some approach other than inheritance as part of a broader consideration
+ * of resolving imports and fragids.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ *
+ */
+
+public class OMSchemaResolverAdapter extends SchemaResolverAdapter {
+
+ public OMSchemaResolverAdapter(URIResolver actualResolver, XMLElement schemaElement) {
+ super(actualResolver, schemaElement);
+ }
+
+ protected InputStream resolveFragId(String fragId) {
+
+ String id = fragId.substring(1);
+
+ OMElement contextEl = (OMElement)fContextElement.getSource();
+ OMElement typesEl = (OMElement)contextEl.getParent();
+ Iterator inlineSchemas = typesEl.
+ getChildrenWithName(SchemaConstants.Q_ELEM_XSD_2001);
+ OMElement identifiedSchema = null;
+ String schemaId;
+ while(inlineSchemas.hasNext()) {
+ OMElement schema = (OMElement)inlineSchemas.next();
+ schemaId = schema.getAttributeValue(SchemaConstants.Q_ATTR_ID);
+ if(schemaId != null && schemaId.equals(id)) {
+ identifiedSchema = schema;
+ break;
+ }
+ }
+
+ if(identifiedSchema == null) {
+ //the fragid does not identify any element
+ //TODO suitable error message
+ return null;
+ }
+
+ String schemaString = null;
+ try {
+ schemaString = identifiedSchema.toStringWithConsume();
+ } catch (XMLStreamException e) {
+ // TODO this conforms to parent, but needs an error message via ErrorReporter and maybe it should be handled differently?
+ throw new RuntimeException(e);
+ }
+ byte[] schemaBytes = schemaString.getBytes();
+ InputStream iStream = new ByteArrayInputStream(schemaBytes);
+ return iStream;
+ }
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/resolver/OMSchemaResolverAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org