Shiva- I'm not sure, but you may need to turn namespace processing on in castor.properties. Unfortunately I don't remember the exact property off the top of my head, but I believe it exists and is commented out in the default properties file (check in the JAR file if no where else).
Stephen On 2/14/06, Shiva P. Kodityala <[EMAIL PROTECTED]> wrote: > I could not get this... > > XSD: > > <?xml version="1.0" encoding="UTF-8"?> > <schema > xmlns="http://www.w3.org/2001/XMLSchema" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNameSpace="http://www.fedex.com/fsmapi" > elementFormDefault="qualified" > > > <element name="TryRequest"> > <complexType> > <sequence> > <element name="TryHeader"> > <complexType> > <sequence> > <element > name="CustomerTransactionIdentifier" type="string"/> > <element > name="AccountNumber" type="integer"/> > <element > name="MeterNumber" type="integer"/> > <element > name="CarrierCode" type="string"/> > </sequence> > </complexType> > </element> > </sequence> > <attribute name="noNamespaceSchemaLocation" > type="string"/> > </complexType> > </element> > </schema> > > Generated the classes using org.exolab.castor.builder.SourceGenerator. > When an instance of XML is created / marshalled, I am not getting > targetNameSpace in it. For ex: > > <?xml version="1.0" encoding="UTF-8"?> > <TryRequest > noNamespaceSchemaLocation="FDXShipRequest.xsd"><TryHeader><CustomerT > ransactionIdentifier>CTID</CustomerTransactionIdentifier><AccountNumber>4321</Ac > countNumber><MeterNumber>1234</MeterNumber><CarrierCode>FDXE</CarrierCode></TryH > eader></TryRequest> > > > I want to see "http://www.fedex.com/fsmapi" in TryRequest tag. > > > Marshalling code: > TryRequest tryRequest = new TryRequest(); > TryHeader tryHeader = new TryHeader(); > tryHeader.setMeterNumber(1234); > tryHeader.setCustomerTransactionIdentifier("CTID"); > tryHeader.setCarrierCode("FDXE"); > tryHeader.setAccountNumber(4321); > tryRequest.setTryHeader(tryHeader); > tryRequest.setNoNamespaceSchemaLocation("FDXShipRequest.xsd"); > StringWriter stringWriter = new StringWriter(); > tryRequest.marshal(stringWriter); > System.out.println(stringWriter.getBuffer().toString()); > > > > > > Keith advised me to keep targetNameSpace in xsd. May be I am doing something > wrong... Do I need to set it somewhere while marshalling? > > Thanks for any help. > > > -----Original Message----- > From: Shiva P. Kodityala [mailto:[EMAIL PROTECTED] > Sent: Friday, February 03, 2006 12:48 PM > To: [email protected] > Subject: RE: [castor-user] XSD generation > > > Hi Keith > > Could you help me giving a sample? I have three attributes here.. xmlns:api, > xmlns:xsi, xsi:noNamespaceSchemaLocation. > > > Thanks > Shiva. > > > > > <TryRequest xmlns:api="http://www.fedex.com/fsmapi" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:noNamespaceSchemaLocation="FDXRateRequest.xsd"> > -- > -- > > -----Original Message----- > From: Visco [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 02, 2006 10:01 PM > To: [email protected] > Subject: Re: [castor-user] XSD generation > > > If you set the targetNamespace in your schema you should see the > namespaces in the output. > > --Keith > > Shiva P. Kodityala wrote: > > My sample xml is as below: > > > > <TryRequest xmlns:api="http://www.fedex.com/fsmapi" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:noNamespaceSchemaLocation="FDXRateRequest.xsd"> > > <TryHeader> > > <CustomerTransactionIdentifier>CTIString</CustomerTransactionIdentifier> > > <AccountNumber>123456789</AccountNumber> > > <MeterNumber>1234567</MeterNumber> > > <CarrierCode>FDXE</CarrierCode> > > </TryHeader> > > </Try> > > > > When I generated XSD: > > <?xml version="1.0" encoding="UTF-8"?> > > <schema xmlns="http://www.w3.org/2001/XMLSchema" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > <element name="TryRequest"> > > <complexType> > > <sequence> > > <element name="TryHeader"> > > <complexType> > > <sequence> > > <element name="CustomerTransactionIdentifier1" > > type="string"/><element name="AccountNumber1" type="integer"/> > > <element name="MeterNumber1" type="integer"/> > > <element name="CarrierCode1" type="string"/> > > </sequence> > > </complexType> > > </element> > > </sequence> > > <attribute name="noNamespaceSchemaLocation" type="string"/> > > </complexType> > > </element> > > </schema> > > > > Generated classes for this XSD and created an instance of the TryRequest > > class and unmarshalled it to create XML string. In this XML: I do not see > > xmlns:api="http://www.fedex.com/fsmapi" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > in <TryRequest ...> tag. > > > > How can I get these strings( into the main tag as attributes..) > > programmatically. > > > > Thanks > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > ------------------------------------------------- > > 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] > ------------------------------------------------- > > > ------------------------------------------------- > 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] > ------------------------------------------------- > >

