XML Schema Parsing for Form Input

Hello there. I have an odd use case. I'm trying to generate a HTML input form to capture data. The data is defined by a set of XMLSchema Files. I can load these files and validate XML against them. So far so good. What I want to be able to do is use an XSLT and convert the XSDs into a HTML form using lxml. This is irregular but since XSDs are valid XML, it should be possible. Indeed, it is trivial if one is using just one XML file. However, I have at least 8 XSD files with lines like this: <xs:import namespace="http://www.cdisc.org/ns/odm/v1.3" schemaLocation="ODM1-3-1.xsd"/> You can then have references such as <xs:element ref="odm:Description" minOccurs="0" maxOccurs="1"> If you parse the XSD as an XML file, xs:import statements are not followed, but if you run the etree.XMLSchema() method on your tree, these import statements are followed. I had an idea to create an intermediate xml file and use the xi:include directive and the etree.XInclude() method in order to load the referenced XSDs but the problem here is the attribute namespace reference. Example: <xs:group ref="sdm:CriterionElementPreExtension" minOccurs="0" maxOccurs="1"/> If I want to follow that ref, I need to look for an element with a name "CriterionElementPreExtension". However, that element must occur in the xml file included with the targetNamespace sdm. no way of doing this with an xi:include fudge. I think I need some kind of URL parser or addon class for lxml that, when it sees the xs:import, does the business with namespaces properly. Not sure how I can go about that. Cheers Ben Blundell -- Research & Scientific Programmer CB204, The Queens Building, Queen Mary University of London +44 (0)20 7882 6373 http://keys.gnupg.net/pks/lookup?search=Benjamin+Blundell

Hello, So for some years I've been working on Spyne and Neurons -- two separate projects. Spyne is an RPC framework that has what I call ComplexModel in the center. Neurons is a web framework that integrates with Spyne, Twisted and SqlAlchemy (that's not yet complete). Spyne started off as a soap framework but became a full-blown RPC library. Once you define a ComplexModel in Spyne, you can generate its xml schema. You can also parse an xml schema to get a ComplexModel back. You can serialize a ComplexModel instance to json, xml, yaml, msgpack, csv etc. as well as to a sql database, if you want to. With neurons, you can also serialize it to an html form (and back). Neurons can embed some of the xml schema constraints in html code (like pattern and maxLength). Spyne even applies some additional xml schema constraints to incoming http requests (without converting it to xml first :)). The catch? I haven't started the docs yet :) The code and some examples are out there[1][2] if you're willing to get your feet wet. And you can ask questions in Spyne's mailing list. I hope that helps. Best, Burak [1]: https://github.com/arskom/spyne [2]: https://github.com/plq/neurons On 09/08/15 18:18, Benjamin Blundell wrote:

Hello, So for some years I've been working on Spyne and Neurons -- two separate projects. Spyne is an RPC framework that has what I call ComplexModel in the center. Neurons is a web framework that integrates with Spyne, Twisted and SqlAlchemy (that's not yet complete). Spyne started off as a soap framework but became a full-blown RPC library. Once you define a ComplexModel in Spyne, you can generate its xml schema. You can also parse an xml schema to get a ComplexModel back. You can serialize a ComplexModel instance to json, xml, yaml, msgpack, csv etc. as well as to a sql database, if you want to. With neurons, you can also serialize it to an html form (and back). Neurons can embed some of the xml schema constraints in html code (like pattern and maxLength). Spyne even applies some additional xml schema constraints to incoming http requests (without converting it to xml first :)). The catch? I haven't started the docs yet :) The code and some examples are out there[1][2] if you're willing to get your feet wet. And you can ask questions in Spyne's mailing list. I hope that helps. Best, Burak [1]: https://github.com/arskom/spyne [2]: https://github.com/plq/neurons On 09/08/15 18:18, Benjamin Blundell wrote:
participants (2)
-
Benjamin Blundell
-
Burak Arslan