Hello you all,
I seem to have stumbled on a problem with the on demand validation that I cannot find in previous discussions.
Some background first. I am developing a content management application using JAXB, Struts and Cocoon.
The XML is unmarshalled (w/ setValidating(true) without any validation errors but on demand validation of the generated object tree gives the error:
tag name "se.cm.data.bind.AmnesgruppBaseType" is not allowed. Possible tag names are: <Rubrik> (row -1,column -1)
This problem puts me in a very tight spot since I either has to perform all validation in the applications business logic or redesign the schema with major implications on the XML-consumer side.
What do you say. Is this a bug or not?
Best regards
Peter Lindvall
-----= XML =-----
<?xml version="1.0" encoding="ISO-8859-1"?>
<Huvudgrupp xmlns:jxb="
http://java.sun.com/xml/ns/jaxb" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<Rubrik>Headline</Rubrik>
<Amnesgrupp>
<Rubrik>Level 1</Rubrik>
<Amnesgrupp>
<Rubrik>Level 2</Rubrik>
<!-- Next element is causing the error-->
<Amnesgrupp>
<Rubrik>Level 3</Rubrik>
</Amnesgrupp>
</Amnesgrupp>
</Amnesgrupp>
</Huvudgrupp>
-----= Schema =-----
The schema contains a lot more type restriction stuff that is removed here for brevity. The types that captures the basic layout are HuvudgruppType, AmnesgruppLevel1, AmnesgruppLevel2 and AmnesgruppBaseType (and ProduktType).
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema xmlns:jxb="
http://java.sun.com/xml/ns/jaxb" xmlns:xs="
http://www.w3.org/2001/XMLSchema" jxb:version="1.0">
<xs:complexType name="HuvudgruppType">
<xs:sequence>
<xs:element name="Rubrik" type="xs:string"/>
<xs:element name="Amnesgrupp" type="AmnesgruppLevel1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Huvudgrupp" type="HuvudgruppType">
<xs:annotation>
<xs:documentation>The root element</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="AmnesgruppLevel1">
<xs:annotation>
<xs:documentation>Defines the containment structure for Amnesgrupp Level 1</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="AmnesgruppBaseType">
<xs:sequence>
<xs:element name="Amnesgrupp" type="AmnesgruppLevel2" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="AmnesgruppLevel2">
<xs:annotation>
<xs:documentation>Defines the containment structure for Amnesgrupp Level 2</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="AmnesgruppBaseType">
<xs:sequence>
<xs:element name="Amnesgrupp" type="AmnesgruppBaseType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="AmnesgruppBaseType">
<xs:annotation>
<xs:documentation>Defines self-contained properties of Amnesgrupp</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Rubrik" type="xs:string"/>
<xs:element name="Kommentar" type="xs:string" minOccurs="0"/>
<xs:element name="FromDatum" type="xs:date" minOccurs="0"/>
<xs:element name="TomDatum" type="xs:date" minOccurs="0"/>
<xs:element name="Produkt" type="ProduktType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProduktType">
<xs:sequence>
<xs:element name="Code" type="xs:string" minOccurs="0"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Assignment" type="xs:string" minOccurs="0"/>
<xs:element name="Id" type="xs:string"/>
<xs:element name="Attach" type="xs:string" minOccurs="0"/>
<xs:element name="SuggestedNo" type="xs:positiveInteger"/>
<xs:element name="MaxNo" type="xs:positiveInteger"/>
<xs:element name="Pdf" minOccurs="0" type="xs:string" />
</xs:sequence>
<xs:attribute name="Kontroll" use="required" type="xs:string"/>
<xs:attribute name="Kategori" use="required" type="xs:string"/>
</xs:complexType>
</xs:schema>