Hi Castor Guys,
 
I am using it to validate data. What I am doing is to create a xml schema, specify a pattern for each simple type and then convert this file using castor to java beans. Using the generated java classes I invoke the method validate() to validate the data. This seems to work quite well for the purposes of the project. However, I find it a little awkward to instantiate an object and use the various set methods before calling the validate method. This is how it works:
 
LayoutsRASC lrasc = new LayoutsRASC();
lrasc.setTipoRegHA("13");
lrasc.setIdentificacionRegHA("ASOC-RES");
lrasc.setClaveEmisorHA("08");
lrasc.validate();
 
It would be nice to indicate Castor to generate a method (the constructor itself?) that could receive an array of elements or an Enumeration object and then, in the body of the method, invoke the varios set methods, more less like this:
 
LayoutsRASC lrasc = new LayoutsRASC();
Enumeration e = v.elements();
lrasc.methodToBeCreated(e);
lra.validate();
 
Then the body of the created method would be something like this:
 
public void methodToBeCreated(Enumeration e)  {  
  setTipoRegHA(e.nextElement());
  setIdentificacionRegHA(e.nextElement());
  setClaveEmisorHA(e.nextElement());
}
Is there any way I could indicate Castor to generate such a method? Do I have to generate a mapping file or something else?  Any help is greatly appreciated.  Thanks!

The xml schema I am using (a little shorter for the sake of simplicity) is as follows:
<?xml version="1.0"?>
  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="formatoRASC">
      <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="layoutsRASC" minOccurs="0" maxOccurs="unbounded">
            <xsd:complexType>
              <xsd:sequence>
                  <xsd:element name="tipoRegHA" minOccurs="0"> 
                      <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                          <xsd:length value="2"/>
                          <xsd:pattern value="13"/>
                        </xsd:restriction>
                      </xsd:simpleType>
               </xsd:element>
              
               <xsd:element name="identificacionRegHA" minOccurs="0">
                 <xsd:simpleType>
                   <xsd:restriction base="xsd:string">
                     <xsd:length value="8"/>
                     <xsd:pattern value="ASOC-RES"/>
                   </xsd:restriction>
                 </xsd:simpleType>
               </xsd:element>
                
               <xsd:element name="claveEmisorHA" minOccurs="0">
                 <xsd:simpleType>
                   <xsd:restriction base="xsd:string">
                     <xsd:length value="2"/>
                     <xsd:pattern value="08"/>
                   </xsd:restriction>
                 </xsd:simpleType>
               </xsd:element>
            </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
</xsd:schema>
 

 


Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to