From do-not-reply at jboss.com Wed Feb 20 04:39:28 2008 Content-Type: multipart/mixed; boundary="===============6109381875380148635==" MIME-Version: 1.0 From: mariuszs To: jbossws-users at lists.jboss.org Subject: [jbossws-users] [JBossWS] - [JAXB] Problem with generating XML from Schema Date: Wed, 20 Feb 2008 04:39:28 -0500 Message-ID: <18478078.1203500368252.JavaMail.jboss@colo-br-02.atl.jboss.com> --===============6109381875380148635== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable I have sample schema: | | | | | | | | | | | = Generated objects: // | // This file was generated by the JavaTM Architecture for XML Binding(J= AXB) Reference Implementation, v2.1.5-b01-fcs = | // See http://java.sun.com/xml= /jaxb = | // Any modifications to this file will be lost upon recompilation of th= e source schema. = | // Generated on: 2008.02.20 at 10:25:59 AM CET = | // | = | = | package pl.pentacomp.pentascape.da; | = | import javax.xml.bind.annotation.XmlAccessType; | import javax.xml.bind.annotation.XmlAccessorType; | import javax.xml.bind.annotation.XmlElement; | import javax.xml.bind.annotation.XmlRootElement; | import javax.xml.bind.annotation.XmlType; | = | = | /** | *

Java class for anonymous complex type. | * = | *

The following schema fragment specifies the expected content cont= ained within this class. | * = | *

  |  * <complexType>
  |  *   <complexContent>
  |  *     <restriction base=3D"{http://www.w3.org/2001/XMLSchema}anyTyp=
e">
  |  *       <sequence>
  |  *         <element name=3D"Element" type=3D"{http://www.w3.org/2001=
/XMLSchema}anyType"/>
  |  *       </sequence>
  |  *     </restriction>
  |  *   </complexContent>
  |  * </complexType>
  |  * 
| * = | * = | */ | @XmlAccessorType(XmlAccessType.FIELD) | @XmlType(name =3D "", propOrder =3D { | "element" | }) | @XmlRootElement(name =3D "DocSample", namespace =3D "http://www.test.co= m/app") | public class DocSample { | = | @XmlElement(name =3D "Element", namespace =3D "http://www.test.com/= app", required =3D true) | protected Object element; | = | /** | * Gets the value of the element property. | * = | * @return | * possible object is | * {@link Object } | * = | */ | public Object getElement() { | return element; | } | = | /** | * Sets the value of the element property. | * = | * @param value | * allowed object is | * {@link Object } | * = | */ | public void setElement(Object value) { | this.element =3D value; | } | = | } | = Java code: @Test | public void testSample() { | DocSample doc =3D new DocSample(); | doc.setElement(new String("sdsd")); | = | StreamResult result =3D new StreamResult(new StringWriter()); | = | JAXBContext jaxbContext; | try { | jaxbContext =3D JAXBContext.newInstance(DocSample.class); | Marshaller marshaller =3D jaxbContext.createMarshaller(); | marshaller.marshal(doc, result); | = | } catch (JAXBException e) { | = | e.printStackTrace(); | } | = | String response =3D result.getWriter().toString(); | = | System.out.println(response); | = | } And result XML: | | | sdsd | | Is this XML correct? Why xmlns:xs, xmlns:xsi are assigned to Element, not D= ocSample. Please help. View the original post : http://www.jboss.com/index.html?module=3Dbb&op=3Dv= iewtopic&p=3D4130664#4130664 Reply to the post : http://www.jboss.com/index.html?module=3Dbb&op=3Dpostin= g&mode=3Dreply&p=3D4130664 --===============6109381875380148635==--