Justin,
Good to hear from you. Glad to hear that generateDS.py has been
useful to you.
Yes, I still work on it, when I have time.
I'll take a look at your issue. I'll have to study this a bit,
because I thought that exporting that element *should* produce
'<Dog>' rather than '<Animal type="Dog" ...'.
I've attached a schema (`test01.xsd`), which is (almost) a copy of
your example schema, and an XML instance document (`test01.xml`),
which is an instance of the schema's document type. When I use
xmllint, it validates:
$ xmllint --schema test02.xsd test02.xml
<?xml version="1.0"?>
<dogcollection>
<dog>
<name>jasmine</name>
<fur>curly</fur>
</dog>
<dog>
<name>peaches</name>
<fur>straight</fur>
</dog>
</dogcollection>
test02.xml validates
So, there must be something about your issue and example that I do
not understand.
Note that there is similar capability of XML schema that provides
this kind of flexibility (and confusion for me). This strategy uses
the `xsi:type` attribute to specify the derived type of an instance
element. You can read about it here:
- https://www.w3.org/TR/2004/REC-xmlschema-0-20041028/#DerivExt
- https://www.w3.org/TR/2004/REC-xmlschema-0-20041028/#UseDerivInInstDocs
I'll be back when I've learned more. Or, if you find a way to solve
your problem, please let me know.
Dave
On Tue, Oct 02, 2018 at 09:25:32AM -0400, Justin McManus wrote:
> Hi,
>
> Your generateDS library has been really useful to me, thanks. However, I
> just found a blocking bug for my use case, and I checked sourceforge and
> bitbucket and didn't find any public issue trackers that I could report it
> on. I'll take a look at fixing it anyway, but I wanted to check if there's
> a place to report this officially, and whether you're accepting pull
> requests.
>
> The issue was found in generateDS 2.29.24 from PyPi. The gist of it is that
> complex subtypes are always assumed to be defined as substitution groups,
> e.g. type "Dog" that extends an abstract type "Animal" will be rendered as
> <Dog> instead of <Animal type="Dog">, which fails xsd validation. Here's a
> minimal example:
>
> *example.xsd:*
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
> <xs:element name="SubType" type="SubType"></xs:element>
> <xs:complexType name="AbstractBaseType" abstract="true"></xs:complexType>
> <xs:complexType name="SubType">
> <xs:complexContent>
> <xs:extension base="AbstractBaseType"></xs:extension>
> </xs:complexContent>
> </xs:complexType>
> </xs:schema>
>
> $> generateDS -o example.py ./example.xsd
> *$> python*
> >>> import sys, example
> >>> example.SubType().export(sys.stdout, 0)
> <SubType/>
--
Dave Kuhlman
http://www.davekuhlman.org
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xs:element name="dog" type="dog"></xs:element>
<xs:complexType name="animal" abstract="true"></xs:complexType>
<xs:complexType name="dog">
<xs:complexContent>
<xs:extension base="animal">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
<?xml version="1.0"?>
<dog>
<name>jasmine</name>
</dog>
_______________________________________________
generateds-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/generateds-users