MichielCM / xsd2html2xml

Generates plain HTML5 forms from XML schemas (XSDs). Transforms filled-in forms into XML.
MIT License
95 stars 42 forks source link

element in included base type not appearing on the html form #19

Closed kgi-github closed 5 years ago

kgi-github commented 5 years ago

I have an issue where an element defined in a base type doesn't appear on the generated form.

This happens when the schema file defining the root element includes a second schema file defining the type of the root element, which in turn includes a third schema file defining the base type.

I have three files. First is test.xsd, specifying the root element "test":

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

    <xs:include schemaLocation="MyType.xsd"/>

    <xs:element name="test" type="MyType"/>

</xs:schema>

Second is MyType.xsd defining "MyType" which extends the type "Base":

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

    <xs:include schemaLocation="Base.xsd"/>

    <xs:complexType name="MyType">
        <xs:complexContent>
            <xs:extension base="Base">
            </xs:extension>
        </xs:complexContent>    
    </xs:complexType>

</xs:schema>

Third is Base.xsd, which defines the type "Base", specifying an element called "baseElement":

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

    <xs:complexType name="Base">
        <xs:sequence>
            <xs:element name="baseElement" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>

No field for the "baseElement" element appears on the generated html form.

Note that this happens with xsd2html2xml 3.2, it is not caused by the fix you made to avoid multiple fields in the base type.

cheers, Kevin.

MichielCM commented 5 years ago

There seems to be some connection, though. If I look at the stack trace, Base.xsd is never loaded in the newer commit. But if I change this line: <xsl:for-each select="(//xs:schema)[1]//xs:include"> to: <xsl:for-each select="(//xs:schema)//xs:include"> it does work.

There seems to be a serious bug with how external documents are loaded into memory. It's on my list but I can't promise how soon I'll be able to attend to it.

MichielCM commented 5 years ago

The issue should be fixed in release 3.3. Can you confirm?

kgi-github commented 5 years ago

Hi, Sorry - I missed github's notification of your comment 10 days ago, I would have replied. Yes, the issue appears to be fixed. Thanks so much! Kevin.

MichielCM commented 5 years ago

Glad it works! I'm closing this issue.