JAXB generated collection ickyness

Is there a way when generating JAXB beans from an XSD to direct it to use java.util collections of beans directly instead of creating custom container classes? There are various JAXB XSD extensions that can dictate some differences to the generated beans and there are some JAXB plugins too but I can't see anything that does this.
More details:
If I take a nice class looking something like the following:
class Foo {
   List<Bar> getBars() ...
class Bar {
// Usage: List<Bar> bars = foo.getBars();Generate an XSD from it and then generate JAXB beans from that XSD I'll end up with something pretty much like:
class Foo {
   // Ew!
   Bars getBars() ...
class Bars {
   // Yuk!
   List<Bar> getBar() ...
class Bar {
// Usage: List<Bar> bars = foo.getBars().getBar();Pretty nasty. That Bars class obviously gets generated as a place in which to stash the properties that might be in the <bars> element of the XML (which will look something like:
<foo>
  <bars> <!-- This element might have properties -->
    <bar>...<bar>
    <bar>...<bar>
    <bar>...<bar>
  </bars>
</foo>Now in the real world scenario I'm actually starting from an XSD but the problem is the same - I want to generate beans from it, I know that the container element won't have any properties and so I want the container to be a plain old list.
Obivously I could make some of the problems go away by starting from annotated Java source files and generating the XSD but that would create its own can of snakes that I'm not going to pry into.
Any ideas?
Edited by: dcminter on Apr 4, 2012 4:25 PM

nlpappu,
I suggest posting the entire error message and stack trace you are getting, as well as the section of your code that is causing the error.
It may also be helpful if you mentioned the Oracle database version, java version and platform you are using.
I assume you are using SUN's reference implementation (RI) for JAXB, correct?
Good Luck,
Avi.

Similar Messages

  • Reusing JAXB generated classes for XSDs included in other XSDs

    Hi,
    I use xsds with jaxb in a number of related projects. To avoid duplication I've factored out commonly used elements into their own xsd in a separate project. I then include these in the xsds that need them.
    I generate classes with jaxb for each project. I'm now trying to get jaxb so far as to reuse the already generated classes for the common elements.
    For example: I have a general xsd Person.xsd for which I generate classes in common.xsd. I have another xsd Project.xsd that includes a reference to the Person element. When i let jaxb generate classes for Projects.xsd, it will also generate a project.xsd.PersonType and so on.
    Is there any way to tell JAXB to use the existing classes? I've played around with the <jxb:javaType> bindings, but I can't get it to work yet. It gives me a "bindings not used" warning and doesn't compile. Also, if this is in fact the way to go, what do I specify as the parseMethod and printMethod attributes for the javaType element?
    Thx for any help

    JAXB questions should be better directed to the users list of http://jaxb.dev.java.net/
    you should subscribe to the 'users' mailing list, then post a question there.
    Thank you!

  • How to use JAXB generated classes with SOAP

    hello,
    I have a library of JAXB generated classes for my web service. There is a Java class for each web method defined in my schema. For example, my getLocation method is mapped to GetLocation.class.
    However my web service is SOAP based, so I am having to manually strip off the SOAP elements to be able to unmarshall the getLocation xml to a GetLocation class.
    I am noticing a disconnect between JAXB and other Java SOAP and RPC libraries. Does anyone know how to create a JAXB class for SOAP Envelopes and Bodys? Does anyone have any ideas how to incorporate the existing Java web service libraries with JAXB?
    Thanks in advance.

    Have you found a method to integrate SAAJ and JAXB? Or
    is better to use SAAJ only ?If I had to choose I'd go with SAAJ. It seems to me that's theoretically possible to use JAXB classes with SAAJ but I imagine if it is possible it would be a big pain in the ass.

  • JAXB generated files problem

    Hi,
    I am posting a fragment from my XSD. JAXB generates the files and compiles fine, but during runtime, I get a NoClassDefFound error when it tries to look for a particular file. This is the xsd :
    <xs:element name="BillingAddress">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Name">
    <xs:complexType>
    <xs:choice>
    <xs:sequence>
    <xs:element name="First" type="xs:string"></xs:element>
    <xs:element name="Middle" minOccurs="0" type="xs:string"></xs:element>
    <xs:element name="Last" type="xs:string"></xs:element>
    <xs:element name="Title" type="xs:string"></xs:element>
    </xs:sequence>
    <xs:element name="FullName" type="xs:string"></xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    <xs:element name="AddressLines">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="AddressLine" maxOccurs="unbounded">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base="xs:string">
    <xs:attribute name="order" type="xs:string" default="0"></xs:attribute>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="City" type="xs:string"></xs:element>
    <xs:element name="State" type="xs:string"></xs:element>
    <xs:element name="ZipCode">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Zip" type="xs:string"></xs:element>
    <xs:element name="PlusFour" minOccurs="0" type="xs:string"></xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="PhoneNumber">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="AreaCode" type="xs:string"></xs:element>
    <xs:element name="Exchange" type="xs:string"></xs:element>
    <xs:element name="Number" type="xs:string"></xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    I see all the generated interfaces. But in impl folder, I do not see the class for AddressLine. Thus I get this error:
    java.lang.NoClassDefFoundError: com.abc.my.generated.files.impl.BillingAddressTypeImpl$AddressLinesTypeImpl$AddressLineTypeImpl
    I see the interface for BillingAddressType$AddressLinesType$AddressLineType but NO impl.
    Anyone know what the issue is. I am certain it is related to the way xsd is defined for AddressLine but am not sure whats the issue.
    Any help will be appreciated.
    Thanks,
    Ashish

    Dont bother looking into this. I found the issue.
    I saw that jaxb is generating the files and compiling them all well. But then, when i try to jar them or zip them, the files with names > 128 chars do not make it to the jar/zip. Windows does not recognize files name >128 chars. U cannot name a file that long. So, there were 2 files that were > 128 and thus were not making into the jar and thus NoClassDefFound error.
    Very interesting. Took 2 days of my time.

  • Jpub generated collections and SLOW RETRIEVAL

    Oracle 8.1.6 EE
    SQLJ/JDBC 8.1.7
    I use jpub to generate oracle specific usertypes (i.e) -usertypes=oracle. All the classes generate fine and I can use them in my code. The problem is that when I try to use the getArray() or getElement() methods from the generated collection class, it is REALLY SLOW. On the order of two minutes to retrieve 30 records. Using a test harness in SQLPLUS the retrieval is fast. On the order of milliseconds.
    I call a stored procedure that returns the array of objects.
    The object looks like this ...
    CREATE OR REPLACE TYPE account_item AS OBJECT
    id number,
    name varchar2(200),
    tag_id varchar2(50),
    state varchar2(20),
    zip varchar2(20),
    primary_contact varchar2(200),
    phone varchar2(20),
    status varchar2(50),
    broker varchar(200)
    The collection type looks like ...
    CREATE OR REPLACE TYPE account_item_list AS TABLE OF account_item
    Does anyone from the jdbc/sql group have any idea why this would be happening ??
    Thanks.
    Joe
    null

    Ad (1): No idea. Retrieving 9 records each with a nested table of 30 items is practically instantaneous. (Using 9.0.1 client and server and OCI.) Are you using thin or OCI JDBC? Maybe there is an issue connecting between an 8.1.7 client and a 8.1.6 server? (The 8.1.6 JPub runtime had bad performance. 8.1.7 is much improved and should be about equal with 9.0.1.)
    Ad (2): With the SQL definitions of account_item and account_item_list and the following table in the scott/tiger schema:
    create table accounts (id number, account account_item_list)
    nested table account store as accounts_nested_table;
    you can run JPublisher as follows:
    jpub -user=scott/tiger -sql=account_item:AccountItem,account_item_list:AccountItemList
    Then use the following program TestAccount.sqlj (can't resist SQLJ here):
    import java.sql.SQLException;
    import oracle.sqlj.runtime.Oracle;
    import sqlj.runtime.ResultSetIterator;
    public class TestAccount
    { #sql public static iterator Iter (int id, AccountItemList account);
    public static void main(String[] args) throws SQLException
    { Oracle.connect("jdbc:oracle:oci:@","scott","tiger");
    Iter it;
    #sql it = { select id, account from accounts };
    while (it.next())
    printList(it.id(), it.account().getArray());
    it.close(); Oracle.close();
    private static void printList(int id, AccountItem[] items) throws SQLException
    { System.out.print("List "+id+" [");
    for (int i=0; i<items.length; i++)
    { System.out.print(items[i].getId());
    if (i < items.length-1 ) System.out.print(",");
    System.out.println("]");
    Compile everything with:
    sqlj *.java *.sqlj
    And then run:
    java TestAccount

  • Generating Collective PO

    HI,
    I would like to generate Collective PO. I tried creating STO and SO and using based on these I was trying to generate Coll PO. But it give error message "No documents Found".
    I tried and check the setting of Dist. Profile at Article Master and Site Master.
    Can any one suggest where am going wrong or possible setting that I need to check for Coll PO.
    Tx. JM

    Hi Dilip,
    Please find my answers to your Question.
    The replenishment of stock is happening from store to DC.
    Check the following Master data.
    1>Check store/Site category from SITE admin data( Header data) u2026u2026u2026if the value is B then it is DC.
    The SIte Category is A - Store
    The next step
    1.Maintain source of supply as 2 for DC view of article master -
    Here the Supply source of Lod DC View is maintained as 1(Standard) and Log Store is maintained as 2 (Stock Transfer)
    2.Also check the supply sites info form site master. -
    Supplying site is maintained in the store master.
    Still I am not Able to fix the issue.
    This Time what i noticed is when i try to create a collective PO in WF10 with Sesonal Procurement radio button selected iam getting the following application Log.
    The Application Log is as follows,
    Customizing for scheduling could not be determined
    Scheduling failed: vendor 100005, site 2000, article 14, date
    The items were not copied due to the scheduling error
    When i select the Classic Radio button the system displays only one Sales order in the work list. It is Not considering any STO's to the DC from the stores.
    Kindly Help.
    Regards,
    Madhan Raj. C
    Thanks
    Dilip

  • Unable to compile the JAXB generated java files

    Hi
    I am using JAXB 2.0 API for binding process.
    I have products.xml file as
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE PRODUCTDATA SYSTEM "products.dtd">
    <PRODUCTDATA>
    <PRODUCT PRODID="P001" CATEGORY="Books">
    <PRODUCTNAME>Gone with the wind</PRODUCTNAME>
    <DESCRIPTION>This is abt American Civil War</DESCRIPTION>
    <PRICE>25.00</PRICE>
    <QUANTITY>3</QUANTITY>
    </PRODUCT>
    </PRODUCTDATA>
    and products.xsd(Schema file) as
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="PRODUCTDATA" type="prdt"/>
    <xsd:complexType name="prdt">
    <xsd:sequence>
    <xsd:element name="PRODUCT" type="prd" maxOccurs="unbounded" />
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="prd">
    <xsd:sequence>
    <xsd:element name="PRODUCTNAME" type="xsd:string"/>
    <xsd:element name="DESCRIPTION" type="xsd:string"/>
    <xsd:element name="PRICE" type="xsd:positiveInteger"/>
    <xsd:element name="QUANTITY" type="xsd:nonNegativeInteger"/>
    </xsd:sequence>
    <xsd:attribute name="PRODID" type="pid" use="required"/>
    <xsd:attribute name="CATEGORY" type="xsd:string" use="optional"/>
    </xsd:complexType>
    <xsd:simpleType name="pid">
    <xsd:restriction base="xsd:string">
    <xsd:pattern value="[p]{1}/d{3}"/>
    <xsd:length value="4"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:schema>
    I am converting these schema file to java files by using binding compiler xjc.
    So that three java files are genearated automatically.
    1) ObjectFactory.java
    // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
    // See http://java.sun.com/xml/jaxb
    // Any modifications to this file will be lost upon recompilation of the source schema.
    // Generated on: 2008.06.23 at 04:09:25 PM IST
    package testing.jaxb;
    import javax.xml.bind.JAXBElement;
    import javax.xml.bind.annotation.XmlElementDecl;
    import javax.xml.bind.annotation.XmlRegistry;
    import javax.xml.namespace.QName;
    * This object contains factory methods for each
    * Java content interface and Java element interface
    * generated in the testing.jaxb package.
    * <p>An ObjectFactory allows you to programatically
    * construct new instances of the Java representation
    * for XML content. The Java representation of XML
    * content can consist of schema derived interfaces
    * and classes representing the binding of schema
    * type definitions, element declarations and model
    * groups. Factory methods for each of these are
    * provided in this class.
    @XmlRegistry
    public class ObjectFactory {
    private final static QName PRODUCTDATAQNAME = new QName("", "PRODUCTDATA");
    * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: testing.jaxb
    public ObjectFactory() {
    * Create an instance of {@link Prd }
    public Prd createPrd() {
    return new Prd();
    * Create an instance of {@link Prdt }
    public Prdt createPrdt() {
    return new Prdt();
    * Create an instance of {@link JAXBElement }{@code <}{@link Prdt }{@code >}}
    @XmlElementDecl(namespace = "", name = "PRODUCTDATA")
    public JAXBElement<Prdt> createPRODUCTDATA(Prdt value) {
    return new JAXBElement<Prdt>(_PRODUCTDATA_QNAME, Prdt.class, null, value);
    2)Prdt.java
    // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
    // See http://java.sun.com/xml/jaxb
    // Any modifications to this file will be lost upon recompilation of the source schema.
    // Generated on: 2008.06.23 at 04:09:25 PM IST
    package testing.jaxb;
    import java.util.ArrayList;
    import java.util.List;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlType;
    * <p>Java class for prdt complex type.
    * <p>The following schema fragment specifies the expected content contained within this class.
    * <pre>
    * <complexType name="prdt">
    * <complexContent>
    * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    * <sequence>
    * <element name="PRODUCT" type="{}prd" maxOccurs="unbounded"/>
    * </sequence>
    * </restriction>
    * </complexContent>
    * </complexType>
    * </pre>
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "prdt", propOrder = {
    "product"
    public class Prdt {
    @XmlElement(name = "PRODUCT", required = true)
    protected List<Prd> product;
    * Gets the value of the product property.
    * <p>
    * This accessor method returns a reference to the live list,
    * not a snapshot. Therefore any modification you make to the
    * returned list will be present inside the JAXB object.
    * This is why there is not a <CODE>set</CODE> method for the product property.
    * <p>
    * For example, to add a new item, do as follows:
    * <pre>
    * getPRODUCT().add(newItem);
    * </pre>
    * <p>
    * Objects of the following type(s) are allowed in the list
    * {@link Prd }
    public List<Prd> getPRODUCT() {
    if (product == null) {
    product = new ArrayList<Prd>();
    return this.product;
    3) Prd.java
    // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
    // See http://java.sun.com/xml/jaxb
    // Any modifications to this file will be lost upon recompilation of the source schema.
    // Generated on: 2008.06.23 at 04:09:25 PM IST
    package testing.jaxb;
    import java.math.BigInteger;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlType;
    * <p>Java class for prd complex type.
    * <p>The following schema fragment specifies the expected content contained within this class.
    * <pre>
    * <complexType name="prd">
    * <complexContent>
    * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    * <sequence>
    * <element name="PRODUCTNAME" type="{http://www.w3.org/2001/XMLSchema}string"/>
    * <element name="DESCRIPTION" type="{http://www.w3.org/2001/XMLSchema}string"/>
    * <element name="PRICE" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
    * <element name="QUANTITY" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger"/>
    * </sequence>
    * <attribute name="CATEGORY" type="{http://www.w3.org/2001/XMLSchema}string" />
    * <attribute name="PRODID" use="required" type="{}pid" />
    * </restriction>
    * </complexContent>
    * </complexType>
    * </pre>
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "prd", propOrder = {
    "productname",
    "description",
    "price",
    "quantity"
    public class Prd {
    @XmlElement(name = "PRODUCTNAME", required = true)
    protected String productname;
    @XmlElement(name = "DESCRIPTION", required = true)
    protected String description;
    @XmlElement(name = "PRICE", required = true)
    protected BigInteger price;
    @XmlElement(name = "QUANTITY", required = true)
    protected BigInteger quantity;
    @XmlAttribute(name = "CATEGORY")
    protected String category;
    @XmlAttribute(name = "PRODID", required = true)
    protected String prodid;
    * Gets the value of the productname property.
    * @return
    * possible object is
    * {@link String }
    public String getPRODUCTNAME() {
    return productname;
    * Sets the value of the productname property.
    * @param value
    * allowed object is
    * {@link String }
    public void setPRODUCTNAME(String value) {
    this.productname = value;
    * Gets the value of the description property.
    * @return
    * possible object is
    * {@link String }
    public String getDESCRIPTION() {
    return description;
    * Sets the value of the description property.
    * @param value
    * allowed object is
    * {@link String }
    public void setDESCRIPTION(String value) {
    this.description = value;
    * Gets the value of the price property.
    * @return
    * possible object is
    * {@link BigInteger }
    public BigInteger getPRICE() {
    return price;
    * Sets the value of the price property.
    * @param value
    * allowed object is
    * {@link BigInteger }
    public void setPRICE(BigInteger value) {
    this.price = value;
    * Gets the value of the quantity property.
    * @return
    * possible object is
    * {@link BigInteger }
    public BigInteger getQUANTITY() {
    return quantity;
    * Sets the value of the quantity property.
    * @param value
    * allowed object is
    * {@link BigInteger }
    public void setQUANTITY(BigInteger value) {
    this.quantity = value;
    * Gets the value of the category property.
    * @return
    * possible object is
    * {@link String }
    public String getCATEGORY() {
    return category;
    * Sets the value of the category property.
    * @param value
    * allowed object is
    * {@link String }
    public void setCATEGORY(String value) {
    this.category = value;
    * Gets the value of the prodid property.
    * @return
    * possible object is
    * {@link String }
    public String getPRODID() {
    return prodid;
    * Sets the value of the prodid property.
    * @param value
    * allowed object is
    * {@link String }
    public void setPRODID(String value) {
    this.prodid = value;
    Next step is to compile these three files
    So I am compiling these three files it gives me compiler error as:
    testing/jaxb/ObjectFactory.java:31: illegal character: \64
    @XmlRegistry
    ^
    testing/jaxb/ObjectFactory.java:63: illegal character: \64
    @XmlElementDecl(namespace = "", name = "PRODUCTDATA")
    ^
    testing/jaxb/ObjectFactory.java:65: <identifier> expected
    return new JAXBElement<Prdt>(_PRODUCTDATA_QNAME, Prdt.class, null, value
    ^
    testing/jaxb/ObjectFactory.java:65: <identifier> expected
    return new JAXBElement<Prdt>(_PRODUCTDATA_QNAME, Prdt.class, null, value
    ^
    testing/jaxb/ObjectFactory.java:65: '{' expected
    return new JAXBElement<Prdt>(_PRODUCTDATA_QNAME, Prdt.class, null, value
    ^
    testing/jaxb/Prdt.java:38: illegal character: \64
    @XmlAccessorType(XmlAccessType.FIELD)
    ^
    testing/jaxb/Prdt.java:39: illegal character: \64
    @XmlType(name = "prdt", propOrder = {
    ^
    testing/jaxb/Prdt.java:44: illegal character: \64
    @XmlElement(name = "PRODUCT", required = true)
    ^
    testing/jaxb/Prdt.java:45: <identifier> expected
    protected List<Prd> product;
    ^
    testing/jaxb/Prdt.java:69: <identifier> expected
    public List<Prd> getPRODUCT() {
    ^
    testing/jaxb/Prdt.java:75: ';' expected
    ^
    testing/jaxb/Prd.java:43: illegal character: \64
    @XmlAccessorType(XmlAccessType.FIELD)
    ^
    testing/jaxb/Prd.java:44: illegal character: \64
    @XmlType(name = "prd", propOrder = {
    ^
    testing/jaxb/Prd.java:52: illegal character: \64
    @XmlElement(name = "PRODUCTNAME", required = true)
    ^
    testing/jaxb/Prd.java:53: <identifier> expected
    protected String productname;
    ^
    testing/jaxb/Prd.java:54: illegal character: \64
    @XmlElement(name = "DESCRIPTION", required = true)
    ^
    testing/jaxb/Prd.java:55: <identifier> expected
    protected String description;
    ^
    testing/jaxb/Prd.java:56: illegal character: \64
    @XmlElement(name = "PRICE", required = true)
    ^
    testing/jaxb/Prd.java:57: <identifier> expected
    protected BigInteger price;
    ^
    testing/jaxb/Prd.java:58: illegal character: \64
    @XmlElement(name = "QUANTITY", required = true)
    ^
    testing/jaxb/Prd.java:59: <identifier> expected
    protected BigInteger quantity;
    ^
    testing/jaxb/Prd.java:60: illegal character: \64
    @XmlAttribute(name = "CATEGORY")
    ^
    testing/jaxb/Prd.java:61: <identifier> expected
    protected String category;
    ^
    testing/jaxb/Prd.java:62: illegal character: \64
    @XmlAttribute(name = "PRODID", required = true)
    ^
    testing/jaxb/Prd.java:63: <identifier> expected
    protected String prodid;
    ^
    25 errors
    I want all three files to compiled successfully.If it is compiled only then I will continue on Unmarshalling process

    I suspect you are trying to compile the files one by one. You may also be trying to compile them disregarding the package structure.
    From your post, I gather these files are in the package: com.geindustrial.sqms
    Therefore, if they are not so already, put them under a directory structure:
    com/geindustrial/sqms
    and then compile with:
    javac com/geindustrial/sqms/AddCtq.java com/geindustrial/sqms/Ctq.java com/geindustrial/sqms/VariableData.java
    (The above is all on one line.)
    HTH,
    Manuel Amago.

  • How to generate .xsd file using jaxb generated java files

    Hi,
    We need to upgrade our applicatio to jdk1.6 which has jaxb2.0 class files in it. Our application has java files generated from .xsd using jaxb1.0.2 version. At present we dont have .xsd or .xml file with us.
    We decide to generate .xsd file by using jaxb1.0.2 generated java files. I tried using schemagen.exe given by jdk1.6 to generate .xsd file. It error out. Is there any other way to generate .xsd file ?
    pls let me know.
    thanks,
    Thiru

    Object-XML mapping is a new feature in JAXB 2.0. Classes generated with JAXB 1.0 won't generate a schema.
    Generate Java classes with JAXB 2.0 xjc.
    http://www.theregister.co.uk/2006/09/22/jaxb2_guide/

  • Setting the DTD in the JAXB generated Java Classes

    Hi All,
    I have generated the Java Source file for a DTD using the xjc tool that comes with JAXB .
    Now from the Class files i can unmarshall and get the XML file . But in the generated XML output file we don't have the <!DOCTYPE > Element which binds the XML to the DTD .
    Is it possible to specify the DTD ? If so Where can we specify that .
    Thanks for your help...
    Sateesh

    Parse the Dtd for a DOCUMENT_TYPE_NODE & create a <!DOCTYPE >element in the output xml.
    PrintWriter pw=new PrintWriter();
    if(node.getNodeType()==Node.DOCUMENT_TYPE_NODE){
    DocumentType doctype = (DocumentType)node;
    pw.print("<!DOCTYPE ");
    pw.print(doctype.getName());
    String publicId = doctype.getPublicId();
    String systemId = doctype.getSystemId();
    if (publicId != null) {
    pw.print(" PUBLIC '");
    pw.print(publicId);
    pw.print("' '");
    pw.print(systemId);
    pw.print('\'');
    else {
    pw.print(" SYSTEM '");
    pw.print(systemId);
    pw.print('\'');
    String internalSubset = doctype.getInternalSubset();
    if (internalSubset != null) {
    pw.println(" [");
    pw.print(internalSubset);
    pw.print(']');
    pw.println('>');}

  • ToString() and Comparable T on a JAXB generated entity class

    Hello,
    I'm trying to create a distributed system and therefore I have all my entity classes present in my Java EE app and hosted as a web service. The Swing frontend app autogenerate the entity classes for use in the presentation.
    I'm having some trouble using the Collections.sort() since a generated entity cannot implement an interface, does anyone have a hint to how i can solve this issue?
    Also, I need to override the toString() so that I can put an entity directly in a eg. JCombobox and it is presented with the return of my custom toString() but if I override the toString() in my original entity in my backend app, then this method is not generated in my frontend app.
    Thanks in advance!
    Nicklas

    Hello,
    I'm trying to create a distributed system and therefore I have all my entity classes present in my Java EE app and hosted as a web service. The Swing frontend app autogenerate the entity classes for use in the presentation.
    I'm having some trouble using the Collections.sort() since a generated entity cannot implement an interface, does anyone have a hint to how i can solve this issue?
    Also, I need to override the toString() so that I can put an entity directly in a eg. JCombobox and it is presented with the return of my custom toString() but if I override the toString() in my original entity in my backend app, then this method is not generated in my frontend app.
    Thanks in advance!
    Nicklas

  • How to access the JAXB generated methods of Complex element

    Hi all,
    I am generating the java classes from the a XSD file which contains the Complex element , which again contains the simple elements. JAXB is generating the interface and public static class for the inner Complex element. But i not able to create the object of this inner class using the Object factory class. Then without object how can i access the setter and getter methods contained in this complex element.
    My XSD file looks like -
    <xs:element name="SSDecisionActivity">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="Id" type="xs:ID"/>
    xs:element name="ConditionFlow">
         <xs:complexType>
         <xs:sequence>
         <xs:element name="Condition" type="xs:string"/>
         <xs:element name="DecisionCriteria" type="xs:string" minOccurs="2" maxOccurs="unbounded"/>
    How shall i access the methods from the ConditionFlow (Complex element) like setCondition(....),getCondition().
    If anybody knows plz tell me the way.
    Ravi

    I'm a bit confused about this design approach.
    [Bindable] public var storyList:IdmlStory = null; 
    The reason why the above line fails to compile in StoryList.mxml is that a variable of the same name already exists. You have specified a List with an id of storyList. The translation process will yield:
    var storyList:List = new List();
    and then fill in the properties.

  • Help: Creating web service proxy using JAXB generated domains

    Hi,
    I'm currently doing some investigation considering the use of web services (BPEL) as a complete application backend.
    The application should contain a pojo facade which communicates with some web service proxies. By making a datacontrol
    of the pojo facade, I'm able to expose methods to the client layer.
    I generated my domain objects by using the JAXB Compilation option in JDeveloper. By using that, a java class can be generated
    based on an XSD. Disadvantage of this use, seems to be the fact that the ObjectFactory class, generated by JAXB, is overwritten
    each time I create java classes from an XSD.
    Q1: Is there a solution to prevent the ObjectFactory class to be overwritten? I also could decide not to use it.
    After the domain objects are created, I want to call the actual webservice and receive the response by using the JAXB marshaller
    and unmarshaller. Problem here is:
    Q2: How do I (manually?) create a proxy which calls the web service, by using the domain objects generated by JAXB?
    Q3: An important requirement is that it needs to be simple to switch from several environments (eg from development to test). How
    can I fulfill this requirement in a nice, solid solution?
    Any tips working with web services as the backend layer are welcome!
    JDeveloper 10.1.3.4
    ADF Faces/JSF
    BPEL
    Thanks,
    Koen Verhulst

    repost.

  • JAXB generating incorrect code with mixed type element extending abstract

    Hello,
    I am using JAXB v 2.0, and trying to generate proper Java classes, from the following snippet of my schema:
    <xsd:complexType name="abstract-query" abstract="true" mixed="true">
    <xsd:annotation>
    <xsd:appinfo>
    <jxb:class name="QueryElement">
    </jxb:class>
    </xsd:appinfo>
    </xsd:annotation>
    <xsd:attribute name="name" use="required"/>
    <xsd:attribute name="datasource" type="report:datasource" use="required"/>
    </xsd:complexType>
    <xsd:element name="query">
    <xsd:annotation>
    <xsd:appinfo>
    <jxb:class name="PreparedQueryElement">
    </jxb:class>
    </xsd:appinfo>
    </xsd:annotation>
    <xsd:complexType mixed="true" >
    <xsd:complexContent>
    <xsd:extension base="report:abstract-query">
    <xsd:sequence>
    <xsd:element name="input-ref" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>
    When generating Java, the PreparedQueryElement class does not include a list of input-ref's.
    If I remov the two "abstract="true"" annotations, the PreparedQueryElement will get the input-ref's list, but the QueryElement will not have the getContent/setContent I need.
    Does anyone know what I'm doing wrong?

    Sorry, third time's a charm!
    Hello,
    I am using JAXB v 2.0, and trying to generate proper Java classes, from the following snippet of my schema:
        <xsd:complexType name="abstract-query" abstract="true" mixed="true">
            <xsd:annotation>
                <xsd:appinfo>
                    <jxb:class name="QueryElement">
                    </jxb:class>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:attribute name="name" use="required"/>
            <xsd:attribute name="datasource" type="report:datasource" use="required"/>
        </xsd:complexType>
        <xsd:element name="query">
            <xsd:annotation>
                <xsd:appinfo>
                    <jxb:class name="PreparedQueryElement">
                    </jxb:class>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:complexType mixed="true" >
                <xsd:complexContent>
                    <xsd:extension base="report:abstract-query">
                        <xsd:sequence>
                            <xsd:element name="input-ref" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
                        </xsd:sequence>
                    </xsd:extension>
                </xsd:complexContent>
            </xsd:complexType>
        </xsd:element>When generating Java, the PreparedQueryElement class does not include a list of input-ref's.
    If I remove the two mixed="true" annotations, the PreparedQueryElement will get the input-ref's list, but the QueryElement will not have the getContent/setContent I need.
    Does anyone know what I'm doing wrong?

  • Jaxb:-generate xml

    Hi,
    I am new to Jaxb, currently working on it.
    I need to Create a java code using JAXb which should load an existing schema and generate xml out of that schema having some values harcoded in the xml.
    I have created a java code which will create an xml having some values hardcoded in it.
    can any one suggest me the simple way to load an existing schema and create an xml out of that..
    If do you have any links, Please do share it..
    Thanks-

    Try "SJIS"

  • System generated Collective number in Quotation.

    Hi All,
    Is there any possibility or a way to have the collective number in quotation generated automatically.
    Edited by: vamsi k on Sep 30, 2010 10:40 PM
    Edited by: vamsi k on Sep 30, 2010 10:41 PM

    Hi
    IF it is BDC and if you are using Call Transaction then use like below.
        CALL TRANSACTION 'XXXX' USING GT_BDCDATA
                         MODE   GD_DISMODE
                         UPDATE GD_UPDMODE
                         MESSAGES INTO GT_MESSTAB.
        IF SY-SUBRC <> 0.
          LOOP AT GT_MESSTAB .
            SELECT SINGLE TEXT FROM T100 INTO GD_TEXT WHERE SPRSL = 'E' AND ARBGB = GT_MESSTAB-MSGID AND MSGNR = GT_MESSTAB-MSGNR.
            REPLACE FIRST OCCURRENCE OF '&' IN GD_TEXT WITH GT_MESSTAB-MSGV1.
            REPLACE FIRST OCCURRENCE OF '&' IN GD_TEXT WITH GT_MESSTAB-MSGV2.
            REPLACE FIRST OCCURRENCE OF '&' IN GD_TEXT WITH GT_MESSTAB-MSGV3.
          ENDLOOP.
    Regards,
    Vijay V

Maybe you are looking for

  • My iTunes won't open, getting error message.

    "The iTunes application could not be opened. An unknown error occured (13010)." Help?

  • 9i:Can Page number be obtained before the entire generation of report ?

    Dear all: Suppose there is a report, the report is printed on both side of paper The page no of report (current logical page no and total logical page no) reset at each customer, For each customer, i want to print a logo on the front side of the last

  • Portal user password reset!

    I for some reason I reset the Portal (DB Schema) user password and i'm not able to get into the portal page! please help.. here is the err i get --- http://<host>:7778/pls/portal/ Forbidden You don't have permission to access /pls/portal/portal.home

  • Can I change the role a new user gets in the B2C senario

    Hi. I am in the Business Blue Print phase of a Web Shop project based on the CRM 4.0 E-commerce. As I understand it, a user registering at the shop is created as a business partner with the role "Consumer". We are already using the consumer role for

  • Webcam chats with windows users

    I have been trying to chat with a friend of mine using webcams and first we thought the problem was that her computer was treating the ichat invitation as an intruder. Now she has set her virus protection to accept me but every time we connect, ichat