Author: ajith
Date: Sat Mar 22 01:46:10 2008
New Revision: 639964
URL: http://svn.apache.org/viewvc?rev=639964&view=rev
Log:
integrating the branch changes with the trunk. Some files (XmlSchema,
SchemaBuilder) did not show the diff right in eclipse so I had to manually see
what is different so not sure whether Ive missed something
Added:
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/filter.properties
webservices/commons/trunk/modules/XmlSchema/src/main/resources/
webservices/commons/trunk/modules/XmlSchema/src/main/resources/META-INF/
webservices/commons/trunk/modules/XmlSchema/src/main/resources/META-INF/LICENSE.txt
webservices/commons/trunk/modules/XmlSchema/src/main/resources/META-INF/NOTICE.txt
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/EnumValueTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RecursiveImportTest.java
Removed:
webservices/commons/trunk/modules/XmlSchema/LICENSE.txt
webservices/commons/trunk/modules/XmlSchema/NOTICE.txt
Modified:
webservices/commons/trunk/modules/XmlSchema/README.txt
webservices/commons/trunk/modules/XmlSchema/RELEASE-NOTE.txt
webservices/commons/trunk/modules/XmlSchema/pom.xml
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/bin.xml
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/doc.xml
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/src.xml
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaElement.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaException.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaObjectCollection.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaType.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java
webservices/commons/trunk/modules/XmlSchema/src/site/xdoc/download.xml
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AppInfoMarkupTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ChoiceTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ComplexContentRestrictionTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ConstraintsTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/EncodingTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/FacetsTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/GroupTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ListTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/NamespaceContextTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SequenceTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ext/PlainExtensionSerializerTest.java
Modified: webservices/commons/trunk/modules/XmlSchema/README.txt
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/README.txt?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/README.txt (original)
+++ webservices/commons/trunk/modules/XmlSchema/README.txt Sat Mar 22 01:46:10
2008
@@ -1,9 +1,9 @@
====================================
- XMLSchema Release Notes
+ XMLSchema Release Notes - Version ${version}
====================================
XMLSchema is a lightweight schema object model that can be used to manipulate
and
-generate XML schema representations. It has very few external dependancies and
can
+generate XML schema representations. It has very few external dependencies and
can
be easily integrated into an existing project.
You are welcome to kick the tires and get XMLSchema on the move. If you like
to
Modified: webservices/commons/trunk/modules/XmlSchema/RELEASE-NOTE.txt
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/RELEASE-NOTE.txt?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/RELEASE-NOTE.txt (original)
+++ webservices/commons/trunk/modules/XmlSchema/RELEASE-NOTE.txt Sat Mar 22
01:46:10 2008
@@ -1,13 +1,13 @@
====================================
- XMLSchema 1.3.2 Release Notes
+ XMLSchema ${version} Release Notes
====================================
-This is the release of XMLSchema 1.3.2 of Apache WS-Commons. This release
includes
+This is the release of XMLSchema ${version} of Apache WS-Commons. This release
includes
numerous bug fixes and a new feature addition that enables users to register
extension types with the schema parser.
XMLSchema is a lightweight schema object model that can be used to manipulate
-and generate XML schema representations. It has no external dependancies
+and generate XML schema representations. It has no external dependencies
and can be easily integrated into an existing project.
You are welcome to kick the tires and get XMLSchema on the move. If you like
@@ -15,6 +15,14 @@
submitting improvements to the documentation, and reporting bugs are always
welcome.
+Major Changes since the last release
+
+ * The behavior of the getElementByName(QName name) and getTypeByName(QName
name) has
+ changed. Now this method triggers a search in the complete schema tree
(including imported and
+ included schemas) for the specified type.
+ * Two new methods have been added etElementByName(String name) and
getTypeByName(String name) which
+ would perform the search only in the current schema.
+
Thanks for your interest in XMLSchema!
- The XMLSchema Development Team
Modified: webservices/commons/trunk/modules/XmlSchema/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/pom.xml?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/pom.xml (original)
+++ webservices/commons/trunk/modules/XmlSchema/pom.xml Sat Mar 22 01:46:10 2008
@@ -26,7 +26,7 @@
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
<name>XmlSchema</name>
- <version>SNAPSHOT</version>
+ <version>SNASHOT</version>
<description>Commons XMLSchema is a light weight schema object model that
can be used to manipualte or
generate a schema. It has a clean, easy to use API and can easily be
integrated into an existing project
since it has almost no dependancies on third party
libraries.</description>
@@ -199,9 +199,25 @@
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
- </organization>
-
+ </organization>
<build>
+
+
+ <!-- this entry here is for the assembly plugin- For some reason
+ the assembly plugin cannot override the filter properties
(as explained
+ in the docs) and also does not inherit the maven
standard properties. This
+ is the one that points to a seperare filter props file -->
+ <filters>
+ <filter>src/main/assembly/filter.properties</filter>
+ </filters>
+
+ <!-- adding relevant resources to the zip files -->
+ <resources>
+ <resource>
+ <directory>src/main/resources/META-INF</directory>
+ </resource>
+ </resources>
+
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
@@ -269,7 +285,7 @@
</execution>
</executions>
</plugin>
- <plugin>
+ <plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagBase>https://svn.apache.org/repos/asf/webservices/commons/tags/XmlSchema</tagBase>
@@ -283,6 +299,24 @@
</configuration>
</plugin>
<plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!--
+ Required to run the TestW3CSchemaBucket test
+ <version>2.3-SNAPSHOT</version>
+ -->
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <!-- Fails in about half of the tests
+
<include>tests/w3c/TestW3CSchemaBucket.java</include>
+ -->
+ </includes>
+ <excludes>
+ <exclude>tests/w3c/SchemaTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
@@ -306,6 +340,7 @@
<attach>true</attach>
</configuration>
</plugin>
+
</plugins>
</build>
<profiles>
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/assembly/bin.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/assembly/bin.xml?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/assembly/bin.xml
(original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/assembly/bin.xml Sat
Mar 22 01:46:10 2008
@@ -27,7 +27,13 @@
<fileSet>
<includes>
<include>*.txt</include>
- </includes>
+ </includes>
+ <!-- Note that we exclude these txt files and later
copy them with
+ filteres -->
+ <excludes>
+ <exclude>README.txt</exclude>
+ <exclude>RELEASE-NOTE.txt</exclude>
+ </excludes>
</fileSet>
<fileSet>
<directory>target</directory>
@@ -40,11 +46,22 @@
<exclude>*-sources.jar</exclude>
</excludes>
</fileSet>
- </fileSets>
+ </fileSets>
+ <files>
+ <file>
+ <source>README.txt</source>
+ <outputDirectory>/</outputDirectory>
+ <filtered>true</filtered>
+ </file>
+ <file>
+ <source>RELEASE-NOTE.txt</source>
+ <outputDirectory>/</outputDirectory>
+ <filtered>true</filtered>
+ </file>
+ </files>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
-
</dependencySet>
</dependencySets>
</assembly>
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/assembly/doc.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/assembly/doc.xml?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/assembly/doc.xml
(original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/assembly/doc.xml Sat
Mar 22 01:46:10 2008
@@ -23,4 +23,11 @@
<format>zip</format>
</formats>
<includeSiteDirectory>true</includeSiteDirectory>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>*.txt</include>
+ </includes>
+ </fileSet>
+ </fileSets>
</assembly>
Added:
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/filter.properties
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/assembly/filter.properties?rev=639964&view=auto
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/filter.properties
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/assembly/filter.properties
Sat Mar 22 01:46:10 2008
@@ -0,0 +1,25 @@
+#
+# ~ 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.
+#
+# This entry here is for the assembly plugin- For some reason
+# the assembly plugin cannot override the filter properties (as explained
+# in the docs) and also does not inherit the maven standard properties. This
+# is the one that points to a separate filter props file
+#
+
+version = 1.4
\ No newline at end of file
Modified: webservices/commons/trunk/modules/XmlSchema/src/main/assembly/src.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/assembly/src.xml?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/assembly/src.xml
(original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/assembly/src.xml Sat
Mar 22 01:46:10 2008
@@ -28,15 +28,28 @@
<include>*.txt</include>
<include>*.xml</include>
<include>*.properties</include>
- <!--<include>.classpath</include>-->
- <!--<include>.project</include>-->
- </includes>
+ </includes>
+ <!-- Note that we exclude these txt files and later copy them with
+ filteres -->
+ <excludes>
+ <exclude>README.txt</exclude>
+ <exclude>RELEASE-NOTE.txt</exclude>
+ </excludes>
</fileSet>
- <!--<fileSet>-->
- <!--<directory>.settings</directory>-->
- <!--</fileSet>-->
- <fileSet>
+ <fileSet>
<directory>src</directory>
</fileSet>
- </fileSets>
+ </fileSets>
+ <files>
+ <file>
+ <source>README.txt</source>
+ <outputDirectory>/</outputDirectory>
+ <filtered>true</filtered>
+ </file>
+ <file>
+ <source>RELEASE-NOTE.txt</source>
+ <outputDirectory>/</outputDirectory>
+ <filtered>true</filtered>
+ </file>
+ </files>
</assembly>
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
Sat Mar 22 01:46:10 2008
@@ -69,7 +69,7 @@
this.extReg = collection.getExtReg();
}
- schema = new XmlSchema(collection);
+ schema = new XmlSchema();
}
/**
@@ -99,6 +99,9 @@
schema.logicalTargetNamespace, uri);
if (!collection.containsSchema(schemaKey)) {
collection.addSchema(schemaKey, schema);
+ schema.parent = collection; // establish parentage now.
+ } else {
+ throw new XmlSchemaException("Schema name conflict in
collection. Namespace: " + schema.logicalTargetNamespace);
}
schema.setElementFormDefault(this.getFormDefault(schemaEl,
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
Sat Mar 22 01:46:10 2008
@@ -24,6 +24,11 @@
public class ValidationEvent extends EventObject {
/**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
* Creates new ValidationEvent
*/
public ValidationEvent(Object source) {
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java?rev=639964&r1=639963&r2=639964&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
Sat Mar 22 01:46:10 2008
@@ -1,557 +1,589 @@
-/*
- * 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.ws.commons.schema;
-
-import org.apache.ws.commons.schema.constants.Constants;
-import org.apache.ws.commons.schema.utils.NamespaceContextOwner;
-import org.apache.ws.commons.schema.utils.NamespacePrefixList;
-import org.w3c.dom.Document;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.*;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Stack;
-
-
-/**
- * Contains the definition of a schema. All XML Schema definition language
(XSD)
- * elements are children of the schema element. Represents the World Wide Web
- * Consortium (W3C) schema element
- */
-
-// Oct 15th - momo - initial impl
-// Oct 17th - vidyanand - add SimpleType + element
-// Oct 18th - momo - add ComplexType
-// Oct 19th - vidyanand - handle external
-// Dec 6th - Vidyanand - changed RuntimeExceptions thrown to
XmlSchemaExceptions
-// Jan 15th - Vidyanand - made changes to SchemaBuilder.handleElement to look
for an element ref.
-// Feb 20th - Joni - Change the getXmlSchemaFromLocation schema
-// variable to name s.
-// Feb 21th - Joni - Port to XMLDomUtil and Tranformation.
-
-public class XmlSchema extends XmlSchemaAnnotated implements
NamespaceContextOwner {
- static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
- XmlSchemaForm attributeFormDefault, elementFormDefault;
-
- XmlSchemaObjectTable attributeGroups,
- attributes, elements, groups,
- notations, schemaTypes;
- XmlSchemaDerivationMethod blockDefault, finalDefault;
- XmlSchemaObjectCollection includes, items;
- boolean isCompiled;
- String syntacticalTargetNamespace, logicalTargetNamespace, version;
- String schema_ns_prefix = "";
- XmlSchemaCollection parent;
-
- private NamespacePrefixList namespaceContext;
- //keep the encoding of the input
- private String inputEncoding;
-
- public void setInputEncoding(String encoding) {
- this.inputEncoding = encoding;
- }
-
- /**
- * Create a new XmlSchema within an XmlSchemaCollection
- *
- * @param parent the parent XmlSchemaCollection
- */
- public XmlSchema(XmlSchemaCollection parent) {
- this.parent = parent;
- attributeFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
- elementFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
- blockDefault = new
XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
- finalDefault = new
XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
- items = new XmlSchemaObjectCollection();
- includes = new XmlSchemaObjectCollection();
- elements = new XmlSchemaObjectTable();
- attributeGroups = new XmlSchemaObjectTable();
- attributes = new XmlSchemaObjectTable();
- groups = new XmlSchemaObjectTable();
- notations = new XmlSchemaObjectTable();
- schemaTypes = new XmlSchemaObjectTable();
- }
-
- public XmlSchema(String namespace, XmlSchemaCollection parent) {
- this(parent);
- syntacticalTargetNamespace = logicalTargetNamespace = namespace;
- }
-
- public XmlSchemaForm getAttributeFormDefault() {
- return attributeFormDefault;
- }
-
- public void setAttributeFormDefault(XmlSchemaForm value) {
- attributeFormDefault = value;
- }
-
- public XmlSchemaObjectTable getAttributeGroups() {
- return attributeGroups;
- }
-
- public XmlSchemaObjectTable getAttributes() {
- return attributes;
- }
-
- public XmlSchemaDerivationMethod getBlockDefault() {
- return blockDefault;
- }
-
- public void setBlockDefault(XmlSchemaDerivationMethod blockDefault) {
- this.blockDefault = blockDefault;
- }
-
- public XmlSchemaForm getElementFormDefault() {
- return elementFormDefault;
- }
-
- public void setElementFormDefault(XmlSchemaForm elementFormDefault) {
- this.elementFormDefault = elementFormDefault;
- }
-
- public XmlSchemaObjectTable getElements() {
- return elements;
- }
-
- protected XmlSchemaElement getElementByName(QName name, boolean deep,
- Stack schemaStack) {
- if (schemaStack != null && schemaStack.contains(this)) {
- // recursive schema - just return null
- return null;
- } else {
- XmlSchemaElement element = (XmlSchemaElement) elements
- .getItem(name);
- if (deep) {
- if (element == null) {
- // search the imports
- for (Iterator includedItems = includes.getIterator();
includedItems
- .hasNext();) {
-
- XmlSchema schema = getSchema(includedItems.next());
-
- if (schema != null) {
- // create an empty stack - push the current parent
in
- // and
- // use the protected method to process the schema
- if (schemaStack == null) {
- schemaStack = new Stack();
- }
- schemaStack.push(this);
- element = schema.getElementByName(name, deep,
- schemaStack);
- if (element != null) {
- return element;
- }
- }
- }
- } else {
- return element;
- }
- }
-
- return element;
- }
- }
-
- /**
- * get an element by the name in the local schema
- *
- * @param name
- * @return
- */
- public XmlSchemaElement getElementByName(String name) {
- QName nameToSearchFor = new QName(this.getTargetNamespace(), name);
- return this.getElementByName(nameToSearchFor, false, null);
- }
-
- /**
- * Look for a element by its qname. Searches through all the schemas
- *
- * @param name
- * @return
- */
- public XmlSchemaElement getElementByName(QName name) {
- return this.getElementByName(name, true, null);
- }
-
- /**
- * Get a schema from an import
- *
- * @param includeOrImport
- * @return
- */
- private XmlSchema getSchema(Object includeOrImport) {
- XmlSchema schema;
- if (includeOrImport instanceof XmlSchemaImport) {
- schema = ((XmlSchemaImport) includeOrImport).getSchema();
- } else if (includeOrImport instanceof XmlSchemaInclude) {
- schema = ((XmlSchemaInclude) includeOrImport).getSchema();
- } else {
- // skip ?
- schema = null;
- }
-
- return schema;
- }
-
- /**
- * protected method that allows safe (non-recursive schema loading)
- *
- * @param name
- * @param deep
- * @param schemaStack
- * @return
- */
- protected XmlSchemaType getTypeByName(QName name, boolean deep,
- Stack schemaStack) {
- if (schemaStack != null && schemaStack.contains(this)) {
- // recursive schema - just return null
- return null;
- } else {
- XmlSchemaType type = (XmlSchemaType) schemaTypes.getItem(name);
-
- if (deep) {
- if (type == null) {
- // search the imports
- for (Iterator includedItems = includes.getIterator();
includedItems
- .hasNext();) {
-
- XmlSchema schema = getSchema(includedItems.next());
-
- if (schema != null) {
- // create an empty stack - push the current parent
- // use the protected method to process the schema
- if (schemaStack == null) {
- schemaStack = new Stack();
- }
- schemaStack.push(this);
- type = schema
- .getTypeByName(name, deep, schemaStack);
- if (type != null) {
- return type;
- }
- }
- }
- } else {
- return type;
- }
- }
-
- return type;
- }
- }
-
- /**
- * Search this schema and all the imported/included ones
- * for the given Qname
- *
- * @param name
- * @return
- */
- public XmlSchemaType getTypeByName(QName name) {
- return getTypeByName(name, true, null);
- }
-
- /**
- * @param name
- * @return
- */
- public XmlSchemaType getTypeByName(String name) {
- QName nameToSearchFor = new QName(this.getTargetNamespace(), name);
- return getTypeByName(nameToSearchFor, false, null);
- }
-
-
- public XmlSchemaDerivationMethod getFinalDefault() {
- return finalDefault;
- }
-
- public void setFinalDefault(XmlSchemaDerivationMethod finalDefault) {
- this.finalDefault = finalDefault;
- }
-
- public XmlSchemaObjectTable getGroups() {
- return groups;
- }
-
- public XmlSchemaObjectCollection getIncludes() {
- return includes;
- }
-
- public boolean isCompiled() {
- return isCompiled;
- }
-
- public XmlSchemaObjectCollection getItems() {
- return items;
- }
-
- public XmlSchemaObjectTable getNotations() {
- return notations;
- }
-
- public XmlSchemaObjectTable getSchemaTypes() {
- return schemaTypes;
- }
-
- public String getTargetNamespace() {
- return syntacticalTargetNamespace;
- }
-
- public void setTargetNamespace(String targetNamespace) {
- if (!targetNamespace.equals("")) {
- syntacticalTargetNamespace = logicalTargetNamespace =
targetNamespace;
- }
- }
-
- public String getVersion() {
- return version;
- }
-
- /**
- * Serialize the schema into the given output stream
- *
- * @param out - the output stream to write to
- */
- public void write(OutputStream out) {
- if (this.inputEncoding != null &&
- !"".equals(this.inputEncoding)) {
- try {
- write(new OutputStreamWriter(out, this.inputEncoding));
- } catch (UnsupportedEncodingException e) {
- //log the error and just write it without the encoding
-
- write(new OutputStreamWriter(out));
- }
- } else {
- write(new OutputStreamWriter(out));
- }
-
- }
-
- /**
- * Serialize the schema into the given output stream
- *
- * @param out - the output stream to write to
- * @param options - a map of options
- */
- public void write(OutputStream out, Map options) {
- if (this.inputEncoding != null &&
- !"".equals(this.inputEncoding)) {
- try {
- write(new OutputStreamWriter(out, this.inputEncoding),
options);
- } catch (UnsupportedEncodingException e) {
- //log the error and just write it without the encoding
- write(new OutputStreamWriter(out));
- }
- } else {
- write(new OutputStreamWriter(out), options);
- }
-
- }
-
- /**
- * Serialize the schema
- *
- * @param writer a Writer to serialize to
- * @param options a way to pass arbitrary options to the internal
serializer
- */
- public void write(Writer writer, Map options) {
- serialize_internal(this, writer, options);
- }
-
- /**
- * Serialize the schema
- *
- * @param writer a Writer to serialize to
- */
- public void write(Writer writer) {
- serialize_internal(this, writer, null);
- }
-
- public Document[] getAllSchemas() {
- try {
-
- XmlSchemaSerializer xser = new XmlSchemaSerializer();
- xser.setExtReg(this.parent.getExtReg());
- return xser.serializeSchema(this, true);
-
- } catch (XmlSchemaSerializer.XmlSchemaSerializerException e) {
- throw new XmlSchemaException(e.getMessage());
- }
- }
-
- /**
- * serialize the schema - this is the method that does the work
- *
- * @param schema XmlSchema to serialize
- * @param out the Writer we'll write to
- * @param options options to customize the serialization
- */
- private void serialize_internal(XmlSchema schema, Writer out, Map options)
{
-
- try {
- XmlSchemaSerializer xser = new XmlSchemaSerializer();
- xser.setExtReg(this.parent.getExtReg());
- Document[] serializedSchemas = xser.serializeSchema(schema, false);
- TransformerFactory trFac = TransformerFactory.newInstance();
-
- try {
- trFac.setAttribute("indent-number", "4");
- } catch (IllegalArgumentException e) {
- //do nothing - we'll just silently let this pass if it
- //was not compatible
- }
-
- Source source = new DOMSource(serializedSchemas[0]);
- Result result = new StreamResult(out);
- javax.xml.transform.Transformer tr = trFac.newTransformer();
-
- //use the input encoding if there is one
- if (schema.inputEncoding != null &&
!"".equals(schema.inputEncoding)) {
- tr.setOutputProperty(OutputKeys.ENCODING,
schema.inputEncoding);
- }
-
- // If options were passed, we'll use them to figure out encoding,
etc.
- // If not, we load the default ones.
-
- if (options == null) {
- options = new HashMap();
- loadDefaultOptions(options);
- }
-
- Iterator keys = options.keySet().iterator();
- while (keys.hasNext()) {
- Object key = keys.next();
- tr.setOutputProperty((String) key, (String) options.get(key));
- }
-
- tr.transform(source, result);
- out.flush();
- } catch (TransformerConfigurationException e) {
- throw new XmlSchemaException(e.getMessage());
- } catch (TransformerException e) {
- throw new XmlSchemaException(e.getMessage());
- } catch (XmlSchemaSerializer.XmlSchemaSerializerException e) {
- throw new XmlSchemaException(e.getMessage());
- } catch (IOException e) {
- throw new XmlSchemaException(e.getMessage());
- }
- }
-
- /**
- * Load the default options
- *
- * @param options - the map of
- */
- private void loadDefaultOptions(Map options) {
- options.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- options.put(OutputKeys.INDENT, "yes");
- }
-
- public void addType(XmlSchemaType type) {
- QName qname = type.getQName();
- if (schemaTypes.contains(qname)) {
- throw new RuntimeException("Schema for namespace '" +
- syntacticalTargetNamespace + "' already contains type '" +
- qname.getLocalPart());
- }
- schemaTypes.add(qname, type);
- }
-
- public NamespacePrefixList getNamespaceContext() {
- return namespaceContext;
- }
-
- /**
- * Sets the schema element's namespace context. This may be used for schema
- * serialization, until a better mechanism is found.
- *
- * @param namespaceContext representation of the currently defined
namespace prefixes
- */
- public void setNamespaceContext(NamespacePrefixList namespaceContext) {
- this.namespaceContext = namespaceContext;
- }
-
- /**
- * Override the equals(Object) method with equivalence checking
- * that is specific to this class.
- */
- public boolean equals(Object what) {
-
- //Note: this method may no longer be required when line
number/position are used correctly in XmlSchemaObject.
- //Currently they are simply initialized to zero, but they are used in
XmlSchemaObject.equals
- //which can result in a false positive (e.g. if a WSDL contains 2
inlined schemas).
-
- if (what == this) {
- return true;
- }
-
- //If the inherited behaviour determines that the objects are NOT
equal, return false.
- //Otherwise, do some further equivalence checking.
-
- if (!super.equals(what)) {
- return false;
- }
-
- if (!(what instanceof XmlSchema)) {
- return false;
- }
-
- XmlSchema xs = (XmlSchema) what;
-
- if (this.id != null) {
- if (!this.id.equals(xs.id)) {
- return false;
- }
- } else {
- if (xs.id != null) {
- return false;
- }
- }
-
- if (this.syntacticalTargetNamespace != null) {
- if
(!this.syntacticalTargetNamespace.equals(xs.syntacticalTargetNamespace)) {
- return false;
- }
- } else {
- if (xs.syntacticalTargetNamespace != null) {
- return false;
- }
- }
-
- //TODO decide if further schema content should be checked for
equivalence.
-
- return true;
- }
-
- public String getInputEncoding() {
- return inputEncoding;
- }
-
- public String toString() {
- return super.toString() + "[" + logicalTargetNamespace + "]";
- }
-}
+/*
+ * 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.ws.commons.schema;
+
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.ws.commons.schema.utils.NamespaceContextOwner;
+import org.apache.ws.commons.schema.utils.NamespacePrefixList;
+import org.w3c.dom.Document;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Stack;
+
+
+/**
+ * Contains the definition of a schema. All XML Schema definition language
(XSD)
+ * elements are children of the schema element. Represents the World Wide Web
+ * Consortium (W3C) schema element
+ */
+
+// Oct 15th - momo - initial impl
+// Oct 17th - vidyanand - add SimpleType + element
+// Oct 18th - momo - add ComplexType
+// Oct 19th - vidyanand - handle external
+// Dec 6th - Vidyanand - changed RuntimeExceptions thrown to
XmlSchemaExceptions
+// Jan 15th - Vidyanand - made changes to SchemaBuilder.handleElement to look
for an element ref.
+// Feb 20th - Joni - Change the getXmlSchemaFromLocation schema
+// variable to name s.
+// Feb 21th - Joni - Port to XMLDomUtil and Tranformation.
+
+public class XmlSchema extends XmlSchemaAnnotated implements
NamespaceContextOwner {
+ private static final String UTF_8_ENCODING = "UTF-8";
+ static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ XmlSchemaForm attributeFormDefault, elementFormDefault;
+
+ XmlSchemaObjectTable attributeGroups,
+ attributes, elements, groups,
+ notations, schemaTypes;
+ XmlSchemaDerivationMethod blockDefault, finalDefault;
+ XmlSchemaObjectCollection includes, items;
+ boolean isCompiled;
+ String syntacticalTargetNamespace, logicalTargetNamespace, version;
+ String schema_ns_prefix = "";
+ XmlSchemaCollection parent;
+
+ private NamespacePrefixList namespaceContext;
+ //keep the encoding of the input
+ private String inputEncoding;
+
+ public void setInputEncoding(String encoding){
+ this.inputEncoding = encoding;
+ }
+ /**
+ * Creates new XmlSchema
+ * Create a new XmlSchema. The schema is <i>not</i> added to the parent
collection,
+ * since it has no target namespace when created through this constructor.
+ * Call [EMAIL PROTECTED] XmlSchema#XmlSchema(String,
XmlSchemaCollection)} instead.
+ *
+ * @param parent the parent XmlSchemaCollection
+ * @deprecated
+ */
+ public XmlSchema(XmlSchemaCollection parent) {
+ this(null, null, parent);
+ }
+
+ /**
+ * Create a schema that is not a member of a collection.
+ */
+ public XmlSchema() {
+ this(null, null, null);
+ }
+
+ /**
+ * Create a new schema and record it as a member of a schema collection.
+ * @param namespace the target namespace.
+ * @param systemId the system ID for the schema.
+ * @param parent the parent collection.
+ */
+ public XmlSchema(String namespace, String systemId, XmlSchemaCollection
parent) {
+ this.parent = parent;
+ if (namespace == null) {
+ namespace = "";
+ }
+ this.parent = parent;
+ attributeFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ elementFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ blockDefault = new
XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
+ finalDefault = new
XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
+ items = new XmlSchemaObjectCollection();
+ includes = new XmlSchemaObjectCollection();
+ elements = new XmlSchemaObjectTable();
+ attributeGroups = new XmlSchemaObjectTable();
+ attributes = new XmlSchemaObjectTable();
+ groups = new XmlSchemaObjectTable();
+ notations = new XmlSchemaObjectTable();
+ schemaTypes = new XmlSchemaObjectTable();
+
+ syntacticalTargetNamespace = logicalTargetNamespace = namespace;
+ if(parent != null) {
+ XmlSchemaCollection.SchemaKey schemaKey =
+ new
XmlSchemaCollection.SchemaKey(this.logicalTargetNamespace, systemId);
+ if (parent.containsSchema(schemaKey)) {
+ throw new XmlSchemaException("Schema name conflict in
collection");
+ } else {
+ parent.addSchema(schemaKey, this);
+ }
+ }
+ }
+
+ public XmlSchema(String namespace, XmlSchemaCollection parent) {
+ this(namespace, namespace, parent);
+
+ }
+
+ public XmlSchemaForm getAttributeFormDefault() {
+ return attributeFormDefault;
+ }
+
+ public void setAttributeFormDefault(XmlSchemaForm value) {
+ attributeFormDefault = value;
+ }
+
+ public XmlSchemaObjectTable getAttributeGroups() {
+ return attributeGroups;
+ }
+
+ public XmlSchemaObjectTable getAttributes() {
+ return attributes;
+ }
+
+ public XmlSchemaDerivationMethod getBlockDefault() {
+ return blockDefault;
+ }
+
+ public void setBlockDefault(XmlSchemaDerivationMethod blockDefault) {
+ this.blockDefault = blockDefault;
+ }
+
+ public XmlSchemaForm getElementFormDefault() {
+ return elementFormDefault;
+ }
+
+ public void setElementFormDefault(XmlSchemaForm elementFormDefault) {
+ this.elementFormDefault = elementFormDefault;
+ }
+
+ public XmlSchemaObjectTable getElements() {
+ return elements;
+ }
+
+
+ protected XmlSchemaElement getElementByName(QName name, boolean deep,
+ Stack schemaStack) {
+ if (schemaStack != null && schemaStack.contains(this)) {
+ // recursive schema - just return null
+ return null;
+ } else {
+ XmlSchemaElement element = (XmlSchemaElement) elements
+ .getItem(name);
+ if (deep) {
+ if (element == null) {
+ // search the imports
+ for (Iterator includedItems =
includes.getIterator(); includedItems
+ .hasNext();) {
+
+ XmlSchema schema =
getSchema(includedItems.next());
+
+ if (schema != null) {
+ // create an empty stack - push
the current parent in
+ // and
+ // use the protected method to
process the schema
+ if (schemaStack == null) {
+ schemaStack = new
Stack();
+ }
+ schemaStack.push(this);
+ element =
schema.getElementByName(name, deep,
+ schemaStack);
+ if (element != null) {
+ return element;
+ }
+ }
+ }
+ } else {
+ return element;
+ }
+ }
+
+ return element;
+ }
+ }
+
+ /**
+ * get an element by the name in the local schema
+ *
+ * @param name
+ * @return
+ */
+ public XmlSchemaElement getElementByName(String name) {
+ QName nameToSearchFor = new QName(this.getTargetNamespace(),name);
+ return this.getElementByName(nameToSearchFor, false, null);
+ }
+
+ /**
+ * Look for a element by its qname. Searches through all the schemas
+ * @param name
+ * @return
+ */
+ public XmlSchemaElement getElementByName(QName name) {
+ return this.getElementByName(name, true, null);
+ }
+
+ /**
+ * protected method that allows safe (non-recursive schema loading)
+ *
+ * @param name
+ * @param deep
+ * @param schemaStack
+ * @return
+ */
+ protected XmlSchemaType getTypeByName(QName name, boolean deep,
+ Stack schemaStack) {
+ if (schemaStack != null && schemaStack.contains(this)) {
+ // recursive schema - just return null
+ return null;
+ } else {
+ XmlSchemaType type = (XmlSchemaType)
schemaTypes.getItem(name);
+
+ if (deep) {
+ if (type == null) {
+ // search the imports
+ for (Iterator includedItems =
includes.getIterator(); includedItems
+ .hasNext();) {
+
+ XmlSchema schema =
getSchema(includedItems.next());
+
+ if (schema != null) {
+ // create an empty
stack - push the current parent
+ // use the protected
method to process the schema
+ if (schemaStack ==
null) {
+ schemaStack =
new Stack();
+ }
+ schemaStack.push(this);
+ type = schema
+
.getTypeByName(name, deep, schemaStack);
+ if (type != null) {
+ return type;
+ }
+ }
+ }
+ } else {
+ return type;
+ }
+ }
+
+ return type;
+ }
+ }
+
+ /**
+ * Search this schema and all the imported/included ones
+ * for the given Qname
+ * @param name
+ * @return
+ */
+ public XmlSchemaType getTypeByName(QName name) {
+ return getTypeByName(name, true, null);
+ }
+
+ /**
+ *
+ * @param name
+ * @return
+ */
+ public XmlSchemaType getTypeByName(String name) {
+ QName nameToSearchFor = new QName(this.getTargetNamespace(),name);
+ return getTypeByName(nameToSearchFor, false, null);
+ }
+
+ /**
+ * Get a schema from an import
+ *
+ * @param includeOrImport
+ * @return
+ */
+ private XmlSchema getSchema(Object includeOrImport) {
+ XmlSchema schema;
+ if (includeOrImport instanceof XmlSchemaImport) {
+ schema = ((XmlSchemaImport)
includeOrImport).getSchema();
+ } else if (includeOrImport instanceof XmlSchemaInclude) {
+ schema = ((XmlSchemaInclude)
includeOrImport).getSchema();
+ } else {
+ // skip ?
+ schema = null;
+ }
+
+ return schema;
+ }
+
+
+
+ public XmlSchemaDerivationMethod getFinalDefault() {
+ return finalDefault;
+ }
+
+ public void setFinalDefault(XmlSchemaDerivationMethod finalDefault) {
+ this.finalDefault = finalDefault;
+ }
+
+ public XmlSchemaObjectTable getGroups() {
+ return groups;
+ }
+
+ public XmlSchemaObjectCollection getIncludes() {
+ return includes;
+ }
+
+ public boolean isCompiled() {
+ return isCompiled;
+ }
+
+ public XmlSchemaObjectCollection getItems() {
+ return items;
+ }
+
+ public XmlSchemaObjectTable getNotations() {
+ return notations;
+ }
+
+ public XmlSchemaObjectTable getSchemaTypes() {
+ return schemaTypes;
+ }
+
+ public String getTargetNamespace() {
+ return syntacticalTargetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace) {
+ if (!targetNamespace.equals("")) {
+ syntacticalTargetNamespace = logicalTargetNamespace =
targetNamespace;
+ }
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void compile(ValidationEventHandler eh) {
+
+ }
+
+ /**
+ * Serialize the schema into the given output stream
+ * @param out - the output stream to write to
+ */
+ public void write(OutputStream out) {
+ try {
+ if (this.inputEncoding!= null &&
+ !"".equals(this.inputEncoding)){
+ write(new OutputStreamWriter(out,this.inputEncoding));
+ }else{
+ //As per the XML spec the default is taken to be UTF 8
+ write(new OutputStreamWriter(out,UTF_8_ENCODING));
+ }
+ } catch (UnsupportedEncodingException e) {
+ //log the error and just write it without the encoding
+ write(new OutputStreamWriter(out));
+ }
+
+ }
+
+ /**
+ * Serialize the schema into the given output stream
+ * @param out - the output stream to write to
+ * @param options - a map of options
+ */
+ public void write(OutputStream out, Map options) {
+ try {
+ if (this.inputEncoding!= null &&
+ !"".equals(this.inputEncoding)){
+ write(new
OutputStreamWriter(out,this.inputEncoding),options);
+ }else{
+ write(new OutputStreamWriter(out,UTF_8_ENCODING),options);
+ }
+ } catch (UnsupportedEncodingException e) {
+ //log the error and just write it without the encoding
+ write(new OutputStreamWriter(out));
+ }
+
+ }
+
+ /**
+ * Serialie the schema to a given writer
+ * @param writer - the writer to write this
+ */
+ public void write(Writer writer,Map options) {
+ serialize_internal(this, writer,options);
+ }
+ /**
+ * Serialie the schema to a given writer
+ * @param writer - the writer to write this
+ */
+ public void write(Writer writer) {
+ serialize_internal(this, writer,null);
+ }
+
+ public Document[] getAllSchemas() {
+ try {
+
+ XmlSchemaSerializer xser = new XmlSchemaSerializer();
+ xser.setExtReg(this.parent.getExtReg());
+ return xser.serializeSchema(this, true);
+
+ } catch (XmlSchemaSerializer.XmlSchemaSerializerException e) {
+ throw new XmlSchemaException(e.getMessage());
+ }
+ }
+
+ /**
+ * serialize the schema - this is the method tht does to work
+ * @param schema
+ * @param out
+ * @param options
+ */
+ private void serialize_internal(XmlSchema schema, Writer out, Map
options) {
+
+ try {
+ XmlSchemaSerializer xser = new XmlSchemaSerializer();
+ xser.setExtReg(this.parent.getExtReg());
+ Document[] serializedSchemas = xser.serializeSchema(schema, false);
+ TransformerFactory trFac = TransformerFactory.newInstance();
+
+ try {
+ trFac.setAttribute("indent-number", "4");
+ } catch (IllegalArgumentException e) {
+ //do nothing - we'll just silently let this pass if it
+ //was not compatible
+ }
+
+ Source source = new DOMSource(serializedSchemas[0]);
+ Result result = new StreamResult(out);
+ javax.xml.transform.Transformer tr = trFac.newTransformer();
+
+ //use the input encoding if there is one
+ if (schema.inputEncoding!= null &&
+ !"".equals(schema.inputEncoding)){
+ tr.setOutputProperty(OutputKeys.ENCODING,schema.inputEncoding);
+ }
+
+ //let these be configured from outside if any is present
+ //Note that one can enforce the encoding by passing the necessary
+ //property in options
+
+ if (options==null){
+ options = new HashMap();
+ loadDefaultOptions(options);
+ }
+ Iterator keys = options.keySet().iterator();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ tr.setOutputProperty((String)key, (String)options.get(key));
+ }
+
+ tr.transform(source, result);
+ out.flush();
+ } catch (TransformerConfigurationException e) {
+ throw new XmlSchemaException(e.getMessage());
+ } catch (TransformerException e) {
+ throw new XmlSchemaException(e.getMessage());
+ } catch (XmlSchemaSerializer.XmlSchemaSerializerException e) {
+ throw new XmlSchemaException(e.getMessage());
+ } catch (IOException e) {
+ throw new XmlSchemaException(e.getMessage());
+ }
+ }
+
+ /**
+ * Load the default options
+ * @param options - the map of
+ */
+ private void loadDefaultOptions(Map options) {
+ options.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ options.put(OutputKeys.INDENT, "yes");
+ }
+
+ public void addType(XmlSchemaType type) {
+ QName qname = type.getQName();
+ if (schemaTypes.contains(qname)) {
+ throw new XmlSchemaException(" Schema for namespace '" +
+ syntacticalTargetNamespace + "' already contains type '" +
+ qname.getLocalPart() + "'");
+ }
+ schemaTypes.add(qname, type);
+ }
+
+ public NamespacePrefixList getNamespaceContext() {
+ return namespaceContext;
+ }
+
+ /**
+ * Sets the schema elements namespace context. This may be used for schema
+ * serialization, until a better mechanism was found.
+ */
+ public void setNamespaceContext(NamespacePrefixList namespaceContext) {
+ this.namespaceContext = namespaceContext;
+ }
+
+ /**
+ * Override the equals(Object) method with equivalence checking
+ * that is specific to this class.
+ */
+ public boolean equals(Object what) {
+
+ //Note: this method may no longer be required when line
number/position are used correctly in XmlSchemaObject.
+ //Currently they are simply initialized to zero, but they are used in
XmlSchemaObject.equals
+ //which can result in a false positive (e.g. if a WSDL contains 2
inlined schemas).
+
+ if (what == this) {
+ return true;
+ }
+
+ //If the inherited behaviour determines that the objects are NOT
equal, return false.
+ //Otherwise, do some further equivalence checking.
+
+ if(!super.equals(what)) {
+ return false;
+ }
+
+ if (!(what instanceof XmlSchema)) {
+ return false;
+ }
+
+ XmlSchema xs = (XmlSchema) what;
+
+ if (this.id != null) {
+ if (!this.id.equals(xs.id)) {
+ return false;
+ }
+ } else {
+ if (xs.id != null) {
+ return false;
+ }
+ }
+
+ if (this.syntacticalTargetNamespace != null) {
+ if
(!this.syntacticalTargetNamespace.equals(xs.syntacticalTargetNamespace)) {
+ return false;
+ }
+ } else {
+ if (xs.syntacticalTargetNamespace != null) {
+ return false;
+ }
+ }
+
+ //TODO decide if further schema content should be checked for
equivalence.
+
+ return true;
+ }
+ public String getInputEncoding() {
+ return inputEncoding;
+ }
+
+ public String toString() {
+ return super.toString() + "[" + logicalTargetNamespace + "]";
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]