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 2005/09/29 19:22:20 UTC
svn commit: r292485 -
/incubator/woden/java/src/org/apache/woden/internal/util/ComponentModelBuilder.java
Author: jkaputin
Date: Thu Sep 29 10:22:14 2005
New Revision: 292485
URL: http://svn.apache.org/viewcvs?rev=292485&view=rev
Log:
Work in progress on building the component model from
the xml representation. ElementDeclarations in progress.
Added:
incubator/woden/java/src/org/apache/woden/internal/util/ComponentModelBuilder.java
Added: incubator/woden/java/src/org/apache/woden/internal/util/ComponentModelBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/util/ComponentModelBuilder.java?rev=292485&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/util/ComponentModelBuilder.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/util/ComponentModelBuilder.java Thu Sep 29 10:22:14 2005
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2005 Apached Software Foundation
+ *
+ * Licensed 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.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.schema.Schema;
+import org.apache.woden.schema.SchemaImport;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSModel;
+import org.apache.xerces.xs.XSNamedMap;
+
+/**
+ * Converts the xml representation of a WSDL document to the WSDL
+ * component model representation defined by the W3C WSDL 2.0 spec.
+ * The xml model is contained within a DescriptionElement object.
+ * The component model is contained within a Description object.
+ *
+ * @author jkaputin@apache.org
+ */
+public class ComponentModelBuilder {
+
+ private DescriptionElement fDescElement;
+ private Description fDescComponent;
+
+ //TODO support for other (non-Schema) type systems
+
+ //Collection of Schema objects
+ private List fInScopeSchemas = new Vector();
+
+ //Collection of schema target namespace Strings
+ private List fInScopeSchemaNamespaces = new Vector();
+
+ /*
+ * Takes a DescriptionElement and converts its WSDL XML model
+ * to a WSDL component model returned as a Description.
+ */
+ public Description xmlToComponent(DescriptionElement descElement)
+ {
+ fDescElement = descElement;
+ fDescComponent = new DescriptionImpl();
+
+ //TODO conversion logic follows
+
+ collectImportedWsdl();
+ collectInScopeSchemas();
+ buildElementDeclarations();
+ buildTypeDefinitions();
+
+ return fDescComponent;
+ }
+
+ /*
+ * Navigate the wsdl imports and collect all imported DescriptionElements.
+ */
+ private void collectImportedWsdl()
+ {
+ }
+
+ /*
+ * Navigate the inlined and imported schemas and collect all schemas and
+ * schema namespaces that are in scope (i.e. visible by the WSDL according
+ * to the W3C WSDL 2.0 spec).
+ */
+ private void collectInScopeSchemas()
+ {
+ //TODO schemas inlined in wsdl:imported docs
+
+ //TODO ensure only schemas and schema namespaces in scope per
+ //W3C WSDL 2.0 spec are collected.
+
+ TypesElement types = fDescElement.getTypesElement();
+
+ Schema s = null;
+ SchemaImport si = null;
+
+ //collect all inlined schemas
+ Collection schemaArrays = types.getSchemas().values();
+ Iterator sIterator = schemaArrays.iterator();
+ while(sIterator.hasNext())
+ {
+ Schema[] schemaArray = (Schema[])sIterator.next();
+ for(int i=0; i < schemaArray.length; i++)
+ {
+ s = schemaArray[i];
+ fInScopeSchemas.add(s);
+ fInScopeSchemaNamespaces.add(s.getTargetNamespace());
+ }
+ }
+
+ //collect all imported schemas
+ Collection schemaImportArrays = types.getSchemaImports().values();
+ Iterator siIterator = schemaImportArrays.iterator();
+ while(siIterator.hasNext())
+ {
+ SchemaImport[] schemaImportArray = (SchemaImport[])siIterator.next();
+ for(int i=0; i < schemaImportArray.length; i++)
+ {
+ si = schemaImportArray[i];
+ fInScopeSchemaNamespaces.add(si.getNamespace());
+ s = si.getSchema();
+ if(s != null) {
+ fInScopeSchemas.add(s);
+ }
+ }
+ }
+
+ //We now have a 'flattened' collection of all inlined and imported
+ //schemas (i.e. as XSModel objects) and a collection of the inlined
+ //and imported schema namespace Strings (i.e. the in-scope namespaces).
+ //These can now be used to extract the in-scope element declarations
+ //and type definitions.
+
+ }
+
+ /*
+ * Extract from the collections of in-scope schemas and schema namespaces
+ * the element declarations.
+ */
+ private void buildElementDeclarations()
+ {
+ Schema schema = null;
+ XSModel xsModel = null;
+ List elementDeclarations = new Vector();
+
+ Iterator i = fInScopeSchemas.iterator();
+ while(i.hasNext())
+ {
+ schema = (Schema)i.next();
+ xsModel = schema.getSchemaContent();
+
+ XSNamedMap xsNamedMap =
+ xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
+
+ //TODO w.i.p.
+ }
+
+ }
+
+ /*
+ * Extract from the collections of in-scope schemas and schema namespaces
+ * the type definitions.
+ */
+
+ private void buildTypeDefinitions()
+ {
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org