Hello,
I want to create a schema fragment as below.
<xs:complexType name="MyType">
<xs:sequence>
<xs:element name="myStringType" type="xs:string" minOccurs="0"/>
<xs:element name="myAnyType" type="xs:anyType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
But I can't create a AnyType by using schema API. It always throws an
exception
Exception in thread "main" java.lang.IllegalArgumentException: The parent of
'anyType' cannot be changed.
at org.exolab.castor.xml.schema.AnyType.setParent(AnyType.java:184)
at
org.exolab.castor.xml.schema.ElementDecl.setType(ElementDecl.java:749)
at MySchema.main(MySchema.java:39)
Please see the enclosed file.
Regards,
--
Le Duc Bao
import java.io.OutputStreamWriter;
import org.exolab.castor.xml.schema.AnyType;
import org.exolab.castor.xml.schema.ComplexType;
import org.exolab.castor.xml.schema.ElementDecl;
import org.exolab.castor.xml.schema.Group;
import org.exolab.castor.xml.schema.Schema;
import org.exolab.castor.xml.schema.SchemaException;
import org.exolab.castor.xml.schema.writer.SchemaWriter;
/*
*
*/
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Le Duc Bao</a>
* @version 1.0
* @since 16 août 08 17:43:47
*/
public class MySchema {
public static void main (String [] arg) throws Exception {
Schema schema = new Schema();
ComplexType ctype = schema.createComplexType();
ctype.setName("MyType");
schema.addComplexType(ctype);
Group group = new Group();
ctype.addGroup(group);
ElementDecl elem = new ElementDecl(schema);
elem.setName("myStringType");
group.addElementDecl(elem);
elem.setTypeReference("string");
elem = new ElementDecl(schema);
elem.setName("myAnyType");
group.addElementDecl(elem);
elem.setType(new AnyType(schema));
SchemaWriter swriter = new SchemaWriter(new OutputStreamWriter (System.out));
swriter.write(schema);
}
}
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email