Hi,
The high-level view of my schema is shown below :
(Filename = ListingRequest.xsd)
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://w3.ibm.com/xmlns/srv/cs/catalog"
xmlns:req="http://w3.ibm.com/xmlns/srv/cs/catalog"
elementFormDefault="qualified">
<xsd:include schemaLocation="TypeDefinitions.xsd"/>
<xsd:element name="listRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="locale"
type="req:LocaleInfo" minOccurs="1"
maxOccurs="1" />
<xsd:element name="contentTypeList"
minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:sequence minOccurs="1"
maxOccurs="unbounded">
<xsd:element
name="contentType" type="req:ContentType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element ref="req:referenceTimestamp"
minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
And here is the code for marshalling objects to it :
/*
* Created on Jan 14, 2005
*
*/
package services.ice.catalog;
import java.io.PrintWriter;
import services.ice.catalog.xmlbind.*;
import services.ice.catalog.xmlbind.types.*;
import org.exolab.castor.xml.*;
/**
* @author Kenneth Stephen
*
*/
public class Client
{
ListRequest createRequest()
{
Locale l = new Locale();
l.setLanguage("en");
l.setCountry("US");
ContentTypeListItem ctli = new ContentTypeListItem();
ctli.setContentType(ContentType.OI700);
ContentTypeList ctl = new ContentTypeList();
ctl.addContentTypeListItem(ctli);
ctli.setContentType(ContentType.OI900);
ctl.addContentTypeListItem(ctli);
ListRequest lr = new ListRequest();
lr.setLocale(l);
lr.setContentTypeList(ctl);
return lr;
}
public static void main(String [] args) throws MarshalException,
ValidationException
{
Client cl = new Client();
ListRequest req = cl.createRequest();
req.marshal(new PrintWriter(System.out));
}
}
The output is :
<?xml version="1.0" encoding="UTF-8"?>
<listRequest xmlns="http://w3.ibm.com/xmlns/srv/cs/catalog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="listRequest">
<locale>
<language>en</language>
<country>US</country>
</locale>
<contentTypeList>
<contentType>OI900</contentType>
<contentType>OI900</contentType>
</contentTypeList>
</listRequest>
There are two issues here :
1. The listingType element really is an anonymous type according to
the schema. Hence for the marshaller to declare that it is of type
"listRequest" is incorrect.
2. How do I get the marshaller to spit out a schema location hint?
In other words, what I would like to see is :
<listRequest xmlns="http://w3.ibm.com/xmlns/srv/cs/catalog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://w3.ibm.com/xmlns/srv/cs/catalog
ListingRequest.xsd"
Thanks,
Kenneth
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user