Hello all!

The castor-0.9.5.2 does not generate sub elements, while older version (I
am not sure, but is should be 0.8) does.
So I have this Schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
      <xs:element name="Criterias">
      <xs:annotation>
              <xs:documentation>
              Parameter spravy PICKED_CRITERIAS, PID je ID usera, ktory
zasiela kriteria, Name je nazov celeho vyberu.
</xs:documentation>
          </xs:annotation>
          <xs:complexType>
              <xs:sequence>
              <xs:element ref="Criterium" maxOccurs="unbounded"/>
              </xs:sequence>
              <xs:attribute name="Name" type="xs:string"
use="required"/>
<xs:attribute name="PID" type="xs:int"/>
<xs:attribute name="DateOfInsertion" type="xs:string"/>
      </xs:complexType>
      </xs:element>
      <xs:element name="Criterium">
          <xs:complexType>
          <xs:simpleContent>
                  <xs:extension base="xs:string">
                  <xs:attribute name="id" type="xs:string"
use="required"/>
<xs:attribute name="name" type="xs:string"
use="optional"/>
</xs:extension>
          </xs:simpleContent>
          </xs:complexType>
</xs:element>
</xs:schema>

Corresponding XML file should be:
<?xml version="1.0" encoding="UTF-8"?>
<Criterias xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\projekty\ISMS\XSD\criterias.xsd"
Name="String" PID="0" DateOfInsertion="String">
      <Criterium id="String" name="String">String</Criterium>
      <Criterium id="String" name="String">String</Criterium>
</Criterias>

I used:
java -cp .;castor-0.9.5.2.jar;xerces.jar
org.exolab.castor.builder.SourceGenerator -i criterias.xsd -package
sk.tempest.j2ee.isms.model -types j2

to generate this files:
/*
* This class was automatically generated with
* <a href="">Castor 0.9.5.2</a>, using an XML
* Schema.
* $Id$
*/

package sk.tempest.j2ee.isms.model;

//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/

import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Enumeration;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;

/**
* Parameter spravy PICKED_CRITERIAS, PID je ID usera, ktory
* zasiela kriteria, Name je nazov celeho vyberu.
*
*
* @version $Revision$ $Date$
*/
public class Criterias implements java.io.Serializable {

      //--------------------------/
      //- Class/Member Variables -/
    //--------------------------/

    /**
    * Field _name
    */
    private java.lang.String _name;

    /**
    * Field _PID
    */
    private int _PID;

    /**
    * keeps track of state for field: _PID
    */
    private boolean _has_PID;

    /**
    * Field _dateOfInsertion
    */
    private java.lang.String _dateOfInsertion;

    /**
    * Field _criteriumList
    */
    private java.util.ArrayList _criteriumList;

      //----------------/
      //- Constructors -/
    //----------------/

    public Criterias() {
    super();
    _criteriumList = new ArrayList();
    } //-- sk.tempest.j2ee.isms.model.Criterias()

      //-----------/
      //- Methods -/
    //-----------/

    /**
    * Method addCriterium
    *
    * @param vCriterium
    */
public void addCriterium(sk.tempest.j2ee.isms.model.Criterium
vCriterium)
    throws java.lang.IndexOutOfBoundsException
    {
    _criteriumList.add(vCriterium);
    } //-- void addCriterium(sk.tempest.j2ee.isms.model.Criterium)

    /**
    * Method addCriterium
    *
    * @param index
    * @param vCriterium
    */
public void addCriterium(int index,
sk.tempest.j2ee.isms.model.Criterium vCriterium)
    throws java.lang.IndexOutOfBoundsException
    {
    _criteriumList.add(index, vCriterium);
    } //-- void addCriterium(int, sk.tempest.j2ee.isms.model.Criterium)

    /**
    * Method clearCriterium
    */
    public void clearCriterium()
    {
    _criteriumList.clear();
    } //-- void clearCriterium()

    /**
    * Method deletePID
    */
    public void deletePID()
    {
    this._has_PID= false;
    } //-- void deletePID()

    /**
    * Method enumerateCriterium
    */
    public java.util.Enumeration enumerateCriterium()
    {
return new
org.exolab.castor.util.IteratorEnumeration(_criteriumList.iterator());
    } //-- java.util.Enumeration enumerateCriterium()

    /**
    * Method getCriterium
    *
    * @param index
    */
    public sk.tempest.j2ee.isms.model.Criterium getCriterium(int index)
    throws java.lang.IndexOutOfBoundsException
    {
    //-- check bounds for index
    if ((index < 0) || (index > _criteriumList.size())) {
        throw new IndexOutOfBoundsException();
        }
return (sk.tempest.j2ee.isms.model.Criterium)
_criteriumList.get(index);
    } //-- sk.tempest.j2ee.isms.model.Criterium getCriterium(int)

    /**
    * Method getCriterium
    */
    public sk.tempest.j2ee.isms.model.Criterium[] getCriterium()
    {
        int size = _criteriumList.size();
        sk.tempest.j2ee.isms.model.Criterium[] mArray = new
sk.tempest.j2ee.isms.model.Criterium[size];
for (int index = 0; index < size; index++) {
mArray[index] = (sk.tempest.j2ee.isms.model.Criterium)
_criteriumList.get(index);
        }
        return mArray;
    } //-- sk.tempest.j2ee.isms.model.Criterium[] getCriterium()

    /**
    * Method getCriteriumCount
    */
    public int getCriteriumCount()
    {
    return _criteriumList.size();
    } //-- int getCriteriumCount()

    /**
    * Returns the value of field 'dateOfInsertion'.
    *
    * @return the value of field 'dateOfInsertion'.
    */
    public java.lang.String getDateOfInsertion()
    {
    return this._dateOfInsertion;
    } //-- java.lang.String getDateOfInsertion()

    /**
    * Returns the value of field 'name'.
    *
    * @return the value of field 'name'.
    */
    public java.lang.String getName()
    {
    return this._name;
    } //-- java.lang.String getName()

    /**
    * Returns the value of field 'PID'.
    *
    * @return the value of field 'PID'.
    */
    public int getPID()
    {
    return this._PID;
    } //-- int getPID()

    /**
    * Method hasPID
    */
    public boolean hasPID()
    {
    return this._has_PID;
    } //-- boolean hasPID()

    /**
    * Method isValid
    */
    public boolean isValid()
    {
        try {
        validate();
        }
        catch (org.exolab.castor.xml.ValidationException vex) {
        return false;
        }
        return true;
    } //-- boolean isValid()

    /**
    * Method marshal
    *
    * @param out
    */
    public void marshal(java.io.Writer out)
    throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
    Marshaller.marshal(this, out);
    } //-- void marshal(java.io.Writer)

    /**
    * Method marshal
    *
    * @param handler
    */
    public void marshal(org.xml.sax.ContentHandler handler)
    throws java.io.IOException, org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
    Marshaller.marshal(this, handler);
    } //-- void marshal(org.xml.sax.ContentHandler)

    /**
    * Method removeCriterium
    *
    * @param vCriterium
    */
public boolean removeCriterium(sk.tempest.j2ee.isms.model.Criterium
vCriterium)
    {
    boolean removed = _criteriumList.remove(vCriterium);
    return removed;
    } //-- boolean removeCriterium(sk.tempest.j2ee.isms.model.Criterium)

    /**
    * Method setCriterium
    *
    * @param index
    * @param vCriterium
    */
public void setCriterium(int index,
sk.tempest.j2ee.isms.model.Criterium vCriterium)
    throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _criteriumList.size())) {
        throw new IndexOutOfBoundsException();
        }
        _criteriumList.set(index, vCriterium);
    } //-- void setCriterium(int, sk.tempest.j2ee.isms.model.Criterium)

    /**
    * Method setCriterium
    *
    * @param criteriumArray
    */
public void setCriterium(sk.tempest.j2ee.isms.model.Criterium[]
criteriumArray)
    {
    //-- copy array
    _criteriumList.clear();
    for (int i = 0; i < criteriumArray.length; i++) {
        _criteriumList.add(criteriumArray[i]);
        }
    } //-- void setCriterium(sk.tempest.j2ee.isms.model.Criterium)

    /**
    * Sets the value of field 'dateOfInsertion'.
    *
    * @param dateOfInsertion the value of field 'dateOfInsertion'.
    */
    public void setDateOfInsertion(java.lang.String dateOfInsertion)
    {
    this._dateOfInsertion = dateOfInsertion;
    } //-- void setDateOfInsertion(java.lang.String)

    /**
    * Sets the value of field 'name'.
    *
    * @param name the value of field 'name'.
    */
    public void setName(java.lang.String name)
    {
    this._name = name;
    } //-- void setName(java.lang.String)

    /**
    * Sets the value of field 'PID'.
    *
    * @param PID the value of field 'PID'.
    */
    public void setPID(int PID)
    {
        this._PID = PID;
        this._has_PID = true;
    } //-- void setPID(int)

    /**
    * Method unmarshal
    *
    * @param reader
    */
    public static java.lang.Object unmarshal(java.io.Reader reader)
    throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
return (sk.tempest.j2ee.isms.model.Criterias)
Unmarshaller.unmarshal(sk.tempest.j2ee.isms.model.Criterias.class, reader);
    } //-- java.lang.Object unmarshal(java.io.Reader)

    /**
    * Method validate
    */
    public void validate()
    throws org.exolab.castor.xml.ValidationException
    {
    org.exolab.castor.xml.Validator validator = new
org.exolab.castor.xml.Validator();
validator.validate(this);
    } //-- void validate()
}

and

*
* This class was automatically generated with
* <a href="">Castor 0.9.5.2</a>, using an XML
* Schema.
* $Id$
*/

package sk.tempest.j2ee.isms.model;

//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/

import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;

/**
* Class Criterium.
*
* @version $Revision$ $Date$
*/
public class Criterium implements java.io.Serializable {

      //--------------------------/
      //- Class/Member Variables -/
    //--------------------------/

    /**
    * internal content storage
    */
    private java.lang.String _content = "";

    /**
    * Field _id
    */
    private java.lang.String _id;

    /**
    * Field _name
    */
    private java.lang.String _name;

      //----------------/
      //- Constructors -/
    //----------------/

    public Criterium() {
    super();
    setContent("");
    } //-- sk.tempest.j2ee.isms.model.Criterium()

      //-----------/
      //- Methods -/
    //-----------/

    /**
    * Returns the value of field 'content'. The field 'content'
    * has the following description: internal content storage
    *
    * @return the value of field 'content'.
    */
    public java.lang.String getContent()
    {
    return this._content;
    } //-- java.lang.String getContent()

    /**
    * Returns the value of field 'id'.
    *
    * @return the value of field 'id'.
    */
    public java.lang.String getId()
    {
    return this._id;
    } //-- java.lang.String getId()

    /**
    * Returns the value of field 'name'.
    *
    * @return the value of field 'name'.
    */
    public java.lang.String getName()
    {
    return this._name;
    } //-- java.lang.String getName()

    /**
    * Method isValid
    */
    public boolean isValid()
    {
        try {
        validate();
        }
        catch (org.exolab.castor.xml.ValidationException vex) {
        return false;
        }
        return true;
    } //-- boolean isValid()

    /**
    * Method marshal
    *
    * @param out
    */
    public void marshal(java.io.Writer out)
    throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
    Marshaller.marshal(this, out);
    } //-- void marshal(java.io.Writer)

    /**
    * Method marshal
    *
    * @param handler
    */
    public void marshal(org.xml.sax.ContentHandler handler)
    throws java.io.IOException, org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
    Marshaller.marshal(this, handler);
    } //-- void marshal(org.xml.sax.ContentHandler)

    /**
    * Sets the value of field 'content'. The field 'content' has
    * the following description: internal content storage
    *
    * @param content the value of field 'content'.
    */
    public void setContent(java.lang.String content)
    {
    this._content = content;
    } //-- void setContent(java.lang.String)

    /**
    * Sets the value of field 'id'.
    *
    * @param id the value of field 'id'.
    */
    public void setId(java.lang.String id)
    {
    this._id = id;
    } //-- void setId(java.lang.String)

    /**
    * Sets the value of field 'name'.
    *
    * @param name the value of field 'name'.
    */
    public void setName(java.lang.String name)
    {
    this._name = name;
    } //-- void setName(java.lang.String)

    /**
    * Method unmarshal
    *
    * @param reader
    */
    public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
    {
    return (sk.tempest.j2ee.isms.model.Criterium)
Unmarshaller.unmarshal(sk.tempest.j2ee.isms.model.Criterium.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader)
    /**
    * Method validate
    */
    public void validate()
    throws org.exolab.castor.xml.ValidationException
    {
    org.exolab.castor.xml.Validator validator = new
org.exolab.castor.xml.Validator();
validator.validate(this);
    } //-- void validate()
}
(and corresponding descriptions, I am not going to send (but I can if you
want me to).
Using new castor (and it's method marshal I get this:)
<?xml version="1.0" encoding="UTF-8"?>
<Criterias Name="Prva" PID="12345" DateOfInsertion="20.11.2003"><Criterium
xsi:type="java:[Lsk.tempest.j2ee.isms.model.Criterium;"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></Criterias>

What does not look like correct XML (based on my Schema).

Using the old castor I get:
<Criterias xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\projekty\ISMS\XSD\criterias.xsd"
Name="ABC" PID="123" DateOfInsertion="01.01.2003">
      <Criterium id="1" name="abc">T1</Criterium>
      <Criterium id="2" name="abc">T2</Criterium>
</Criterias>

I would like to use new ersion of castor because of other reasons. What is
wrong? What am I missing?

Thanks for help
Regards
Michal
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev

Reply via email to