eed3si9n / scalaxb

scalaxb is an XML data binding tool for Scala.
http://scalaxb.org/
MIT License
337 stars 155 forks source link

local elements are not parsed correctly when the form is unqualified #26

Closed dbolene closed 13 years ago

dbolene commented 13 years ago

I'm not an XML expert (by choice :-) but isn't it legal to not have a default ns attribute like xmlns="someNameSpace" at the root but instead something like: "xmlns:nsname="someNameSpace" and then prefix the root element with <nsname:RootElement>...</nsname:RootElement>?

scalaxb can't seem to handle this

A full example:

<epcis:EPCISDocument xmlns:epcis="urn:epcglobal:epcis:xsd:1" creationDate="2010-03-15T06:07:08Z"
             schemaVersion="1">
   <EPCISBody>
      <EventList>
     <ObjectEvent>
        <eventTime>2010-03-22T11:47:01-05:00</eventTime>
        <eventTimeZoneOffset>-05:00</eventTimeZoneOffset>
        <epcList>
           <epc>urn:epc:id:sgtin:0614141.012345.101</epc>
           <epc>urn:epc:id:sgtin:0614141.012345.102</epc>
        </epcList>
        <action>OBSERVE</action>
        <bizStep>urn:epcglobal:cbv:bizstep:shipping</bizStep>
        <disposition>urn:epcglobal:cbv:disp:in_transit</disposition>
        <readPoint>
           <id>urn:epc:id:sgln:0614141.00000.1234</id>
        </readPoint>
        <bizTransactionList>
           <bizTransaction type="urn:epcglobal:cbv:btt:po">urn:epcglobal:cbv:bt:0614141000005:XYZ123</bizTransaction>
           <bizTransaction type="urn:epcglobal:cbv:btt:desadv">urn:epcglobal:cbv:bt:0614141000005:DA123</bizTransaction>
        </bizTransactionList>
     </ObjectEvent>
      </EventList>
   </EPCISBody>
</epcis:EPCISDocument>
eed3si9n commented 13 years ago

You are absolutely right. The whole issue of unqualified local elements have slipped my mind. The relevant part from the XML Schema spec is XML Representation of Element Declaration Schema Components:

{target namespace}

If form is present and its actual value is qualified, or if form is absent and the actual value of elementFormDefault on the <schema> ancestor is qualified, then the actual value of the targetNamespace [attribute] of the parent <schema> element information item, or absent if there is none, otherwise absent.

Since the default value of elemeFormDefault is unqualified, unless otherwise specified the local elements must be unqualified. Schemas like XML Schema and XHTML specify this value to qualified, but this is a defect of scalaxb not handling form correctly.

eed3si9n commented 13 years ago

Implemented support for elementFormDefault and form. https://github.com/eed3si9n/scalaxb/commit/303fee6651b8c0cb21a4d24f0fe35ab60b7e9c00