Implementing the xs:all tag#584
Conversation
|
jenkins, run tests |
|
hey, thanks for the patch! one of your tests are failing, can you have a look? |
|
What's the point of having a group name for the xs:all tag? What happens when you pass different values to xml_all_group ? |
|
Will fix tests, pushed this out a bit late last night :) I modeled the group name after the implementation of xs:choice, with the addition that xs:all is a direct subelement of complexType instead of in a sequence. I will add an additional failure case for when you specify two "all groups" in the same element |
<xs:complexType name="AbcAll">
<xs:all>
<xs:element name="abc" type="xs:string"/>
<xs:element name="bcd" type="xs:string" minOccurs="0"/>
</xs:all>
<xs:all>
<xs:element name="cde" type="xs:string" minOccurs="0"/>
</xs:all>
</xs:complexType>gets generated if I specify something like class AbcAll(ComplexModel):
abc = Unicode(xml_all_group="all1", min_occurs=1)
bcd = Unicode(xml_all_group="all1")
cde = Unicode(xml_all_group="all2")This then fails lxml schema validation in I can add an explicit check for this in the code and throw a reasonable error |
|
It's been some time since I looked at the xml schema spec so please correct me if I'm wrong here.
Instead of throwing an error, we have two options depending on whether you can have both If it's possible, we could change so your example becomes: class AbcAll(ComplexModel):
abc = Unicode(xml_main_group='all', min_occurs=1)
bcd = Unicode(xml_main_group='all')
cde = Unicode(xml_main_group='sequence')
def = Unicode(xml_main_group='sequence')which would generate: <xs:complexType name="AbcAll">
<xs:all>
<xs:element name="abc" type="xs:string"/>
<xs:element name="bcd" type="xs:string" minOccurs="0"/>
</xs:all>
<xs:sequence>
<xs:element name="cde" type="xs:string" minOccurs="0"/>
<xs:element name="def" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>If having both class AbcAll(ComplexModel):
class Attributes(ComplexModel.Attributes):
xml_main_group='all'
abc = Unicode(min_occurs=1)
bcd = Unicode
cde = Unicodewhich would generate <xs:complexType name="AbcAll">
<xs:all>
<xs:element name="abc" type="xs:string"/>
<xs:element name="bcd" type="xs:string" minOccurs="0"/>
<xs:element name="cde" type="xs:string" minOccurs="0"/>
</xs:all>
</xs:complexType>It seems both could be implemented with minor modifications to your current patch. So, what does the spec say? |
|
Schema says they cannot coexist. Will look into making it a class attribute |
No description provided.