+1 to release
I tested by appling the attached patch to the trunk. and every thing worked
fine.
I applied this patch with the changed axis2 details.
thanks,
Amila.
On Dec 5, 2007 3:05 PM, Amila Suriarachchi <[EMAIL PROTECTED]>
wrote:
>
>
> On Dec 5, 2007 1:50 AM, Ajith Ranabahu <[EMAIL PROTECTED]> wrote:
>
> > Hi Benson,
> > The suggested API change (I'm not sure whether this should be termed
> > an API change anyway. The earlier discussions implied to some extent
> > that it is a bug fix) and your patch are both applied in the release
> > branch (1.3.3).
> > Just to give some insight into what is happening let me explain the
> > situation. There are two methods getType[Element]Byname(Qname) that
> > used to look only inside the current schema. The problem is that Axis2
> > code generator relies on this behavior. The argument was that since
> > you are passing a Qname this method should rightfully look in *all*
> > schemas (including the imported ones). So the posted RC has the
> > following changes
> >
> > 1. getType[Element]Byname(Qname) looks through all schemas
> > 2. Two new methods getType[Element]Byname(String) are added. These
> > look only inside the current Schema object for required type
> >
> > I'm sure if I change the trunk now Axis2 would break in its tests (not
> > during compilation) and that is why I am not so keen on putting it in
> > the trunk right now. After we test the RC (code from the branch) then
> > we can do the transition to the trunk.
>
>
> hi ajith can you add this change to the trunk. I mean can you add new two
> methods to the Xml schema.
> Then according to that I can change the Axis2 and test. (Adding two method
> won't break anything.)
> It is bit difficult to test with your RC.
>
> thanks,
> Amila.
>
> >
> >
> > Ideas ?
> >
> > Ajith
> >
> > On Dec 4, 2007 12:13 PM, Benson Margulies <[EMAIL PROTECTED]> wrote:
> >
> > > If you are breaking the API, why can't you include the 272 fix? The
> > JIRA
> > > traffic said that it was being held off in a branch due to possibly
> > > disturbing existing users, but won't it pale in comparison with the
> > main
> > > change under discussion?
> > >
> > >
> > > > -----Original Message-----
> > > > From: David Illsley [mailto:[EMAIL PROTECTED]
> > > > Sent: Tuesday, December 04, 2007 12:11 PM
> > > > To: [email protected]
> > > > Subject: Re: [Vote][XMLSchema] time for a release (again)
> > > >
> > > > Yeah, I'm suggesting that an API breaking change probably
> > > > shouldn't be in a x.x.1 version number. I'm also hesitant to
> > > > release with those changes if they've not been widely tested
> > > > e.g. on the trunk with Axis2. If it causes unanticipated
> > > > problems we'd be in a really unfortunate situation.
> > > > David
> > > >
> > > > On Dec 4, 2007 5:05 PM, Ajith Ranabahu
> > > > <[EMAIL PROTECTED] > wrote:
> > > > > Hi,
> > > > > I was only going with minor revision change but since we
> > > > are having an
> > > > > API change are you are you suggesting a major revision
> > > > number change ?
> > > > > (Like 1.4 maybe) Actually the Interface has only additions but the
> > > > > behavior of the method has changed.
> > > > >
> > > > > Ajith
> > > > >
> > > > >
> > > > > On Dec 3, 2007 6:27 PM, David Illsley
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > > Hi Ajith,
> > > > > > I'm a little confused... what's the version number you
> > > > want this to go out with?
> > > > > > David
> > > > > >
> > > > > >
> > > > > > On Dec 3, 2007 10:27 PM, Ajith Ranabahu
> > > > < [EMAIL PROTECTED]> wrote:
> > > > > > > Hi all,
> > > > > > > I've fixed all the issues as discussed in the mailing list and
> > > > > > > posted the RC jars and zip files at
> > > > > > > http://people.apache.org/~ajith/xmlschema/<http://people.apache.org/%7Eajith/xmlschema/>
> > > > > > >
> > > > > > > This version has the API changed (not deprecated) and
> > > > is likely to
> > > > > > > break certain projects - especially Axis2. Hence I have not
> > > > > > > changed the trunk (since the snapshots will kick in and break
> > > > > > > things unexpectedly). As for the Jira issues I have
> > > > fixed 5 issues
> > > > > > > and marked
> > > > > > > 1 issue as wont fix since it seems to be something not
> > directly
> > > > > > > related to XMLSchema.
> > > > > > >
> > > > > > > Please give the RC's a try and let us know whether this
> > > > is fit for
> > > > > > > a release :)
> > > > > > >
> > > > > > > --
> > > > > > > Ajith Ranabahu
> > > > > > >
> > > > > > > Reading, after a certain age, diverts the mind too much
> > > > from its
> > > > > > > creative pursuits. Any man who reads too much and uses his own
> >
> > > > > > > brain too little falls into lazy habits of thinking - Albert
> > > > > > > Einstein
> > > > > > >
> > > > > > >
> > > > ------------------------------------------------------------------
> > > > > > > --- To unsubscribe, e-mail:
> > > > [EMAIL PROTECTED]
> > > > > > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > David Illsley - IBM Web Services Development
> > > > > >
> > > > > >
> > > > --------------------------------------------------------------------
> > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Ajith Ranabahu
> > > > >
> > > > > Reading, after a certain age, diverts the mind too much from its
> > > > > creative pursuits. Any man who reads too much and uses his
> > > > own brain
> > > > > too little falls into lazy habits of thinking - Albert Einstein
> > > > >
> > > > >
> > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > David Illsley - IBM Web Services Development
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> >
> > --
> > Ajith Ranabahu
> >
> > Reading, after a certain age, diverts the mind too much from its
> > creative pursuits. Any man who reads too much and uses his own brain
> > too little falls into lazy habits of thinking - Albert Einstein
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Amila Suriarachchi,
> WSO2 Inc.
--
Amila Suriarachchi,
WSO2 Inc.
Index: src/main/java/org/apache/ws/commons/schema/XmlSchema.java
===================================================================
--- src/main/java/org/apache/ws/commons/schema/XmlSchema.java (revision
603249)
+++ src/main/java/org/apache/ws/commons/schema/XmlSchema.java (working copy)
@@ -32,6 +32,7 @@
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Stack;
/**
@@ -68,13 +69,13 @@
//keep the encoding of the input
private String inputEncoding;
- public void setInputEncoding(String encoding){
+ public void setInputEncoding(String encoding) {
this.inputEncoding = encoding;
}
-
+
/**
* Create a new XmlSchema within an XmlSchemaCollection
- *
+ *
* @param parent the parent XmlSchemaCollection
*/
public XmlSchema(XmlSchemaCollection parent) {
@@ -134,59 +135,155 @@
return elements;
}
- public XmlSchemaElement getElementByName(QName name) {
- XmlSchemaElement element = (XmlSchemaElement) elements.getItem(name);
- if (element == null) {
- //search the imports
- for (Iterator includedItems = includes.getIterator();
includedItems.hasNext();) {
- Object includeOrImport = includedItems.next();
- XmlSchema schema;
- if (includeOrImport instanceof XmlSchemaImport) {
- schema = ((XmlSchemaImport) includeOrImport).getSchema();
- } else if (includeOrImport instanceof XmlSchemaInclude) {
- schema = ((XmlSchemaInclude) includeOrImport).getSchema();
+ 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 {
- //skip ?
- continue;
+ return element;
}
- if (schema != null && schema.getElementByName(name) != null) {
- return schema.getElementByName(name);
- }
}
- } else {
+
return element;
}
+ }
- return null;
+ /**
+ * 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);
}
- public XmlSchemaType getTypeByName(QName name) {
- XmlSchemaType type = (XmlSchemaType) schemaTypes.getItem(name);
- if (type == null) {
- //search the imports
- for (Iterator includedItems = includes.getIterator();
includedItems.hasNext();) {
- Object includeOrImport = includedItems.next();
- XmlSchema schema;
- if (includeOrImport instanceof XmlSchemaImport) {
- schema = ((XmlSchemaImport) includeOrImport).getSchema();
- } else if (includeOrImport instanceof XmlSchemaInclude) {
- schema = ((XmlSchemaInclude) includeOrImport).getSchema();
+ /**
+ * 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 {
- //skip ?
- continue;
+ return type;
}
+ }
- if (schema != null && schema.getTypeByName(name) != null) {
- return schema.getTypeByName(name);
- }
- }
- } else {
return type;
}
+ }
- return null;
+ /**
+ * 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;
}
@@ -235,11 +332,12 @@
/**
* 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)){
+ if (this.inputEncoding != null &&
+ !"".equals(this.inputEncoding)) {
try {
write(new OutputStreamWriter(out, this.inputEncoding));
} catch (UnsupportedEncodingException e) {
@@ -247,7 +345,7 @@
write(new OutputStreamWriter(out));
}
- }else{
+ } else {
write(new OutputStreamWriter(out));
}
@@ -255,20 +353,21 @@
/**
* Serialize the schema into the given output stream
- * @param out - the output stream to write to
+ *
+ * @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)){
+ 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);
+ } else {
+ write(new OutputStreamWriter(out), options);
}
}
@@ -276,7 +375,7 @@
/**
* Serialize the schema
*
- * @param writer a Writer to serialize to
+ * @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) {
@@ -306,8 +405,9 @@
/**
* 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 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)
{
@@ -330,7 +430,7 @@
javax.xml.transform.Transformer tr = trFac.newTransformer();
//use the input encoding if there is one
- if (schema.inputEncoding!= null &&
!"".equals(schema.inputEncoding)) {
+ if (schema.inputEncoding != null &&
!"".equals(schema.inputEncoding)) {
tr.setOutputProperty(OutputKeys.ENCODING,
schema.inputEncoding);
}
@@ -345,7 +445,7 @@
Iterator keys = options.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
- tr.setOutputProperty((String)key, (String)options.get(key));
+ tr.setOutputProperty((String) key, (String) options.get(key));
}
tr.transform(source, result);
@@ -363,7 +463,8 @@
/**
* Load the default options
- * @param options - the map of
+ *
+ * @param options - the map of
*/
private void loadDefaultOptions(Map options) {
options.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
@@ -411,7 +512,7 @@
//If the inherited behaviour determines that the objects are NOT
equal, return false.
//Otherwise, do some further equivalence checking.
- if(!super.equals(what)) {
+ if (!super.equals(what)) {
return false;
}
@@ -445,11 +546,12 @@
return true;
}
+
public String getInputEncoding() {
return inputEncoding;
}
-
+
public String toString() {
- return super.toString() + "[" + logicalTargetNamespace + "]";
+ return super.toString() + "[" + logicalTargetNamespace + "]";
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]