Marshalling an Object into XML using org.exolab.castor.xml.Marshaller yields a 
sligthly different looking XML document on each invocation. The reason for this seems 
to be the use of the NAMESPACE_COUNTER which is declared as a static variable. 

private static int NAMESPACE_COUNTER = 0;

Although the generated document is valid, it would be nice to get the same document 
everytime, so that it can be used in applications like ours that generate a hash based 
on this XMl Document. 

To generate the same namespace number everytime, we simply declare this as variable 
within the marshal() method itself and initialized it to zero.

        int[] NAMESPACE_COUNTER = new int[1];
        NAMESPACE_COUNTER[0] = 0;

We declared this as an array so that we can pass it along to the method resolveQName() 
which can change the variable inside the method and still reflect it the changes in 
the marshal() method.

I have attached the fixes. If these changes are OK, could someone please commit this 
into CVS. If you have a better solution than the array, please do let me know.

Thanks

Abhideep



Attachment: Marshaller.java
Description: Marshaller.java

Reply via email to