Hi Matthew,

Matthew Erler wrote:
> I hope that this looks better:
> <?xml version="1.0" encoding="UTF-8"?>
> <PatientContact MessageId="1234"><callInfo Patient_First_Name="John" 
> Patient_Last_Name="Smith"/></PatientContact>
No, that cannot be configured on Castor itself, as Castor internally
relies on a SAX parser's Serializer (and OutputFormat) to generate the
XML prologe (or not, if you wish so).

> If it isn't apparent the line break is right before the starting 
> <PatientContact> tag.  Can that be supressed?
> You are correct in your statement below.  I would like 
> <callInfo>...</callInfo> rather than <callInfo/>.  Is that possible?  Thanks 
> in advance.
I still have to look into this in detail, but somehow I think the answer
will be very similar.

Cheers
Werner

> 
> --- On Sun, 3/29/09, Werner Guttmann <[email protected]> wrote:
> From: Werner Guttmann <[email protected]>
> Subject: Re: [castor-user] FW: New user questions: Line break and implicit 
> tag closing in XML.
> To: [email protected]
> Date: Sunday, March 29, 2009, 7:02 AM
> 
> Hi Matthew,
> 
> which line break are you talking about in particular ? It looks to me
> like you email client rewrapped lines before sending things, you please
> try to make it more explicit.
> 
> Werner
> 
> Matthew Erler wrote:
>> I'm a 
>> new Castor user and am ramping up on how it works.  I need to 
>> format Castor's XML output differently than how Castor seems 
>> to generate it by default.  In the following example XML output I'd 
>> like to know if it's possible to:
>> 1.  Suppress 
>> the line break.
>> 2.  Explicitly 
>> close <callInfo> rather than 
>> implicitly.
> You mean have <callInfo>...</callInfo> rather than
> <callInfo/> ?
> 
>> <?xml 
>> version="1.0" encoding="UTF-8"?>
>> <PatientContact 
>> MessageId="1234"><callInfo
> Patient_First_Name="John" 
>> Patient_Last_Name="Smith"/></PatientContact>
>> Thanks in 
>> advance.
>> -Matthew
>> Here is my 
>> mapping file:
>> <?xml 
>> version="1.0"?>
>> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD 
>> Version 1.0//EN" "http://castor.org/mapping.dtd";>
>> <mapping>
>>   
>> <class name="com.uht.example.PatientContact">
>>     
>> <map-to xml="PatientContact" />
>>     <field 
>> name="messageId" type="java.lang.String">
>>       
>> <bind-xml name="MessageId" node="attribute"  />
>>     
>> </field>  
>>     <field name="callInfo" 
>> type="com.uht.example.PatientCallInfo">
>>       
>> <bind-xml name="callInfo" node="element"  />
>>     
>> </field> 
>>   </class> 
>>   <class 
>> name="com.uht.example.PatientCallInfo">
>>     <field 
>> name="patientFirstName" 
>> type="java.lang.String">
>>       <bind-xml 
>> name="Patient_First_Name" node="attribute"  />
>>     
>> </field>     
>>     <field 
>> name="patientLastName" 
>> type="java.lang.String">
>>       <bind-xml 
>> name="Patient_Last_Name" node="attribute"  />
>>     
>> </field>                         
>>
>>   </class>  
>> </mapping>
>> Here is 
>> main():
>> public 
>> static void main(String args[]){
>>  Mapping mapping = new 
>> Mapping();
>>  try {
>>    
>>
> mapping.loadMapping("src/main/resources/patientContactMapping.xml");
>>    
>> PatientCallInfo patient = new PatientCallInfo();
>>    
>> patient.setPatientFirstName("John");
>>    
>> patient.setPatientLastName("Smith");
>>  
>>    PatientContact 
>> patientContact = new PatientContact("1234", patient);
>>    StringWriter stringWriter = new 
>> StringWriter();
>>    Marshaller marshaller = new 
>> Marshaller(stringWriter);
>>    
>> marshaller.setMapping(mapping);
>>    
>> marshaller.marshal(patientContact);
>>    String s = 
>> stringWriter.toString();
>>    
>> System.out.println(s);
>>  }
>>  catch (Exception e) 
>> {
>>   System.out.println(e.toString());
>>  }
>>   
>> } 
>>  
>> Here is the 
>> PatientContact class:
>> public 
>> class PatientContact {
>>   private String messageId;
>>   private 
>> PatientCallInfo callInfo;
>>  
>>   
>> public PatientContact() 
>> {super();}
>> public 
>> PatientContact(String messageId, PatientCallInfo callInfo) 
>> {
>>  super();
>>  this.messageId = messageId;
>>  this.callInfo 
>> = callInfo;
>> }
>> public String getMessageId() {
>>  return 
>> messageId;
>> }
>> public void setMessageId(String messageId) 
>> {
>>  this.messageId = messageId;
>> }
>> public PatientCallInfo 
>> getCallInfo() {
>>  return callInfo;
>> }
>> public void 
>> setCallInfo(PatientCallInfo callInfo) {
>>  this.callInfo = 
>> callInfo;
>> }
>> }
>>  
>> Here is the 
>> PatientCallInfo class:
>> public 
>> class PatientCallInfo {
>>    private String patientFirstName 
>> ="";
>>    private String patientLastName ="";
>>    
>>  public PatientCallInfo() 
>> {super();}
>>  
>>  public PatientCallInfo(String patientFirstName, 
>> String patientLastName) 
>> {
>>   super();
>>   this.patientFirstName = 
>> patientFirstName;
>>   this.patientLastName = 
>> patientLastName;
>>  }
>>  public String getPatientFirstName() 
>> {
>>   return patientFirstName;
>>  }
>>  public void 
>> setPatientFirstName(String patientFirstName) 
>> {
>>   this.patientFirstName = 
>> patientFirstName;
>>  }
>>  public String getPatientLastName() 
>> {
>>   return patientLastName;
>>  }
>>  public void 
>> setPatientLastName(String patientLastName) {
>>   this.patientLastName 
>> = patientLastName;
>>  }
>> }
>>
>>
>>       
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 
> 
> 
>       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to