I have figured out what to add to my schema to validate a collection of
Gene objects.
<xs:element name="collection">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
All I need now is to figure out how to manipulate the castor mapping
file or the marshaller to output a single document containing an array
of like objects. I could still use any tips on that process.
Thanks,
Mike Connolly
National Cancer Institute
Center for Bioinformatics
-----Original Message-----
From: Connelly, Mike (NIH/NCI)
Sent: Friday, November 18, 2005 10:25 AM
To: [email protected]
Subject: [castor-user] Using castor to process a result set to a single
xml document.
Good morning,
I am working on a software developer kit that generates xml schemas
and castor mapping files based on a uml model. I have written an
XMLUtility class that has a toXML(Object a) and fromXML(File a) method
which converts java objects to xml and back again using castor and the
mapping file generated from my model. This works fine. Validating my xml
using the JDK 1.5 Validator class with my model based schemas is also
working fine.
Now, my problem. I want to be able to marshal a collection of objects
into one xml file that I can validate with my schema. Iterating through
the collection and marshalling one at a time is no problem but the model
based castor mapping file and schema won't work with a collection of
generated objects.
The following is an example of my current single object xml output:
<?xml version="1.0" encoding="UTF-8"?>
<GeneImpl
xmlns="gme://caCORE.cabig/3.0/gov.nih.nci.cabio.domain">
<id>63060</id>
<fullName>Biogenesis of lysosome</fullName>
<clusterId>124685</clusterId>
<symbol>Bloc1s2</symbol>
</GeneImpl>
The following is my castor mapping:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN" "http://www.castor.org/mapping.dtd">
<mapping>
<class name="gov.nih.nci.cabio.domain.impl.GeneImpl">
<map-to xml="GeneImpl"
ns-uri="gme://caCORE.cabig/3.0/gov.nih.nci.cabio.domain" />
<field name="id" type="long">
<bind-xml name="id" node="element" />
</field>
<field name="fullName" type="string">
<bind-xml name="fullName" node="element" />
</field>
<field name="clusterId" type="long">
<bind-xml name="clusterId" node="element" />
</field>
<field name="symbol" type="string">
<bind-xml name="symbol" node="element" />
</field>
</class>
</mapping>
Lastly, the following is a portion of my schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="gme://caCORE.cabig/3.0/gov.nih.nci.cabio.domain"
targetNamespace="gme://caCORE.cabig/3.0/gov.nih.nci.cabio.domain"
elementFormDefault="qualified">
<xs:element name="GeneImpl" type="GeneImpl" />
<xs:complexType name="GeneImpl">
<xs:sequence>
<xs:element name="id" type="xs:long" />
<xs:element name="fullName" type="xs:string" minOccurs="0" />
<xs:element name="clusterId" type="xs:long" minOccurs="0" />
<xs:element name="symbol" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
If I have a result set from my database with 100 Gene objects I want to
use castor to produce a single document that I can later convert back
into the original 100 java objects and validate with my schema. I'm sure
someone must have done this type of operation before. I think there is
probabaly something I can add to my schema and mapping file that will
allow it to process collections of objects, but I am not sure. Any ideas
would be greatly appreciated.
Thanks,
Mike Connolly
National Cancer Institute
Center for Bioinformatics
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message
to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------