This is in followup to the previous e-mail I sent.
I am still unable to use anyType in my schema. I looked at the api for the generated source and there is some confusion there.
For testing purpose when I change anyType to string I get methods such as :
setAttributeValue(String s);
String getAttributeValue();
But when I compile my project with anyType I get:
setAttributeValue(AttributeValue av);
AttributeValue getAttributeValue();
I was expecting something like:
setAttributeValue(Object av);
Object getAttributeValue();
Am I missing something. I dont have getContent and SetContent methods on AttributeValue and so I can not do anything with it.
Any comments or thoughts on this problem are welcome.
Thanks,
Kamlesh
-----Original Message-----
From: Kamlesh Patel [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 20, 2002 12:56 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Problem with anyType. Using 9.3.17 tage from cvs.
I am using tag tag_0_9_3_17 from the CVS.
Here is a sample schema, sample xml file, test java code and the exception that I get when I just try to do a marshal and unmarshal. I also tried to cast AttributeValue -> Object -> String on unmarshal and String -> Object -> AttributeValue on marshal but get the same error.
Maybe I am missing some point here but according to me this should work.
Any suggestions from anyone will be most welcome.
Thanks,
Kamlesh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Sample schema
-------------
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="assertion" xmlns:a="assertion" xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="AttributeDesignatorType">
<attribute name="AttributeNamespace" type="anyURI" use="required"/>
</complexType>
<element name="Attribute" type="a:AttributeType"/>
<complexType name="AttributeType">
<complexContent>
<extension base="a:AttributeDesignatorType">
<sequence>
<element ref="a:AttributeValue" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element name="AttributeValue" type="anyType"/>
</schema>
Test XML File
-------------
<?xml version="1.0" encoding="UTF-8"?>
<Attribute xmlns="assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" AttributeNamespace="http://www.xmlspy.com">
<AttributeValue>someString</AttributeValue>
</Attribute>
Test Java Program
-----------------
import java.io.*;
import org.exolab.castor.xml.*;
import assertion.*;
public class test {
public static void main(String argv[]) {
try {
//-- Unmarshal/Marshal
Attribute attr = Attribute.unmarshal(new FileReader ("test_anyType.xml"));
attr.marshal(new FileWriter ("out_anyType.xml"));
} catch(Exception e) {
e.printStackTrace();
}
}
}
Exception
---------
org.xml.sax.SAXException: Illegal Text data found as child of: AttributeValue value: "someString"
at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:564)
at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1436)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1205)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:463)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:395)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:535)
at assertion.Attribute.unmarshal(Attribute.java:90)
at test.main(test.java:13)
-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 11:17 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] RE: newbee: Is anyType supported
This should work in the CVS version of Castor (tag_0_9_3_17 or later).
It won't work with Castor 0.9.3.9.
--Keith
