Current location: Hot Scripts Forums » Programming Languages » Other Languages » dtd validation with python


dtd validation with python

Reply
  #1 (permalink)  
Old 06-22-06, 02:40 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
dtd validation with python

hi,
i've written a XML parser in python (both reader and writer), and i want to check the structure of the outputted xml document by a dtd (document type definition). i'm using this to send data to flash, through a socket. is it possible to do so: before sending the data to flash, validate the document against the dtd?

thanx,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #2 (permalink)  
Old 06-22-06, 10:41 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Can you post what you have so far? It would make it easier to help.
__________________
Reply With Quote
  #3 (permalink)  
Old 06-23-06, 02:17 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
ok, here's what i have so far (don't mind the dutch language):
The XML Reader
The XML Writer

they both use the CElementTree module. when using em, you have to fill in or an XMLString, or 1 or 2 dictionaries containing the xml-document's structure. something like this:
Code:
a = dict()
a["root"] = dict()
a["root"]["text"] = "Hello World"
a["root"]["username"] = "John"
will result in:
Code:
<root>
  <text>Hello World</text>
  <username>John</username>
</root>
after that the Writer returns the xmlstring, and the Reader will return 2 dictionaries: 1 dict containing the xml nodes, and 1 containing the attributes

thanx for looking in to it,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #4 (permalink)  
Old 06-23-06, 09:35 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Hey bud,

Here is a short list of XML Parsing software (with DTD Validation) that should help you with what you are trying to do:

PyLTXML
PyLTXML is a Python extension wrapping the LTXML parser. It supports DTD validation.
http://www.ltg.ed.ac.uk/software/xml/

cDomlette
cDomlette is part of 4Suite. It is a fast C-based DOM implementation with a Python API, and includes a wrapper of the expat parser. It supports DTD validation. It also supports XInclude and XML Base and XML entity catalogs.
http://4suite.org/

libxml/python
This Python extension module is a wrapper for libxml. It supports DTD validation, XInclude (plus XPointer), XML Base and XML Catalogs.
http://xmlsoft.org/python.html

pyRXP
pyRXP is a Python extension wrapping the RXP XML parser. It supports DTD validation.
http://www.reportlab.com/xml/pyrxp.html

pyexpat
Pyexpat is part of PyXML and is a wrapper of the expat parser. It supports DTD validation.
http://pyxml.sourceforge.net/

qp_xml
qp_xml is part of PyXML. It is a simple parser written entirely in Python with no validation support.
http://pyxml.sourceforge.net/

xmlproc
xmlproc is part of PyXML. It is a parser written entirely in Python. It supports DTD validation and XML catalogs. It provides API access to parsed DTD constructs.
http://pyxml.sourceforge.net/

I hope this helps.
__________________
Reply With Quote
  #5 (permalink)  
Old 06-23-06, 10:56 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
thx for the links,

do you prefere any of these modules? speed is a requirement, cause it needs to be able to parse a xml document of about 3Mb filesize in less then 10 seconds.

if i'm gonna use one of those xml libraries, i'll probably have to rewrite the parser i have now? or is it good enough if i just use the dtd-validation function of 1 module to check the xmlstring written by the cElementTree module?

many thanx,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #6 (permalink)  
Old 06-23-06, 11:32 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
It's really a matter of preference. I have used LT XML, because they have good documentation and is pretty fast (I don't know about the 10 second requirement though). You will need to re-write part of the code though, based on which library you choose.
__________________
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
List of Python Tutorials and Resources digioz Other Languages 2 02-08-09 11:14 PM
Converting VB6 script to Python LAMPX The Lounge 0 04-11-06 05:51 PM
Python UnrealEd Hot Scripts Forum Questions, Suggestions and Feedback 2 03-27-06 03:38 PM
validation not working buzzby PHP 13 05-29-05 02:09 PM
Frameset DTD El Barto HTML/XHTML/XML 4 02-13-05 10:10 AM


All times are GMT -5. The time now is 03:39 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.