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
