|
Hi Arnaud,
By saying "dropping namespaces I mean that the XML
which is being marshalled (written to file) by my castor generated classes, does
not include the namespace tags which are defined in my XML Schema, and which
must form part of the xml document for it to be well formed.
This is an example of what the generated XML should
look like:
<transactflex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="{0}"> <header
codtran="7001"/> <txndata> <accountdtls
accountno="101120000028"/>
</txndata> </transactflex>
This is an example of what the generated XML does
look like:
<?xml
version="1.0"?> <transactflex> <header
codtran="7001"/> <txndata> <accountdtls
accountno="101120000028"/> </txndata> </transactflex>
I have tried to instantiate the Marshaller
programattically and pass the generated object model of the schema to the
Marshaller to marshall. I have tried to set parameters on the marshaller to
force the nameapsace statements. This too has not worked.
I have
used org.exolab.castor.builder.SourceGenerator to generate the classes
which represent my XML Schema.
The precise command follows:
java org.exolab.castor.builder.SourceGenerator -i
1001.xsd -f -types j2 -dest C:\java_dirs\cafeintegration\src -package
xml1001
I have covered the pdf ""SourceGeneratorUse.pdf" to
investigate what you meant by Generating Discriptor classes. According to the
pdf, the Source Generator does in fact generate source which includes an object model of the
schema as well as the necessary Class Descriptors used by the marshalling
framework to obtain information about the generated classes.
So it would seem that the class descriptors are
there.
Any other ideas? Currently I am marshalling to a
String Buffer and manually inserting the namespace statements into the string.
This works but is a very bad example of how to do it.
Many thanks and kind regards
Scott.
----- Original Message -----
Sent: Monday, June 03, 2002 5:05 PM
Subject: Re: [castor-dev] Castor
generated XML.
Hi
Scott,
What do you mean
exactly by �dropping� namespaces? Are you sure you are generating the
descriptor classes and that they are compiled?
Arnaud
-----Original
Message----- From: Scott
Venter [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 3:37
PM To: [EMAIL PROTECTED] Subject: [castor-dev] Castor generated
XML.
I agree with you. The Generated
calsses are dropping the namespace.
I have manually
instantiated the Marshaller class, and I have set the following
properties as such:
org.exolab.castor.xml.Marshaller vMarshaller =
new
org.exolab.castor.xml.Marshaller(out);
vMarshaller.setDebug(true);
vMarshaller.setMarshalAsDocument(true); //tried true
and false, no success
vMarshaller.setNSPrefixAtRoot(true);
//tried true and false, no success
vMarshaller.setValidation(true);
vMarshaller.marshal(vTransactflex, vWriter);
However my generated XML
still does not include the necessary namespace
declarations.
Would you be kind enough to post
an example of what you guys are doing programatically. (Please) Obviously I
would only be interested in the particular aspects of forcing the API to
generate XML which includes namespace details.
I simply can not beleive that the
Castor API would generate non Namespaced XML. So I think the error lies with
me.
Many thanks and kind
regards
----- Original Message -----
Sent: Monday,
June 03, 2002 1:21 PM
Subject: Re:
[castor-dev] Castor generated XML.
> 1) The marshal method is
outputting a single string which has no formatting. Is this a
problem?
No, this shouldn't be a problem
for any XML parser.
However, you can force Castor to
produce formatted output by setting the
org.exolab.castor.indent=true property
in the castor.properties file.
> 2) The first line reads
<?xml version="1.0"?> and it should not be there, according to the
second XML Structure.
This is a standard XML data
prefix, which should also be accepted by an XML
parser.
> 3) Some fields in the
Castor generated XML have been dropped.
I suppose you mean the namespace
attributes.
This is proabably what causes
the application to reject the generated XML.
I think there is a way to force
Castor to include this, however, don't know how this works
with
the Castor source generator (we
are writing our classes and mapping files manually).
Heiko
Erhardt skynamics AG www.skynamics.com
-----Original
Message----- From: Scott
Venter [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 12:46
PM To:
[EMAIL PROTECTED] Subject: [castor-dev] Castor
generated XML.
I am using Castor version
0.9.3.9 and in partcular, I am using the XML Schema binding functionality,
to generate classes which represent my XML Schema.
Once I have generated the
classes, and implemented them, I noticed that the marshaled data which I
get from these classes only loosely resembles the XML data I should be
seeing.
I have attached first the
structure generated by my Castor classes, and then the structure the way
it should be.
<?xml
version="1.0"?> <transactflex><header
codtran="7001"/><txndata><accountdtls
accountno="101120000028"/></txndata></transactflex>
<transactflex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="{0}"> <header
codtran="7001"/>
<txndata> <accountdtls
accountno="101120000028"/>
</txndata> </transactflex>
There are three problems in
particular that I notice in the Castor generated XML.
1) The marshal method is
outputting a single string which has no formatting. Is this a
problem?
2) The first line reads
<?xml version="1.0"?> and it should not be there, according to the
second XML Structure.
3) Some fields in the Castor
generated XML have been dropped.
Could anyone please advise me
as to why the Castor generated XML is so vastly different to the Second
structure, which was supplied to me by the vendor, and consequently
works.
The Castor generated XML
structure is deemed not valid by the server I am sending it to, but the
second structure is accepted and I receive a valid response when sending
it to the server.
Many thanks and kind
regards
|