You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/10/12 07:53:02 UTC
svn commit: r314794 - in
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema:
JavaBeanWriter.java SchemaCompiler.java template/BeanTemplate.xsl
Author: ajith
Date: Tue Oct 11 22:52:53 2005
New Revision: 314794
URL: http://svn.apache.org/viewcvs?rev=314794&view=rev
Log:
1. Modified the schema compiler NOT to generate classes for elements. What it does now is put the elements QName in the processed element list with it's type. if an element referes to a simple type (say a string) java.lang.String will be the class name for that particular element. for complex types, beans will be generated!
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java?rev=314794&r1=314793&r2=314794&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java Tue Oct 11 22:52:53 2005
@@ -96,6 +96,9 @@
throw new SchemaCompilationException("Type missing!");
}
XSLTUtils.addAttribute(model,"type",javaClassNameForElement,property);
+ if (typeMap.containsKey(metainf.getSchemaQNameForElement(name))){
+ XSLTUtils.addAttribute(model,"ours","yes",property); //todo introduce a better name for this
+ }
}
//create the file
@@ -152,10 +155,14 @@
Element property = XSLTUtils.addChildElement(model,"property",rootElt);
name = (QName)qNameIterator.next();
XSLTUtils.addAttribute(model,"name",name.getLocalPart(),property);
- XSLTUtils.addAttribute(model,"type",metainf.getJavaClassNameForElement(name),property);
-// if (typeMap.containsKey(metainf.getSchemaQNameForElement(name))){
-// XSLTUtils.addAttribute(model,"ours","yes",property); //todo introduce a better name for this
-// }
+ String javaClassNameForElement = metainf.getJavaClassNameForElement(name);
+ if (javaClassNameForElement==null){
+ throw new SchemaCompilationException("Type missing!");
+ }
+ XSLTUtils.addAttribute(model,"type",javaClassNameForElement,property);
+ if (typeMap.containsKey(metainf.getSchemaQNameForElement(name))){
+ XSLTUtils.addAttribute(model,"ours","yes",property); //todo introduce a better name for this
+ }
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=314794&r1=314793&r2=314794&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java Tue Oct 11 22:52:53 2005
@@ -86,15 +86,8 @@
*/
public void compile(XmlSchema schema) throws SchemaCompilationException{
- //write the code here to do the schema compilation
- //select the types
- XmlSchemaObjectTable types = schema.getSchemaTypes();
- Iterator xmlSchemaTypeIterator = types.getValues();
- while (xmlSchemaTypeIterator.hasNext()) {
- processSchema((XmlSchemaType)xmlSchemaTypeIterator.next());
- }
-
- //select all the elements next
+ //select all the elements. We generate the code for types
+ //only if the elements refer them!!!
XmlSchemaObjectTable elements = schema.getElements();
Iterator xmlSchemaElementIterator = elements.getValues();
while (xmlSchemaElementIterator.hasNext()) {
@@ -117,15 +110,19 @@
if (processedElementmap.containsKey(xsElt.getQName())){
return;
}
- if (schemaType==null){
- throw new SchemaCompilationException("Schema type not found!");
+ QName qName = null;
+
+ if (schemaType!=null){
+ processSchema(schemaType);
+ qName = schemaType.getQName();
+ }else{
+ //perhaps this has an anoynimous complex type!
}
- processSchema(schemaType);
- QName qName = schemaType.getQName();
- //write a class for this element
- BeanWriterMetaInfoHolder metainf = new BeanWriterMetaInfoHolder();
- //there can be only one schema type
+
+ //if the schema type is a basic one then we are done by just
+ //there can be only one schema type (????)
+
String className = "";
if (processedTypemap.containsKey(qName)){
className = processedTypemap.get(qName).toString();
@@ -134,10 +131,8 @@
}else{
//throw an exception here
}
- metainf.addElementInfo(xsElt.getQName(),qName,className);
- String fullyQualifiedClassName = writer.write(xsElt,processedTypemap,metainf);
- processedElementmap.put(xsElt.getQName(),fullyQualifiedClassName);
+ processedElementmap.put(xsElt.getQName(),className);
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl?rev=314794&r1=314793&r2=314794&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl Tue Oct 11 22:52:53 2005
@@ -62,6 +62,9 @@
* Note - This is not complete
*/
public static <xsl:value-of select="$name"/> parse(javax.xml.stream.XMLStreamReader reader){
+
+
+
return new <xsl:value-of select="$name"/>();
}