users@jaxb.java.net

Re: Duplicated namespace declaration from output xml

From: Son Nguyen <sontrang91_at_gmail.com>
Date: Tue, 21 Oct 2008 09:25:16 -0700 (PDT)

I was able to create a similar situation using a smaller schema so that it is
to reproduce.

Here is the schema: Book.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">


<xs:element name="Collection">
   <xs:complexType>
      <xs:sequence>
        <xs:element name ="books">
           <xs:complexType>
              <xs:sequence>
                <xs:element name="book" type="bookType" minOccurs="1"
maxOccurs="unbounded"/>
              </xs:sequence>
           </xs:complexType>
        </xs:element>
      </xs:sequence>
   </xs:complexType>
</xs:element>

<xs:complexType name="bookType">
  <xs:sequence>
    <xs:element name="name" type="xs:anySimpleType" minOccurs="0"/>
    <xs:element name="ISBN" type="xs:anySimpleType" minOccurs="0"/>
    <xs:element name="price" type="xs:anySimpleType" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

</xs:schema>


The output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Collection>
    <books>
        <book>
            <name xsi:type="xs:string"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">ABC</name>
        </book>
    </books>
</Collection>


I think the problem comes from the xs:anySimpleType. If I change it to
string, it will works as normal. It also make sense that jaxb create output
with types for anySimpleType element. However, it will be a lot nicer if
jaxb can group all the xml declaration on the top and just use the nametag
for it. Do you know a way to tell jaxb to do that?

Attachment is the complete project for you to run.

Thanks,


-- 
View this message in context: http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-tp20069914p20094153.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.