473,394 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Python code from XMLSchema?

I need to be able to unmarshall data from an XML file into (instances of)
appropriate Python classes . I don't have control over the schema used.

I'd like the Python classes to use lists for elements whose XMLSchema spec
has maxOccurs > 1, simple attributes for maxOccurs = minOccurs = 1, dict
for element attributes, etc.

In the past I've just used SAX and hand-written the parsing - a
straightforward, fairly mechanical task. In short, perfect for a tool.

I've poked a little through the PyXML collection but don't really see what I
want (although I could be missing it). Does someone know of a tool to do
this kind of thing? Perhaps taking an XMLSchema with a cleverly written
XSLT script to do the transform?

Or am I making this harder than it has to be?

Thanks for any pointers,
Russell.

Jul 18 '05 #1
3 1500
Russell Lear wrote:
I need to be able to unmarshall data from an XML file into
(instances of)
appropriate Python classes . I don't have control over the schema
used.

I'd like the Python classes to use lists for elements whose
XMLSchema spec has maxOccurs > 1, simple attributes for maxOccurs
= minOccurs = 1, dict for element attributes, etc.


Here are links to two different solutions: generateDS.py and
xml_objectify. One is shameless self-promotion; you will have to
figure out which.

http://www.rexx.com/~dkuhlman/generateDS.html
http://gnosis.cx/publish/programming/xml_matters_2.txt

And, here is a document that compares the above two approaches:

http://www.rexx.com/~dkuhlman/gnosis_generateds.html

And, if you are considering the use of XSLT, you may also be
interested in the following document, which describes the use of
generateDS.py as an alternative to XSLT:

http://www.rexx.com/~dkuhlman/xsltvsgenerateds.html

Dave

[snip]
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
Jul 18 '05 #2
Dave Kuhlman wrote:
http://www.rexx.com/~dkuhlman/gnosis_generateds.html


Why do you think that XSLT is not a "full programming language"?

Cheers,
Brian

Jul 18 '05 #3
Brian Quinlan wrote:
Dave Kuhlman wrote:
http://www.rexx.com/~dkuhlman/gnosis_generateds.html


Why do you think that XSLT is not a "full programming language"?


Because I'm biased and prejudiced and pig-headed?

XSLT seems very special purpose to me.

Many years ago, I took a class in "comparative programming
languages" from a professor who loved to say: "I can do A in X.",
where A was some task that was very inappropriate for language X,
for example string processing in FORTRAN, numerical analysis in
Lisp, etc. So, why don't we write a mail reader in XSLT or maybe
we could re-write the Python C code implementation in XSLT.

OK. I'm being silly, but you get my point.

What is the technical term for a "full" or "complete" programming
language? Turing complete? Is XSLT Turing complete? I suppose it
is. But it still seems special purpose to me.

For me, saying that Python is a full programming language and XSLT
is not is similar to saying that Python is good and Perl is bad.
That claim is not defensible but is totally true.

But then you already knew that I'm biased and prejudiced and
pig-headed.

Dave

--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JuiceMan | last post by:
Hi, i've been trying to access the my company's SOAP webservice with no luck. I'm using the httplib library. This is my code: from httplib import HTTP from urllib import quote
0
by: BODIN | last post by:
I have an XML document, which is actually physically stored in 2 separated files. doc1.xml and doc2.xml I NEED a WAY FOR THIS SIMPLE NEED : XML file splitted into two physical files, and use...
2
by: AlexS | last post by:
Hello, I have error when reading schema using XmlSchema. Read and then .Compile: System.Xml.Schema.XmlSchemaException: May not be nominated as the {substitution group affiliation} of any...
2
by: Alex Shirshov | last post by:
Hello, All! It seems the bug (http://groups.google.com/groups?hl=ru&lr=&ie=UTF-8&threadm=a53b01c28a00%242 08bc860%2439ef2ecf%40TKMSFTNGXA08&rnum=8&prev=/groups%3Fq%3DschemaLocation%2...
2
by: Steve at Pixelda | last post by:
I accidentally put this on another group - this is the more likley home... The first code fragment creates the simplest of XML Schemas is code. After the “Compile()” method is called on the...
0
by: Rafal Zawadzki | last post by:
Hi. I tried earlier to write python zsi mail list, but nobody answered. I am using ZSI 1.7/2.0rc1 with TTPro Soap SDK. The wsdl file can be found here: http://demo.seapine.com/ttsoapcgi.wsdl ...
0
by: Doug Caldwell | last post by:
Hi! ** Accessing the USGS Web Service Using Python ** I am trying to access the US Geological Survey's gazetteer SOAP web service using Python to find the locations of all the places with the...
4
by: moorcroft | last post by:
Hi, I'm new to using SOAP so apologies for any ignorance on my part! I'm trying to write java code to create the following SOAP message and return message, and am wondering if someone could...
0
by: Default User | last post by:
I work on creating test cases for a SOAP-based set of servers, using soapUI. I received and updated set of WSDL and schema files, and when I made new tests and mock server operations, all of the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.