Author: dims
Date: Thu Mar 8 13:23:36 2007
New Revision: 516179
URL: http://svn.apache.org/viewvc?view=rev&rev=516179
Log:
if two schemas import each other, we need to prevent the recursion
Modified:
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/XmlSchemaCollection.java
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?view=diff&rev=516179&r1=516178&r2=516179
==============================================================================
---
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
Thu Mar 8 13:23:36 2007
@@ -19,6 +19,7 @@
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.Stack;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
@@ -1573,7 +1574,7 @@
validator);
}
}
- return schemaImport;
+ return (schemaImport.schema == null) ? null : schemaImport;
}
/**
@@ -1619,6 +1620,7 @@
include.schemaLocation,
validator);
}
+
//process extra attributes and elements
processExtensibilityComponents(include,includeEl);
return include;
@@ -1819,11 +1821,17 @@
if (schema != null) {
return schema;
}
- try {
- return collection.read(source, null, validator);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ if (collection.check(key)) {
+ collection.push(key);
+ try {
+ return collection.read(source, null, validator);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ collection.pop();
+ }
}
+ return null;
}
/**
Modified:
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java?view=diff&rev=516179&r1=516178&r2=516179
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
Thu Mar 8 13:23:36 2007
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Stack;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -120,7 +121,12 @@
XmlSchema xsd = new XmlSchema(XmlSchema.SCHEMA_NS, this);
- /**
+ /**
+ * stack to track imports (to prevent recursion)
+ */
+ Stack stack = new Stack();
+
+ /**
* Set the base URI. This is used when schemas need to be
* loaded from relative locations
* @param baseUri
@@ -438,5 +444,17 @@
public void setNamespaceContext(NamespacePrefixList namespaceContext) {
this.namespaceContext = namespaceContext;
+ }
+
+ public void push(SchemaKey pKey){
+ stack.push(pKey);
+ }
+
+ public void pop(){
+ stack.pop();
+ }
+
+ public boolean check(SchemaKey pKey){
+ return (stack.indexOf(pKey)==-1);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]