473,594 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1511
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 "comparativ e 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
3172
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
1770
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 of XML Schema.
2
9065
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 other declaration. An error occurred at , (11, 3). Schema compile error: System.Exception: Schema error ---> System.Xml.Schema.XmlSchemaException: May no
2
1892
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 BXmlSchema%2B.NET%26hl%3Dru%26lr%3D%26ie%3DUTF-8%26selm%3Da53b01c28a00%25242 08bc860%252439ef2ecf%2540TKMSFTNGXA08%26rnum%3D8) wasn't fixed neither in v1.1 nor in v2.0. Here is exception
2
1352
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 schemaset objetc, the schema element count is zero – but I was expecting one element in the PSVI. I saved the XML output in the console window to a file, and ran the second code fragment below to load in the XML from the file, and compile the...
0
2535
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 My wsdl is the same, only different is the address of the cgi file. for example i cannot use defectRequest method:
0
1497
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 name 'Alexandria.' I tried to keep this simple by putting a soap message in a string and sending the request using httplib. I am receiving the following error message.
4
2213
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 please talk me through it? (PS I've starred out parts of it as they are private to my company!) POST /*****/*****.asmx HTTP/1.1 Host: localhost Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0"...
0
3127
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 ones that had been working now returned a SOAP fault. The faults look something like: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <soap:Fault> <soap:Code>
0
7946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8253
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8009
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8240
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3867
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1482
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.