The Library.java is as follows...

import java.io.IOException;

import java.io.Reader;

import java.io.Serializable;

import java.io.Writer;

import java.util.Enumeration;

import java.util.Vector;

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 Library.

*

* @version $Revision$ $Date$

*/

public class Library implements java.io.Serializable {

 

//--------------------------/

//- Class/Member Variables -/

//--------------------------/

/**

* Field _publicationList

*/

private java.util.Vector _publicationList;

 

//----------------/

//- Constructors -/

//----------------/

public Library() {

super();

_publicationList = new Vector();

} //-- xsitype1.Library()

 

//-----------/

//- Methods -/

//-----------/

/**

* Method addPublication

*

* @param vPublication

*/

public void addPublication(xsitype1.PublicationType vPublication)

throws java.lang.IndexOutOfBoundsException

{

_publicationList.addElement(vPublication);

} //-- void addPublication(xsitype1.PublicationType)

/**

* Method addPublication

*

* @param index

* @param vPublication

*/

public void addPublication(int index, xsitype1.PublicationType vPublication)

throws java.lang.IndexOutOfBoundsException

{

_publicationList.insertElementAt(vPublication, index);

} //-- void addPublication(int, xsitype1.PublicationType)

/**

* Method enumeratePublication

*/

public java.util.Enumeration enumeratePublication()

{

return _publicationList.elements();

} //-- java.util.Enumeration enumeratePublication()

/**

* Method getPublication

*

* @param index

*/

public xsitype1.PublicationType getPublication(int index)

throws java.lang.IndexOutOfBoundsException

{

//-- check bounds for index

if ((index < 0) || (index > _publicationList.size())) {

throw new IndexOutOfBoundsException();

}

return (xsitype1.PublicationType) _publicationList.elementAt(index);

} //-- xsitype1.PublicationType getPublication(int)

/**

* Method getPublication

*/

public xsitype1.PublicationType[] getPublication()

{

int size = _publicationList.size();

xsitype1.PublicationType[] mArray = new xsitype1.PublicationType[size];

for (int index = 0; index < size; index++) {

mArray[index] = (xsitype1.PublicationType) _publicationList.elementAt(index);

}

return mArray;

} //-- xsitype1.PublicationType[] getPublication()

/**

* Method getPublicationCount

*/

public int getPublicationCount()

{

return _publicationList.size();

} //-- int getPublicationCount()

/**

* 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 removeAllPublication

*/

public void removeAllPublication()

{

_publicationList.removeAllElements();

} //-- void removeAllPublication()

/**

* Method removePublication

*

* @param index

*/

public xsitype1.PublicationType removePublication(int index)

{

java.lang.Object obj = _publicationList.elementAt(index);

_publicationList.removeElementAt(index);

return (xsitype1.PublicationType) obj;

} //-- xsitype1.PublicationType removePublication(int)

/**

* Method setPublication

*

* @param index

* @param vPublication

*/

public void setPublication(int index, xsitype1.PublicationType vPublication)

throws java.lang.IndexOutOfBoundsException

{

//-- check bounds for index

if ((index < 0) || (index > _publicationList.size())) {

throw new IndexOutOfBoundsException();

}

_publicationList.setElementAt(vPublication, index);

} //-- void setPublication(int, xsitype1.PublicationType)

/**

* Method setPublication

*

* @param publicationArray

*/

public void setPublication(xsitype1.PublicationType[] publicationArray)

{

//-- copy array

_publicationList.removeAllElements();

for (int i = 0; i < publicationArray.length; i++) {

_publicationList.addElement(publicationArray[i]);

}

} //-- void setPublication(xsitype1.PublicationType)

/**

* Method unmarshalLibrary

*

* @param reader

*/

public static java.lang.Object unmarshalLibrary(java.io.Reader reader)

throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException

{

return (xsitype1.Library) Unmarshaller.unmarshal(xsitype1.Library.class, reader);

} //-- java.lang.Object unmarshalLibrary(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()

}



Keith Visco <[EMAIL PROTECTED]> wrote:


What does the code for Library look like?

Castor is somehow getting two copies of the same BookType instance.

--Keith

[EMAIL PROTECTED] wrote:
>
> I'm trying trying to marshall java objects. Its marshalling as below.
>
>
>
>
> > xmlns:ns1="http://www.books.org"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> Illusions The Adventures of a Reluctant Messiah
> Richard Bach
> 1977
> 0-440-34319-4
> Dell Publishing Co.
>

> > xmlns:ns2="http://www.books.org"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> Illusions The Adventures of a Reluctant Messiah
> Richard Bach
> 1977
> 0-440-34319-4
> Dell Publishing Co.
>

>

>
> I've created only one java object of BookType ans marshalled it. When
> I looked into the xml file its showing two objects.
>
> My java code is as follows..
>
>
> Library library=new Library();
>
> BookType book=new BookType();
>
> String [] authors={"Richard Bach"};
>
> book.setAuthor(authors);
>
> book.setDate(new GYear(1977));
>
> book.setISBN("0-440-34319-4");
>
> book.setPublisher("Dell Publishing Co.");
>
> book.setTitle("Illusions The Adventures of a Reluctant Messiah");
>
> library.addPublication(book);
>
> Writer writer = new FileWriter(file);
>
> Marshaller marshaller = new Marshaller(writer);
>
> marshaller.setMapping(map);
>
> marshaller.marshal(library);
>
> Could you let me know if I'm doing anything wrong? How to solve this
> problem...
>
>
>
> ----------------------------------------------------------------------
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
>
> ---------------------------------------------------------------
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user



--------------------------------------------------! ---------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user


Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to