HOW TO write an xml schema coping types from another xml Schema:

SchemaReader sr;

//Reads the schema              
sr = new SchemaReader("file.xsd");
Schema schema = sr.read();

//the schema that i'll write            
Schema mySchema = new Schema(prefix,namespace);

//add a complex type defined in the schema file.xsd             
ComplexType ct = schema.getComplexType("typename");
ct.setSchema(mySchema);
mySchema.addComplexType(ct);


//add a simple type defined in the schema file.xsd                              
SimpleType st =schema.getSimpleType("typename");
st.setSchema(mySchema);
mySchema.addSimpleType(st);

//add a new element referred to a type previously added         
ElementDecl ele =new ElementDecl(mySchema,"pippo");
ele.setTypeReference(st.getName());
mySchema.addElementDecl(ele);
                
FileWriter fw =new FileWriter("outputfile.xsd");
SchemaWriter sw = new SchemaWriter(fw);
sw.write(mySchema);
-- 
View this message in context: 
http://www.nabble.com/HOW-TO-write-an-xml-schema-coping-types-from-another-xml-Schema-tf4771603.html#a13649151
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to