Adding annotations to JAXB-generated classes which depend on information in XSD

hdentistuwcc

New Member
I have a WSDL + XSD that needs to be turned into Java classes. That's pretty simple - \[code\]wsimport\[/code\] will handle that without issue. However, I also need to be able to add annotations to the generated classes, and those annotations need to contain information that is contained in the XSD (in particular, they need to reference the \[code\]xsd:maxLength\[/code\] or \[code\]xsd:length\[/code\] properties).Why? Because I plan to transform them into a flat file afterwards, using Bindy. For reference, I know that I can use Annox to add custom annotations to the generated classes, but as far as I'm aware, that would require that either all annotations are identical, with all parameters being identical, or specifying annotations for each element individually, with no way to specify the annotation once along with some way (e.g. xpath) of specifying that the value of one of the parameters should be different for each element.That is, given a schema extract like\[code\]<xsd:element name="smapleRequest"> <xsd:sequence> <xsd:element name="ELEMENT_ONE"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:length value="http://stackoverflow.com/questions/10780481/3" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="ELEMENT_TWO"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="http://stackoverflow.com/questions/10780481/8" /> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:sequence></xsd:element>\[/code\]I would like to see classes that look this:\[code\]...@FixedLengthRecordpublic class SampleRequest { @XmlElement(name = "ELEMENT_ONE", required = true) @DataField(pos = 1, length=3) protected String elementOne; @XmlElement(name = "ELEMENT_TWO", required = true) @DataField(pos = 4, length=8) protected String elementTwo; . . .}\[/code\]Ideally, I would like to be able to do this without having to duplicate all the information from the XSD into the JAXB Binding File. I mean, I could, but with potentially hundreds of elements per web service method, and dozens of methods, that would get very, very old very, very fast. At that point, I would probably have to use another tool to generate the XSD and JAXB binding file(s) from the COBOL!So, does anyone know if this is possible? Have I just missed something in Annox? Or am I just asking for too much here?
 
Back
Top