From yakumoklesk at yahoo.es Sun Sep 14 12:40:13 2008 From: yakumoklesk at yahoo.es (David Lucena) Date: Sun, 14 Sep 2008 10:40:13 +0000 (GMT) Subject: [XML-SIG] PyXML and DOM example 'generate_xml1.py' Message-ID: <411464.18620.qm@web23704.mail.ird.yahoo.com> I've started to use PyXML because I needed a xml library for a tool I am making. Due to lack of documentation, I have been looking for the examples, but I've found some of them does not work. In fact, the fist I tested was the one on the Subject. I have made some modifications get it to work. Here I paste the full file contents: """ A basic example of using the DOM to create an XML document from scratch. """ from xml.dom import ext from xml.dom import implementation if __name__ == '__main__': #Create a doctype using document type name, sysid and pubid dt = implementation.createDocumentType('mydoc', '', '') #Create a document using document element namespace URI, doc element #name and doctype. This automatically creates a document element #which is the single element child of the document doc = implementation. ( None, 'mydoc', dt) #Get the document element doc_elem = doc.documentElement #Create an element: the Document instanmce acts as a factory new_elem = doc.createElementNS( None, 'spam') #Create an attribute on the new element new_elem.setAttributeNS( None, 'eggs', 'sunnysideup') #Create a text node new_text = doc.createTextNode('some text here...') #Add the new text node to the new element new_elem.appendChild(new_text) #Add the new element to the document element doc_elem.appendChild(new_elem) #Print out the resulting document import xml.dom.ext xml.dom.ext.Print(doc) Basic changes have been: -Change createHTMLDocument for createDocument -Change '' for None in, createDocument, createElementNS, createAttributeNS -Change the two lines from "xml.doc.*" to "xml.dom.*" Please, report if I am wrong or not. Thanks, David. PS.- I have changed createHTMLDocument for createDocument because first only takes 2 arguments whereas second takes four, as it reported the function from inspect module 'getargspec' From fredrik at pythonware.com Sun Sep 14 13:35:53 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 14 Sep 2008 13:35:53 +0200 Subject: [XML-SIG] PyXML and DOM example 'generate_xml1.py' In-Reply-To: <411464.18620.qm@web23704.mail.ird.yahoo.com> References: <411464.18620.qm@web23704.mail.ird.yahoo.com> Message-ID: David Lucena wrote: > I've started to use PyXML because I needed a xml library for > a tool I am making. if you're writing new code, I strongly suggest using a library based on the ElementTree API instead of struggling with an old, unmaintained and rather unwieldy XML library. if I'm reading things correctly, your entire example boils down to import xml.etree.ElementTree as ET elem = ET.Element("spam", eggs="sunny side up") elem.text = "some text here..." print ET.tostring(elem) with the ET API. The standard implementation of ET is included in Python 2.5 and later: http://docs.python.org/dev/library/xml.etree.elementtree.html and is available for Python 1.5.2 and newer from here: http://effbot.org/zone/element-index.htm and there's also a separate implementation based on the libxml2 and libxslt libraries, which adds validation and lots of other goodies: http://codespeak.net/lxml/ From a.gioti at ucl.ac.uk Fri Sep 19 16:20:58 2008 From: a.gioti at ucl.ac.uk (Natassa Gioti) Date: Fri, 19 Sep 2008 15:20:58 +0100 (BST) Subject: [XML-SIG] Problem installing Pyxml Message-ID: <59305.128.40.80.40.1221834058.squirrel@www.squirrelmail.ucl.ac.uk> Hallo, I have Python 2.5 version on a MacOSX, and tried to install Pyxml: python setup.py build error: command 'gcc' failed with exit status 1 I previously had problems with other programs I tried to install, as if no gcc compiler could be found, but do not know how to check that indeed ( I used alternative programs previously). Could you please help me with that? I am a newbie in such issues... Thank you in advance, Natassa Gioti Research Associate - Bioinformatics Institute of Healthy Ageing, and GEE Room 324, The Darwin Building University College London Gower Street, London WC1E 6BT, UK. From bortzmeyer at nic.fr Fri Sep 19 17:04:06 2008 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Fri, 19 Sep 2008 17:04:06 +0200 Subject: [XML-SIG] Problem installing Pyxml In-Reply-To: <59305.128.40.80.40.1221834058.squirrel@www.squirrelmail.ucl.ac.uk> References: <59305.128.40.80.40.1221834058.squirrel@www.squirrelmail.ucl.ac.uk> Message-ID: <20080919150406.GA28574@nic.fr> On Fri, Sep 19, 2008 at 03:20:58PM +0100, Natassa Gioti wrote a message of 23 lines which said: > I have Python 2.5 version on a MacOSX, I do not know MacOSX (I use only free software) but isn't there a packaging system with already-made Pyxml packages? http://py-xml.darwinports.com/ Compiling by yourself (if you are not a developer) is quite 20th century :-) > I previously had problems with other programs I tried to install, as > if no gcc compiler could be found, but do not know how to check that > indeed ~ % cat > test.c main () {} ~ % gcc test.c ~ % ./a.out From jwt at onjapan.net Fri Sep 19 23:57:10 2008 From: jwt at onjapan.net (Jim Tittsler) Date: Sat, 20 Sep 2008 09:57:10 +1200 Subject: [XML-SIG] Problem installing Pyxml In-Reply-To: <59305.128.40.80.40.1221834058.squirrel@www.squirrelmail.ucl.ac.uk> References: <59305.128.40.80.40.1221834058.squirrel@www.squirrelmail.ucl.ac.uk> Message-ID: <07B9A23E-B225-41FB-8240-40A633CD6A26@onjapan.net> On Sep 20, 2008, at 02:20, Natassa Gioti wrote: > error: command 'gcc' failed with exit status 1 > > I previously had problems with other programs I tried to install, > as if no > gcc compiler could be found, but do not know how to check that > indeed ( I > used alternative programs previously). gcc is included in the Apple developer toolset known as Xcode. Xcode is available as a free download from http://developer.apple.com/ -- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/crew/jwt/ Mailman IRC irc://irc.freenode.net/#mailman From darren at dvhart.com Sun Sep 21 20:57:41 2008 From: darren at dvhart.com (Darren Hart) Date: Sun, 21 Sep 2008 11:57:41 -0700 Subject: [XML-SIG] Choosing an XML method for a backing store Message-ID: I'm writing a simple application that has a tree-like data structure. I'd like to be able to eventually easily synchronize this data from one client to another. With that in mind, I have a few questions regarding how I should best store my data and whether DOM or SAX is a more appropriate choice. I am new to XML and am trying to make sure I'm headed in the right direction before I make any pervasive changes to my application. If I'm barking up the wrong tree, can someone point me in the right direction? Example data structure list of type A type A data type A data tree of types B,C,D,E type B data list of type C type C data type B ref list of type D type D data type C ref list of type E data type D ref list of type A ref type A ref type A ref Thoughts/Questions: 1) The structure seems to lend itself well to DOM 2) Using DOM seems to mean one single file, which makes synchonization harder and more error prone, lots of individual files seem like a better approach for that 3) Since I already have a data structure, it seems I'd end up building the DOM, then constructing the data structure from the DOM, then writing the entire thing out on each save... seems to invalidate some of the benefits of a DOM (easy reorganization of nodes for example). 4) Is it common practice to subclass the DOM objects into something my application can use explicitly, thus avoiding the need to convert from the DOM to the structure outlined above? My objects currently use signals to communication with the GUI and other objects. 5) Is there a common practice for dealing with the references in my data structure? For example, when parsing the XML file(s) with SAX it is possible I'll come across a reference to an object that hasn't yet been created and is defined elsewhere in the file (or another file). My thought was to store a unique ID for each object, and use object reference elements in the xml with the unique as CTEXT, if this is encountered and the object hasn't been constructed, a proxy object would be built and converted to a complete object when the xml data for it was encountered. Thanks for the time, -- Darren Hart From laura3d at inmail.hu Tue Sep 23 02:11:09 2008 From: laura3d at inmail.hu (LAURA edzo) Date: Tue, 23 Sep 2008 02:11:09 +0200 Subject: [XML-SIG] Engedely keres Message-ID: <48D73FF20000B00E@gsp03-c07d3.vodafone.hu> (added by postmaster@gsp03-c07d3.vodafone.hu) Tisztelt Xml Sig ! Engedje meg, hogy bemutassak egy fantasztikus lehet?s?get, melyben ?n egy 3 dimenzi?s szem?lyiedz?t haszn?lhat korl?tlanul (aki a helyes t?pl?lkoz?s, eg?szs?g ?s vitalit?s meg?rz?s?ben segit), s ez?rt nem kell p?nzt fizetnie. Csak egy regisztr?ci? ?s m?r indulhatunk is! Amennyiben b?vebb inform?ci?t k?ldhet?nk ?nnek, k?rem, v?laszoljon erre az eng?lyt k?r? lev?lre, ?s dijtalanul t?j?koztatjuk. Ha b?vebb inform?ci?ra lenne sz?ks?ge, hivjon a (nem emeltdijas) telefonsz?mon. K?sz?nettel: Berta Sz?fia 06-70-2808170 www.webstar3dinfo.com/lauraa Amennyiben zavartam a(z) xml-sig at python.org ?rkezett levelemmel, k?rem, jelezze!