473,387 Members | 1,859 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,387 software developers and data experts.

Help designing reading/writing a xml-fileformat

I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format. The basic layout of my code :

class Diagram {
Blocks blocks[]
}

class Block {
int x, y
}

class Square(Block) {
int width, height
}

class Circle(Block) {
int radius
}

I'd like to be able to output something similar to this:

<diagram>
<square x='12' y='34' width='50' height='40'/>
<circle x='40' y='60' radius='20/>
</diagram>

One idea I had was to make Diagram and Block derive from
xml.dom.minidom.Element,
and then somehow catch when I set an attribute, so that setAttribute()
gets called with correct
arguments. Perhaps then I could just do a simple diagram.toprettyxml().

Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)

/Jacob Kroon

Dec 13 '05 #1
2 1325
[Jacob Kroon]
I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format.
I highly recommend reading David Mertz excellent articles on the
conversion of objects to xml and vice-versa.

On the 'Pythonic' treatment of XML documents as objects, I + II
http://www-128.ibm.com/developerwork...rs1/index.html
http://www-128.ibm.com/developerwork...rs2/index.html

Revisiting xml_pickle and xml_objectify
http://www-128.ibm.com/developerwork...matters11.html
Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)


Why not the pickle module? XML-format pickles are a good solution to
your problem, IMHO.

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Dec 13 '05 #2
Jacob Kroon wrote:
I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format. The basic layout of my code :

class Diagram {
Blocks blocks[]
}

class Block {
int x, y
}

class Square(Block) {
int width, height
}

class Circle(Block) {
int radius
}

I'd like to be able to output something similar to this:

<diagram>
<square x='12' y='34' width='50' height='40'/>
<circle x='40' y='60' radius='20/>
</diagram>
[SNIP]
Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)


How about an XML pickle? PyXML has such a module. WDDX, also in
PyXML, is another option.

--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

Dec 13 '05 #3

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

Similar topics

6
by: Jake | last post by:
Hello, We have some code (see below) that has been working intermittently and I was wondering if someone had a better approach or an idea on why we get these errors. This part of code basically...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
2
by: arman | last post by:
Hi, I am newbie in php and i am having some probs. This is a cool forum and i ask for your help. so plz help me if u can. Here is my prob -- I am using domxml to read and write data from...
0
by: jmdeschamps | last post by:
I have to work with XML data containing accented characters (ISO-8859-1 encoding) Using ElementTree, the only way i found to get the text attribute of a node was to encode it individually, if you...
2
by: -D- | last post by:
I'm taking my first stab at using xml, so please bear with my novice questions and understanding of xml. I'm trying to create an xml file that holds all my website navigation. If I understand...
2
by: Aryan | last post by:
Hi, I have problem related to Caching of data. I am reading large xml file and putting this xml in dataset, since this dataset will contain many datatable's inside. And each datatable might be big...
1
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started...
1
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: ramyakrishnakumar | last post by:
Hi All, I am facing some problem with basic file operation... I have one xml file looks like <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <x:recording> <udf3>Gélin</udf3> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.