Seems that the bug propagates to the inner elements as well. I was
expecting
<package>
<filesets>
<enumset guid="abcde" name="alfa" description="alfa description"
type="dev"/>
<ruleset guid="wxyz" name="beta" description="beta description
type="dev">
<load resource="/"/>
</ruleset>
</filesets>
</package>
but I got
<package>
<filesets>
<enumset guid="abcde" name="alfa" description="alfa description"
type="dev"/>
<ruleset guid="wxyz" name="beta" description="beta description
type="dev" resource="/" />
</filesets>
</package>
No <load> !!!! and the resource attribute got marshalled into <ruleset>
!!!!
Again, same workaround fixed the output. (declaring <load> and <check> as
possible root elements and using a reference ( <element ref="load"/> )where
the original declaration was. )
-Jorge
JMedina_at_on.com wrote on 08/14/2003 01:46:07 PM:
> I have a schema in which a type (FilesetType) is used as the base
> for two other types (EnumsetType and RulesetType).
>
> I tried to build a "document" by creating a new root (ObjectFactory.
> createPackageElement), and then I was adding the subelements. I
> tried to add derived types to its container (FilesetsType) by
> creating new object with createEnumsetType() and
> createRulesetType(). Everything seemed to work. I was even able to
> marshal the "document" into XML but the produced output was wrong.
> The container (<filesets>) was getting the attributes of its
> children (<enumset> and <ruleset>) and the childrens never appeared
> into the document. Even more, the attributes were repeated at the
> container (<filesets>). So, I got something like:
>
> <package>
> <filesets guid="abcde" name="alfa" description="alfa description"
> type="dev" guid="wxyz" name="beta" description="beta description
> type="gamma"/>
> </package>
>
> when, i was expecting:
>
> <package>
> <filesets>
> <enumset guid="abcde" name="alfa" description="alfa description"
type="dev"/>
> <enumset guid="wxyz" name="beta" description="beta description
type="gamma"/>
> </filesets>
> </package>
>
>
> I modified the schema to look like below (Version 2), declaring
> <enumset> and <ruleset> as possible roots. Then I changed my code to
> createEnumsetElement() and createRulesetElement(). This change
> produced the correct output.
>
> Although I found a workaround, I think that it is a serious bug
> since the marshalling was putting the attributes in an element that
> was not even supposed to have any and was even repeating the
> attributes on that entity !!!
>
> If you require more details, let me know.
>
> -Jorge
>
> -------------------------- XML Schema Version 1
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.on.com/xml/schemas"
> xmlns="http://www.on.com/xml/schemas"
> elementFormDefault="unqualified"
> attributeFormDefault="unqualified">
>
> <xsd:element name="package" type="PackageType"/>
>
> <xsd:element name="comment" type="TextType"/>
>
> <xsd:element name="filesets" type="FilesetsType"/>
>
> <!-- Types -->
>
> <xsd:complexType name="PackageType">
> <!-- Sequenced entities -->
> <xsd:all>
>
> <xsd:element ref="comment" minOccurs="0"/>
>
> <xsd:element ref="filesets" minOccurs="0"/>
>
> </xsd:all>
>
> </xsd:complexType>
>
> <xsd:complexType name="TextType">
> <xsd:complexContent mixed="true">
> <xsd:restriction base="xsd:anyType">
> <xsd:sequence>
> <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <!-- <xsd:attribute name="name" type="ScriptNameType"/> -->
> </xsd:restriction>
> </xsd:complexContent>
> </xsd:complexType>
>
> <xsd:complexType name="FilesetsType">
> <xsd:sequence>
> <xsd:choice minOccurs="0" maxOccurs="unbounded">
> <xsd:element name="enumset" type="EnumsetType"/>
> <xsd:element name="ruleset" type="RulesetType"/>
> </xsd:choice>
> </xsd:sequence>
> </xsd:complexType>
>
> <!-- Definitions for filesets using derived types -->
>
> <xsd:complexType name="FilesetType">
> <xsd:attribute name="guid" type="GUIDType" use="required"/>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="description" type="xsd:string"/>
> <xsd:attribute name="type" type="FilesetPurposeType" use="required"/>
> <xsd:attribute name="envname" type="xsd:ID" use="required"/>
> </xsd:complexType>
>
> <xsd:complexType name="RulesetType">
> <xsd:complexContent>
> <xsd:extension base="FilesetType">
> <xsd:sequence>
> <xsd:choice minOccurs="0" maxOccurs="unbounded">
> <xsd:element name="load" type="LoadType"/>
> <xsd:element name="check" type ="CheckType"/>
> </xsd:choice>
> </xsd:sequence>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> <xsd:complexType name="EnumsetType">
> <xsd:complexContent>
> <xsd:extension base="FilesetType">
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> </xsd:complexType>
>
> <xsd:simpleType name="GUIDType">
> <xsd:restriction base="xsd:string">
> <xsd:pattern value="[A-F0-9]{16,16}"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> <xsd:simpleType name="FilesetPurposeType">
> <xsd:restriction base="xsd:string">
> <xsd:enumeration value="vendor"/>
> <xsd:enumeration value="dev"/>
> <xsd:enumeration value="info"/>
> <xsd:enumeration value="script"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> </xsd:schema>
>
>
> -------------------------- XML Schema Version 2
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.on.com/xml/schemas"
> xmlns="http://www.on.com/xml/schemas"
> elementFormDefault="unqualified"
> attributeFormDefault="unqualified">
>
> <xsd:element name="package" type="PackageType"/>
>
> <xsd:element name="comment" type="TextType"/>
>
> <xsd:element name="filesets" type="FilesetsType"/>
>
> <!-- Types -->
>
> <xsd:complexType name="PackageType">
> <!-- Sequenced entities -->
> <xsd:all>
>
> <xsd:element ref="comment" minOccurs="0"/>
>
> <xsd:element ref="filesets" minOccurs="0"/>
>
> </xsd:all>
>
> </xsd:complexType>
>
> <xsd:complexType name="TextType">
> <xsd:complexContent mixed="true">
> <xsd:restriction base="xsd:anyType">
> <xsd:sequence>
> <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> <!-- <xsd:attribute name="name" type="ScriptNameType"/> -->
> </xsd:restriction>
> </xsd:complexContent>
> </xsd:complexType>
>
> <xsd:element name="enumset" type="EnumsetType"/>
> <xsd:element name="ruleset" type="RulesetType"/>
>
> <xsd:complexType name="FilesetsType">
> <xsd:sequence>
> <xsd:choice minOccurs="0" maxOccurs="unbounded">
> <xsd:element ref="enumset"/>
> <xsd:element ref="ruleset"/>
> </xsd:choice>
> </xsd:sequence>
> </xsd:complexType>
>
> <!-- Definitions for filesets using derived types -->
>
> <xsd:complexType name="FilesetType">
> <xsd:attribute name="guid" type="GUIDType" use="required"/>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="description" type="xsd:string"/>
> <xsd:attribute name="type" type="FilesetPurposeType" use="required"/>
> <xsd:attribute name="envname" type="xsd:ID" use="required"/>
> </xsd:complexType>
>
> <xsd:complexType name="RulesetType">
> <xsd:complexContent>
> <xsd:extension base="FilesetType">
> <xsd:sequence>
> <xsd:choice minOccurs="0" maxOccurs="unbounded">
> <xsd:element name="load" type="LoadType"/>
> <xsd:element name="check" type ="CheckType"/>
> </xsd:choice>
> </xsd:sequence>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> <xsd:complexType name="EnumsetType">
> <xsd:complexContent>
> <xsd:extension base="FilesetType">
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> </xsd:complexType>
>
> <xsd:simpleType name="GUIDType">
> <xsd:restriction base="xsd:string">
> <xsd:pattern value="[A-F0-9]{16,16}"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> <xsd:simpleType name="FilesetPurposeType">
> <xsd:restriction base="xsd:string">
> <xsd:enumeration value="vendor"/>
> <xsd:enumeration value="dev"/>
> <xsd:enumeration value="info"/>
> <xsd:enumeration value="script"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> </xsd:schema>