JAXB & DTD

Hi there
In order to develop an XML-based applikationmodule I wanted to use JAXB.
Actually we only hav a DTD that describes our XML-documents.
Now my question is: Is there a way to use JAXB with DTD instaead of schema, or does someone know a tool for converting DTD to an equivalent schema?
Thanks very much
danwan

OK I found out!
see: http://www.xml.com/pub/a/2002/08/28/validation.html

Similar Messages

  • JAXB DTD and XJS element specification

    I have a DTD with the following element declaration:
    <!ELEMENT PersonIdentifiers ((GvtNbr, (IdSateNbr, IdStateCd)?) | (IdStateNbr, IdStateCd))>
    GvtNbr, IdStateNbr, and IdStateCd are all #PCDATA
    How can I structure my XJS in order that I don't just have to call getContent() and then search for what I want?

    Have you tried an interface, which would consist of an IDStateNbr and an IDStateCd?
    the only problem with your setup and jaxb right now is that jaxb will choke on validation, if your optional element isn't present. hopefully, this bug will be fixed when the 1.0 version comes out, later this year...

  • DTD to java

    i need to write a model class for a dtd file, that is, read a dtd and model it into fields in,say, a java object. Is there an easy way to do it?

    Hi,
    you might want to check JAXB ( [https://jaxb.dev.java.net/|https://jaxb.dev.java.net/] ), which supports XML schema, but also DTD. It is used to create Java classes from an XML schema or DTD, which also contain code to marshal or unmarshal an XML document to Java classes or vice versa.
    JAXB (package javax.xml.bind) ist part of Java SE 6.0. In prior versions, it was shipped separately or as part of the web service tools.
    Martin
    PS: after reading your post a second time I see, that you do not want to create classes out of a DTD, but objects which contain a description of the classes! That's not the intention of JAXB.
    However the developers of JAXB had to do the same when they wrote the JAXB DTD compiler. So perhaps you get some ideas if you look for the source code of the reference implementation of the JAXB compiler.
    Edited by: martin@work on Jun 16, 2008 9:27 AM

  • How to ignore DTD in xml files under JAXB?

    hi,
    I have a program that has to access files which declare they use a DTD that no longer exists on the web in that location.
    we don't have the option to alter the xml files since they don't belong to us!
    I've written an equivalent schema and its all working with the files that have correct DTD references.
    Is there a way to tell the unmarshaller not to attempt to use the DTD that the documents declare?
    thanks,
    asjf

    I've found that by opening a inputstream to the XML file and wrapping it to filter the DTD out altogether and passing that inputstream to JAXB does the trick.
    this seems actually faster, since it doesn't go off on the net to look for the dtd!
    is this not catered for already somewhere??
    thanks,

  • 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('>');}

  • JAXB problem with DTD file

    Hi All,
    I just started to learn JAXB and I come to a point in which I need to run xjc on a dtd file and jxs file. The problem is that is gives me an ERROR :
    "parsing a schema...
    [ERROR] The markup in the document preceding the root element must be well-forme
    d.
    line 1 of checkbook.dtd
    This is my dtd file:
    <!ELEMENT checkbook ( transactions, balance ) >
    <!ELEMENT transactions ( deposit | check | withdrawal )* >
    <!ELEMENT deposit ( date, name, amount )>
    <!ATTLIST deposit category ( salary | interest-income | other ) #IMPLIED >
    <!ELEMENT check ( date, name, amount, ( pending | void | cleared ), memo? )>
    <!ATTLIST check number CDATA #REQUIRED category ( rent | groceries | other ) #IMPLIED >
    <!ELEMENT withdrawal ( date, amount ) >
    <!ELEMENT balance (#PCDATA) >
    <!ELEMENT date (#PCDATA ) >
    <!ELEMENT name (#PCDATA) >
    <!ELEMENT amount (#PCDATA) >
    <!ELEMENT memo (#PCDATA) >
    <!ELEMENT pending EMPTY >
    <!ELEMENT void EMPTY >
    <!ELEMENT cleared EMPTY >
    What is the problem with it?
    Need your help and THANKS in advance
    A.B

    Try adding dom4j.jar (http://www.dom4j.org/) to your classpath and compiling with the -dtd switch. E.g.:
    xjc -dtd foo.dtd
    -- Ed

  • JAXB is incorrectly handling the ? DTD sign.

    When writing a DTD that has an element that can occur either one or zero times, I have used the ? sign. However, when such a JAXB object is validated, a NullPointerException is thrown if the element is not present. Either this is a bug or I am missing something obvious. Below you will find a snippet of my DTD. I am referring to the "dependency" element. Just wanted to clear it here first before I submit a bug report. Thanks in advance for all help.
    <snip>
    <!ELEMENT question (text+,option*,dependency?) >
    </snip>

    Oops, this is already reported as bug id 4497267. Didn't find it the first time I searched.

  • Dtd support for jaxb

    i know the beta won't work with dtds. Is this feature gone for good from jaxb or just the beta? I read the FAQ http://java.sun.com/xml/jaxb/faq.html. and it seems like it says dtd is gone, but doesn't come out and clearly say so.

    i know the beta won't work with dtds. Is this feature
    gone for good from jaxb or just the beta? I read the
    FAQ http://java.sun.com/xml/jaxb/faq.html. and it
    seems like it says dtd is gone, but doesn't come out
    and clearly say so.Hi,
    The dtd feature support is no longer there in JAXB. The beta release does not support dtds and also the FCS will not be supporting it.
    Thanks,
    Bhakti Mehta
    Sun Microsystems Inc.

  • Creating an XML document from a DTD in Java

    Hi All,
    I need help on the following requirement very badly. Pls help me.
    I have a requirement to implement with java and XML. I am quit new to XML.Can any of you pls help me.
    I have a DTD file. I need to generate XML document from it using java code. I have to use DTD as a template to generate my XML document.
    After going through WEB sites, I understtod that, we have to user Java API JAXB for my requirement. But I could not find JAXB.jar anywhere.
    I need to know the following inforamtion ....
    1. Is my understanding of using JAXB for my requirement is correct?
    2. Where can I get JAXB.jar?
    3. What are the steps to create XML document from a DTD in Java?
    If can give me a sample code for this would help me a lot.
    Pls pls reply me. Your help is greatly appreciated.
    Thanks in Advance.
    Regards,
    Gayathri.

    hi Gayathri,
    iam currently working in the same field.
    firs download jaxb from this link:
    http://java.sun.com/xml/downloads/jaxb.html
    first u need to marshall it.
    cheers
    shashi

  • Can't import schemas in classpath when generating JAXB

    I'm trying to create schemas that are used to provide basic components for more complex schemas, using the same design idea behind creating abstract Java classes and then extending them. I'm having trouble referring to classes in different modules, though. Below is the start of a schema that refers to a schema that is stored in another jar file:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://xml.kitfox.com/schema/tw/ts"
        elementFormDefault="qualified"
        xmlns:tns="http://xml.kitfox.com/schema/tw/ts"
        xmlns:cmn="http://xml.kitfox.com/schema/common">
        <xsd:import schemaLocation="/com/kitfox/common.xsd" namespace="http://xml.kitfox.com/schema/common"/>
        <xsd:complexType name="sourceType">
            <xsd:attribute name="uid" type="cmn:uidType"/>
        </xsd:complexType>I'm generating my JAXB with the following task:
        <target name="bind-preferences" depends="init">
            <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
                <classpath>
                    <pathelement path="${javac.classpath}"/>
                </classpath>
            </taskdef>
            <xjc destdir="gen" extension="true" removeOldOutput="true">
                <schema dir="src">
                    <include name="**/*.xsd"/>
                </schema>
                <produces dir="gen">
                    <include name="**/*.java"/>
                </produces>
            </xjc>
        </target>Unfortunately, this causes the following error:
    [WARNING] schema_reference.4: Failed to read schema document '/com/kitfox/common.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
      line 9 of file:/C:/dev/kitfox.com/gameEngine/proj/tileWorld/src/com/kitfox/tw/ts.xsd
    [ERROR] src-resolve: Cannot resolve the name 'cmn:uidType' to a(n) 'type definition' component.
      line 24 of file:/C:/dev/kitfox.com/gameEngine/proj/tileWorld/src/com/kitfox/tw/ts.xsd
    [ERROR] src-resolve: Cannot resolve the name 'cmn:uidType' to a(n) 'simpleType definition' component.
      line 24 of file:/C:/dev/kitfox.com/gameEngine/proj/tileWorld/src/com/kitfox/tw/ts.xsdI know that the classpath passed into the xjc task contains the jar with my original schema. What can I do so that JAXB finds it? Also, how would I tell JAXB to extend the classes already generated for common.xsd in my original jar rather than regenerating them in the jar I'm compiling?

    Thanks. I've looked into using a catalog (the ant task allows you to specify a catalog), but don't think I've got the syntax right. Does the following look right to you?
    <!DOCTYPE catalog
      PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
             "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
    <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
             prefer="public">
      <uri name="common.xsd"
       uri="../gb/src/com/kitfox/common.xsd"/>
    </catalog>I've changed my schema to look like:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://xml.kitfox.com/schema/tw/ts"
        elementFormDefault="qualified"
        xmlns:tns="http://xml.kitfox.com/schema/tw/ts"
        xmlns:cmn="http://xml.kitfox.com/schema/common">
        <xsd:import schemaLocation="common.xsd" namespace="http://xml.kitfox.com/schema/common"/>
        <xsd:complexType name="sourceType">
            <xsd:attribute name="uid" type="cmn:uidType"/>
        </xsd:complexType>I'm still getting errors:
    [WARNING] schema_reference.4: Failed to read schema document 'common.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
      line 9 of file:/C:/dev/kitfox.com/proj/tw/src/com/kitfox/tw/ts.xsd
    [ERROR] src-resolve: Cannot resolve the name 'cmn:uidType' to a(n) 'type definition' component.
      line 24 of file:/C:/dev/kitfox.com/proj/tw/src/com/kitfox/tw/ts.xsd
    [ERROR] src-resolve: Cannot resolve the name 'cmn:uidType' to a(n) 'simpleType definition' component.
      line 24 of file:/C:/dev/kitfox.com/proj/tw/src/com/kitfox/tw/ts.xsdI've tried some variations such as leaving out the import/@schemaLocation attribute and hoping that the catalog could resolve that with the namespace alone or creating a fake http:// url for the schemaLocation, but none of that works. Would you know what I'm doing wrong with this catalog? The catalog and ant file are in the same directory and the relative path to the common.xsd file is correct.

  • Don't know how to resolve JAXB UnsynchronizedContentModel

    I've got a dtd that looks something like:
    <!ELEMENT Foo (Bar)*>
    <!ELEMENT Bar (A, B, C)>
    <!ELEMENT A (#PCDATA)>
    <!ELEMENT B (#PCDATA)>
    <!ELEMENT C (#PCDATA)>and a binding schema that looks something like:
    <xml-java-binding-schema>
    <element name="Foo" type="class" root="true">
        <content>
            <choice property="BarList" collection="list"/>
        </content>
    </element>
    <element name="Bar" type="class">
        <content>
            <element-ref name="A"/>
            <element-ref name="B"/>
            <element-ref name="C"/>
        </content>
    </element>
    <element name="A" type="value"/>
    <element name="B" type="value"/>
    <element name="C" type="value"/>
    </xml-java-binding-schema>When I try to compile it, I gen an UnsynchronizedContentModel. Other postings in this forum suggest that my choice property doesn't correspond to the data in my dtd.
    So, thinking that I need to explicitly map my list to my Bar element, I try:
    <choice property="Bar" collection="list"/>
    but that doesn't work, either.
    All I'm trying to do is cause a List of Bar objects to be created when I unmarshal an xml file. What am I doing wrong?
    In the example in the JAXB User's Guide, they complicate the issue of choice / collections by adding in the notion of an interface. I don't really have any sibling classes that share fields, so I don't see why I'd want to add this construct. However, is it necessary to do so, in order to make this work?
    Thanks!
    Larry

    Man, do I feel stupid... finally, after banging my head up against the documentation, I found the answer.
    In short, I had been telling the binding schema compiler that I wanted a list that should be named "BarList", but I wasn't telling it that it should be a list of "Bar" objects.
    So, the xjs for Foo needed to look like this:
    <element name="Foo" type="class" root="true">
        <content>
            <element-ref name="Bar" collection="list" property="BarList"/>
        </content>
    </element>like i said, it wasn't that hard, but it sure took a lot of looking at it to realize what I'd done wrong...
    Larry

  • 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 paste DTD in XML file. (not reference to .dtd file)

    Hello!
    I create XML file using DOM. How can I create DTD on the top of the file?
    I need the DTD, not a reference to it. So the next method won't work.
    transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "Resources\\Settings\\projectFile.dtd") since it is paste a reference to .dtd file. It means that if user moves XML file to other place he need to move .dtd file also, and I don't want this method. I want paste next DTD
    <!DOCTYPE project [
                        <!ELEMENT project (component*) >
                        <!ELEMENT component ANY >
                        <!ATTLIST component id  ID  #REQUIRED >
    ]>from the .dtd file on the top of my XML file. How can I do this?
    Thank you.

    I've found that by opening a inputstream to the XML file and wrapping it to filter the DTD out altogether and passing that inputstream to JAXB does the trick.
    this seems actually faster, since it doesn't go off on the net to look for the dtd!
    is this not catered for already somewhere??
    thanks,

  • JAXB 1.3 can't parse W3 SOAP 2003-05 envelope XML schema

    Hello,
    I was trying to use JAXB to parse the MMAP schema from the SMS Forum
    (http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd). I finally
    tracked it down to XJC choking on the included SOAP envelope schema's
    use of the xml:lang attribute for a tag called reasontext. Here's the
    pared-down test case:
    C:\java\src\baz>%JWSDP_HOME%\jaxb\bin\xjc.bat http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
    %JWSDP_HOME%\jaxb\bin\xjc.bat http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
    parsing a schema...
    [ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a(n) attribute declaration component.
      line 97 of soap-envelope.xsd
    [ERROR] src-ct.0.1: Complex Type Definition Representation Error for type 'reasontext'.  Element 'attribute' is invalid, misplaced, or occurs too often.
      line 97 of soap-envelope.xsd
    Failed to parse a schema.
    C:\java\src\baz>I believe that the relevant portions of the schemas and namespaces in
    question are:
    http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
    <xs:complexType name="reasontext">
    <xs:simpleContent>
    <xs:extension base="xs:string">
    <xs:attribute ref="xml:lang" use="required" />
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>http://www.w3.org/2001/XMLSchema.xsd
    <xs:complexType name="attribute" mixed="false">
    <xs:complexContent>
    <xs:extension base="xs:annotated">
    <xs:sequence>
    <xs:element name="simpleType" minOccurs="0" type="xs:localSimpleType" />
    </xs:sequence>
    <xs:attributeGroup ref="xs:defRef" />
    <xs:attribute name="type" type="xs:QName" />
    <xs:attribute name="use" use="optional" default="optional">
    <xs:simpleType>
    <xs:restriction base="xs:NMTOKEN">
    <xs:enumeration value="prohibited" />
    <xs:enumeration value="optional" />
    <xs:enumeration value="required" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="default" type="xs:string" />
    <xs:attribute name="fixed" type="xs:string" />
    <xs:attribute name="form" type="xs:formChoice" />
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>http://www.w3.org/2001/XMLSchema.xsd
    <xs:attributeGroup name="defRef">
    <xs:annotation>
    <xs:documentation>for element, group and attributeGroup, which both define and reference</xs:documentation>
    </xs:annotation>
    <xs:attribute name="name" type="xs:NCName" />
    <xs:attribute name="ref" type="xs:QName" />
    </xs:attributeGroup>http://www.w3.org/XML/1998/namespace
    The namespace whose name is http://www.w3.org/XML/1998/namespace is
    bound by definition to the prefix xml: according to Namespaces in XML,
    W3C Recommendation 14 Jan 1999. Note that unlike all other XML
    namespaces, both the name and the prefix are specified; i.e., if you
    want XML 1.0 processors to recognize this namespace, you must use the
    reserved prefix xml:.
    xml:lang and xml:space
    As of the last update of this document, the XML 1.0 Specification
    defines two attribute names in this namespace:
    xml:lang
    Designed for identifying the human language used in the scope of the
    element to which it's attached.
    .I'm no XML schema expert, but it looks to me like "name" and "ref"
    are both valid attributes for an <xs:attribute> tag and that the XML
    namespace standard requires XML processors to recognize the xml:lang
    attribute. Hence, this appears to me to be a bug in JAXB.
    A secondary bug is that the original error message left the name of
    the offending included schema blank:
    C:\java\src\foo>d:\java\jwsdp\jwsdp-1.3\jaxb\bin\xjc.bat http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd
    parsing a schema...
    [ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a(n) attribute declaration component.
      line 97 of
    [ERROR] src-ct.0.1: Complex Type Definition Representation Error for type 'reasontext'.  Element 'attribute' is invalid, misplaced, or occurs too often.
      line 97 of
    Failed to parse a schema.
    C:\java\src\foo>In case it helps with problem diagnosis, I'm running with J2SDK 1.4.2
    and have copied the endorsed jar files into the JRE lib as instructured
    with JAXB:
    C:\java\src\baz>java -version
    java -version
    java version "1.4.2"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
    Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
    C:\java\src\baz>dir %JAVA_HOME%\jre\lib\endorsed
    dir %JAVA_HOME%\jre\lib\endorsed
    Volume in drive D has no label.
    Volume Serial Number is 70AE-6E52
    Directory of D:\java\j2se\j2sdk1.4.2\jre\lib\endorsed
    03/31/2004  09:41 AM    <DIR>          .
    03/31/2004  09:41 AM    <DIR>          ..
    03/29/2004  01:28 PM            56,619 dom.jar
    03/29/2004  01:28 PM            60,963 sax.jar
    03/29/2004  01:28 PM         2,823,241 xalan.jar
    03/29/2004  01:28 PM         2,667,618 xercesImpl.jar
    10/10/2003  06:36 PM         1,379,810 xsltc.jar
                   6 File(s)      6,989,573 bytes
                   2 Dir(s)   7,889,731,584 bytes free
    C:\java\src\baz>I'm quite interested in the resolution of this issue as I'm stopped in
    my tracks on progress here. Help with resolution, whether in JAXB or
    my usage of it, will be much appreciated. I did a search of existing
    issues but didn't notice a duplicate. Thanks in advance.

    I have also come across a similar problem with validating an xml file with an xml:lang attribute. It seems to be common across the schema validation and dtd validation. I get the following error with both schema and dtd validation:
    Validation Error Msg (0): unexpected attribute "xml:lang"
    Validation Error Location (0): FreeFormText
    The test file extract looks like this:
    <FreeFormText xml:lang="EN">Pelle</FreeFormText>
    The schema defines the node as:
    <xs:complexType name="FreeFormText">
              <xs:simpleContent>
                   <xs:extension base="FreeFormTextType">
                        <xs:attribute name="lang" type="xs:language"/>
                   </xs:extension>
              </xs:simpleContent>
    </xs:complexType>
    and the dtd defines the node as:
    <!ELEMENT FreeFormText
         (#PCDATA)>
    <!ATTLIST FreeFormText xml:lang CDATA #IMPLIED >
    This looks like a bug in JAXB to me aswell. Any help on it would be much appreciated as i am also stuck.

  • Subject: Choice element in JAXB 1.x

    Recently i ran into problem of having too many elements in choice tag. JAXB doesn't throw exception, but generated files doesn't comply Java.
    While compilation it throws "code too large" exception. On removing few i can manage, but i am looking for long term solution.
    Any suggestion appreciated.
    -Balaji S

    As per my understanding the * at the end SEDOL | SILCHESTER)*> making it to create choice or replace. If you remove star from you DTD it will generate OTD without choice.
    Thanks
    Sanjeev

Maybe you are looking for

  • Verizon doesn't care if you pay for Priority Overnight.

    I preordered the Note 3, and picked priority overnight shipping, it cost me $14.99. First of all, when I preordered my S4 I got overnight as well, I ended up receiving the phone earlier than most customers, and I got it before I go into work. That be

  • HT1414 I'm trying to update my iPad 2 to iOS 6 help

    Trying to download iOS 6 for my iPad 2 not having any luck.

  • Error code 5103 when renting a movie

    I get the following error message when I rented a movie from iTunes store, "An unknown error occurred (5103)". I downloaded the movie and when I tried to watch it, I got that message. I have tried disabling my firewall, reset iTunes cache, and restar

  • IW32 - Total planned cost value

    Hi All,    Can you one of you tell how to get the Total planned cost(i.e. KKBCS_OUT- PLANKOST_G this value is calculated and displayed dynamically in another ALV list of same IW32 transaction when we go to Cost Tab and click on button Rep plan/Act.) 

  • Parking and Posting of Documents

    Hi Frnds, Can i park the documents relating to Incoming and Outgoing Payments??? thanks in advance........ Regards, Jigar