Skip to content
Go to file
Cannot retrieve contributors at this time
99 lines (83 sloc) 2.96 KB


xsd.Ref() is not serialized

XML schema references are not serialized. Below is an example of code that does not generate a valid schema:

from lxml import etree
from soapfish import py2xsd, xsd

class Person(xsd.Group):
    name = xsd.Element(xsd.String)
    surname = xsd.Element(xsd.String)

class Job(xsd.ComplexType):
    title = xsd.Element(xsd.String)
    person = xsd.Ref(Person)

schema = xsd.Schema(
    elements={'job': xsd.Element(Job())},

print(etree.tostring(py2xsd.generate_xsd(schema), pretty_print=True))

Incorrect XML Schema:

<xsd:schema xmlns:sns="" xmlns:xsd="" targetNamespace="" elementFormDefault="qualified">
  <xsd:element name="job">
        <xsd:element name="title" type="xsd:string" minOccurs="1" nillable="false"/>

Expected XML Schema:

<xsd:schema xmlns:site="" xmlns:xs="" targetNamespace="" elementFormDefault="qualified">
  <xsd:element name="person">
        <xsd:element name="name" type="xs:string"/>
        <xsd:element name="surname" type="xs:string"/>
  <xsd:element name="job">
        <xsd:element name="title" type="xs:string" minOccurs="1" nillable="false"/>
        <xsd:element ref="site:person"/>

Valid XML for Expected Schema:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<job xmlns="">
  <title>Software Developer</title>

XSDDate does not support full date range

The XML schema specification does not limit the range of dates representable by xs:date. For example, the values -2000-03-10 and 20000-04-20 are valid as far xs:date is concerned. Currently soapfish.xsd_types.XSDDate is subclassing Python's standard library which has a much more narrow definition.

Very likely the best solution is to back our implementation with an alternative date implementation such as mxDateTime which seems to represent all possible values from xs:date. As mxDateTime currently (2014-11-13) uses compiled components (making it harder to install in some environments) and does not support Python 3 this should likely be an optional dependency (if at all).

You can’t perform that action at this time.