From noreply at sourceforge.net Thu Dec 1 03:03:54 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed, 30 Nov 2005 18:03:54 -0800 Subject: [XML-SIG] [ pyxml-Bugs-1370537 ] PrettyPrinter uses single quotes Message-ID: Bugs item #1370537, was opened at 2005-12-01 02:03 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=106473&aid=1370537&group_id=6473 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: DOM Group: None Status: Open Resolution: None Priority: 5 Submitted By: Dobes V (dobesv) Assigned to: Nobody/Anonymous (nobody) Summary: PrettyPrinter uses single quotes Initial Comment: The pretty printer emits single quotes areound attributes by default. Unfortunately, single quotes aren't supported by all XML parsers - really I'm not sure they are part of the XML standard (?!?!?). In any case, I wanted to pretty-print some XML but the result was unparsable. Hopefully the use of single-quotes will be removed, or made optional, in the next version. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=106473&aid=1370537&group_id=6473 From tony.mcdonald at ncl.ac.uk Thu Dec 1 09:45:43 2005 From: tony.mcdonald at ncl.ac.uk (Tony McDonald) Date: Thu, 1 Dec 2005 08:45:43 +0000 Subject: [XML-SIG] How do I replace multiple elements in a document?(using ElementTree) In-Reply-To: References: <6D5F2A11-8201-4ED2-9208-C22D5D08239C@ncl.ac.uk> <436A9F11-3108-4464-AFCB-E5EC12957258@ncl.ac.uk> Message-ID: <3A68563C-CC1D-41D0-B2B7-93CD3B2F8331@ncl.ac.uk> On 30 Nov 2005, at 16:27, Fredrik Lundh wrote: > Tony McDonald wrote: > >> I did have this, >> >> from elementtree.ElementTree import XML, ElementTree, Element, >> SubElement, dump >> >> and went to this; >> >> from cElementTree import XML, ElementTree, Element, SubElement, dump >> >> Which imports fine, but there's something amiss because; >> root = ElementTree(file=filename) >> ... >> elements = root.getiterator() >> print "LEN", len(elements) >> >> which gave 634 elements using python ElementTree but gives len() of >> unsized object when using the eElementTree version, and there does >> seem to be something amiss ... > > the getiterator method is defined to return "something that you can > iterate over", which is not necessarily a sequence object. > > in ElementTree, it happens to be a list (at least in the 1.2 > series), but > cElementTree returns a generator instead. > > no matter what version you're using, this > > for elem in root.getiterator(): > ... > > is guaranteed to work. and indeed it does. Rapidly! > if you want a list, you can always use the list > constructor. e.g. > > print "LEN", len(list(root.getiterator())) > > > Many thanks Fredrik, this thread has helped me out no end! cheers Tone -- Dr Tony McDonald, Asst Director, FMSC. 0191 246 4543 School of Medical Education Development Project Manager, FDTL-4 ePortfolios http://www.eportfolios.ac.uk/ From meonimarco at gmail.com Thu Dec 1 11:07:40 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Thu, 1 Dec 2005 11:07:40 +0100 Subject: [XML-SIG] Build a dinamic GUI from a DTD file In-Reply-To: <438C31D5.9060108@gmail.com> References: <438C31D5.9060108@gmail.com> Message-ID: <7d14f3a90512010207v1159aa66o@mail.gmail.com> No ideas or examples for managing dtd & xml in python? 2005/11/29, Marco Meoni : > > Hi, i'm new in python programming and i'm new in this mailing list. > I have a problem in buildin a GUI with wxpython. My application have to > start by GUI. This GUI have to be dinamic. The commands that the GUI have to > show are described in a DTD. The GUI must read the DTD file and show the > command that is in DTD file (in every start of the program). > How can I do this? > Is there any simple py files that you can send me for examples in managing > DTD or XML with Python? > Sorry for my bad english but i'm an italian boy... > Thanks to all! > Marco. > -- > mail address: meonimarco at gmail.com web site: www.marcomeoni.net > -- Mail address: meonimarco at gmail.com Web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051201/8cf62638/attachment.html From fredrik at pythonware.com Thu Dec 1 11:42:06 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 1 Dec 2005 11:42:06 +0100 Subject: [XML-SIG] Build a dinamic GUI from a DTD file References: <438C31D5.9060108@gmail.com> <7d14f3a90512010207v1159aa66o@mail.gmail.com> Message-ID: Marco Meoni wrote: > No ideas or examples for managing dtd & xml in python? sure, but the scope of your original post was probably too large for anyone to deal with... anyway, if you want an XML parser that gives you full access to the DTD, this might be your best choice: http://www.garshol.priv.no/download/software/xmlproc/ if you meant plain XML and not DTD (I'm not sure how the DTD can contain command descriptions...), there are dozens of alternatives. you can find links to most of them in this article: http://www.xml.com/pub/a/2004/10/13/py-xml.html (also see the comment section) 2005/11/29, Marco Meoni : > > Hi, i'm new in python programming and i'm new in this mailing list. > I have a problem in buildin a GUI with wxpython. My application have to > start by GUI. This GUI have to be dinamic. The commands that the GUI have to > show are described in a DTD. The GUI must read the DTD file and show the > command that is in DTD file (in every start of the program). > How can I do this? > Is there any simple py files that you can send me for examples in managing > DTD or XML with Python? > Sorry for my bad english but i'm an italian boy... > Thanks to all! > Marco. > -- > mail address: meonimarco at gmail.com web site: www.marcomeoni.net > -- Mail address: meonimarco at gmail.com Web site: www.marcomeoni.net -------------------------------------------------------------------------------- > _______________________________________________ > XML-SIG maillist - XML-SIG at python.org > http://mail.python.org/mailman/listinfo/xml-sig > From meonimarco at gmail.com Thu Dec 1 12:35:56 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Thu, 1 Dec 2005 12:35:56 +0100 Subject: [XML-SIG] Build a dinamic GUI from a DTD file In-Reply-To: References: <438C31D5.9060108@gmail.com> <7d14f3a90512010207v1159aa66o@mail.gmail.com> Message-ID: <7d14f3a90512010335u73394a19k@mail.gmail.com> Very thanks for your answer... I'll try with xml-proc but if anyone have examples are welcome!!! 2005/12/1, Fredrik Lundh : > > Marco Meoni wrote: > > > No ideas or examples for managing dtd & xml in python? > > sure, but the scope of your original post was probably too large for > anyone > to deal with... > > anyway, if you want an XML parser that gives you full access to the DTD, > this might be your best choice: > > http://www.garshol.priv.no/download/software/xmlproc/ > > if you meant plain XML and not DTD (I'm not sure how the DTD can contain > command descriptions...), there are dozens of alternatives. you can find > links > to most of them in this article: > > http://www.xml.com/pub/a/2004/10/13/py-xml.html > (also see the comment section) > > > > 2005/11/29, Marco Meoni : > > > > Hi, i'm new in python programming and i'm new in this mailing list. > > I have a problem in buildin a GUI with wxpython. My application have to > > start by GUI. This GUI have to be dinamic. The commands that the GUI > have to > > show are described in a DTD. The GUI must read the DTD file and show the > > command that is in DTD file (in every start of the program). > > How can I do this? > > Is there any simple py files that you can send me for examples in > managing > > DTD or XML with Python? > > Sorry for my bad english but i'm an italian boy... > > Thanks to all! > > Marco. > > -- > > mail address: meonimarco at gmail.com web site: www.marcomeoni.net > > > > > > -- > Mail address: meonimarco at gmail.com > Web site: www.marcomeoni.net > > > > > -------------------------------------------------------------------------------- > > > > _______________________________________________ > > XML-SIG maillist - XML-SIG at python.org > > http://mail.python.org/mailman/listinfo/xml-sig > > > > > > _______________________________________________ > XML-SIG maillist - XML-SIG at python.org > http://mail.python.org/mailman/listinfo/xml-sig > -- Mail address: meonimarco at gmail.com Web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051201/8b73537a/attachment.html From ppetkov at gnucitizen.org Thu Dec 1 15:23:05 2005 From: ppetkov at gnucitizen.org (Petko Petkov) Date: Thu, 01 Dec 2005 14:23:05 +0000 Subject: [XML-SIG] XT (XML Toolkit) Message-ID: <438F0749.4090904@gnucitizen.org> Guys I've been working in the past few weeks on a project that was previously called Hackers XML Toolkit. Well, after the official release I liked it so much that I changed the name to XML Toolkit. You can download the code from http://www.gnucitizen.org http://www.gnucitizen.org/data/download/xt-0.7.BETA.py Check it out and tell me what you think. BTW, there is a simple demo of the stuff you can do with XT. My module is not as powerful was SAX or DOM but has some neat functionalities that may simplify your work a bit. # DEMO import xt element = xt.Element().loadstring(''' XT ''') element = xt.Element().loadfile('xml.xml') element[0] for e in element: print e.namespace e['document'] e['{urn:namespace}document'].name = 'the_document' e['definitions']['service'].attributes['name'] element.sort() element.append(Element('another_one')) Well, you can use it in many other ways. :) Thanks. From hanwen at xs4all.nl Fri Dec 2 12:43:15 2005 From: hanwen at xs4all.nl (Han-Wen Nienhuys) Date: Fri, 02 Dec 2005 12:43:15 +0100 Subject: [XML-SIG] automatically building Python data structures from DOM trees? Message-ID: Hi, I'm looking for a package that will translate a minidom tree into something which is native python, i.e. translate into a python object, for which the following holds bar.bla[1].id == "2" Of course, I would have to supply a mapping from names like "bar" and "bla" to my own classes (probably deriving from xml.node). Does such a thing exist? -- Han-Wen Nienhuys - hanwen at xs4all.nl - http://www.xs4all.nl/~hanwen From ppetkov at gnucitizen.org Fri Dec 2 13:57:50 2005 From: ppetkov at gnucitizen.org (Petko Petkov) Date: Fri, 02 Dec 2005 12:57:50 +0000 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: References: Message-ID: <439044CE.7000506@gnucitizen.org> Well, why don't you try my XML Toolkit http://www.gnucitizen.org/data/download/xt-0.7.BETA.py This is what to do import xt element = xt.Element().loadstring(''' ''') element = xt.Element().loadfile('myfile.xml') for e in element: print e.name print e.namespace print element print element['bla'].findall('foo') print element['bla']['foo'].attributes['id'].namesace element['bla']['foo'].attributes['id'] = 'This is a new id' for e in element['bla'].findall('foo'): print e.attributes['id'].value element['bla'].append(Element().loadstring('Another bla')) element['bla'].append(Element('foo')) Cheers Han-Wen Nienhuys wrote: > Hi, > > I'm looking for a package that will translate a minidom tree into > something which is native python, i.e. translate > > > > > > > > > into a python object, for which the following holds > > bar.bla[1].id == "2" > > > Of course, I would have to supply a mapping from names like "bar" and > "bla" to my own classes (probably deriving from xml.node). > > Does such a thing exist? > > > > From fredrik at pythonware.com Fri Dec 2 13:58:34 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 2 Dec 2005 13:58:34 +0100 Subject: [XML-SIG] automatically building Python data structures from DOMtrees? References: Message-ID: Han-Wen Nienhuys wrote: > I'm looking for a package that will translate a minidom tree into > something which is native python, i.e. translate > > > > > > > > > into a python object, for which the following holds > > bar.bla[1].id == "2" > > > Of course, I would have to supply a mapping from names like "bar" and > "bla" to my own classes (probably deriving from xml.node). > > Does such a thing exist? does it has to be a minidom tree? if not, you can find plenty of alternatives under the "data bindings" section in this article: http://www.xml.com/pub/a/2004/10/13/py-xml.html From morillas at unizar.es Fri Dec 2 14:07:16 2005 From: morillas at unizar.es (Luis Miguel Morillas) Date: Fri, 02 Dec 2005 14:07:16 +0100 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: References: Message-ID: <1133528836.43904704b33a1@webmail.unizar.es> Mensaje citado por Han-Wen Nienhuys : > > Hi, > > I'm looking for a package that will translate a minidom tree into > something which is native python, i.e. translate > > > > > > > > > into a python object, for which the following holds > > bar.bla[1].id == "2" > > > Of course, I would have to supply a mapping from names like "bar" and > "bla" to my own classes (probably deriving from xml.node). > > Does such a thing exist? > > Yes, Try Amara (http://uche.ogbuji.net/tech/4suite/amara/) What do you mean "bleh" But I was looking for argument Becomes a data structure such that you can write: binding.monty.python.spam In order to get the value "eggs" or binding.monty.python[1] -- Luis Miguel From guido at python.org Fri Dec 2 16:43:59 2005 From: guido at python.org (Guido van Rossum) Date: Fri, 2 Dec 2005 07:43:59 -0800 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: References: Message-ID: On 12/2/05, Han-Wen Nienhuys wrote: > I'm looking for a package that will translate a minidom tree into > something which is native python, i.e. translate > > > > > > > > > into a python object, for which the following holds > > bar.bla[1].id == "2" I wrote something like this except it just parses XML -- it doesn't go through (mini)DOM. It also *produces* XML from the Python data structures at request. It's not yet integrated anywhere but you can get it from SourceForge: python.org/sf/1337648. I've been looking for feedback on this package -- let me know if it's useful for you! -- --Guido van Rossum (home page: http://www.python.org/~guido/) From Uche.Ogbuji at fourthought.com Fri Dec 2 18:52:35 2005 From: Uche.Ogbuji at fourthought.com (Uche Ogbuji) Date: Fri, 02 Dec 2005 10:52:35 -0700 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: <1133528836.43904704b33a1@webmail.unizar.es> References: <1133528836.43904704b33a1@webmail.unizar.es> Message-ID: <1133545955.15399.135.camel@borgia> On Fri, 2005-12-02 at 14:07 +0100, Luis Miguel Morillas wrote: > Mensaje citado por Han-Wen Nienhuys : > > I'm looking for a package that will translate a minidom tree into > > something which is native python, i.e. translate > > > > > > > > > > > > > > > > > > into a python object, for which the following holds > > > > bar.bla[1].id == "2" > > > > > > Of course, I would have to supply a mapping from names like "bar" and > > "bla" to my own classes (probably deriving from xml.node). > > > > Does such a thing exist? > > > > > > Yes, Try Amara (http://uche.ogbuji.net/tech/4suite/amara/) > > > What do you mean "bleh" > But I was looking for argument > > > Becomes a data structure such that you can write: > > binding.monty.python.spam > > In order to get the value "eggs" or > > binding.monty.python[1] Thanks, Luis. Yep, and 'bar.bla[1].id == "2"' would work out of the box with Amara. One question, Han-Wen, do you have to use minidom as the source, or can you go from straight XML? Just seems unnecessary to parse to minidom and then bind. -- 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/ From hanwen at xs4all.nl Sat Dec 3 00:42:37 2005 From: hanwen at xs4all.nl (Han-Wen Nienhuys) Date: Sat, 03 Dec 2005 00:42:37 +0100 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: <1133545955.15399.135.camel@borgia> References: <1133528836.43904704b33a1@webmail.unizar.es> <1133545955.15399.135.camel@borgia> Message-ID: <4390DBED.3010805@xs4all.nl> Uche Ogbuji wrote: > Thanks, Luis. > > Yep, and 'bar.bla[1].id == "2"' would work out of the box with Amara. > > One question, Han-Wen, do you have to use minidom as the source, or can > you go from straight XML? Just seems unnecessary to parse to minidom > and then bind. No, but I'd like to have the source as a complete, in-memory tree. I thought that DOM was just a word for such a tree. I'm a complete XML newbie. For the moment, I have concocted something simple with new.classobj() - if I need anything more complex, I suppose that I'll have a look at Amara. -- Han-Wen Nienhuys - hanwen at xs4all.nl - http://www.xs4all.nl/~hanwen From hanwen at xs4all.nl Sat Dec 3 00:44:22 2005 From: hanwen at xs4all.nl (Han-Wen Nienhuys) Date: Sat, 03 Dec 2005 00:44:22 +0100 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: References: Message-ID: <4390DC56.1070305@xs4all.nl> Guido van Rossum wrote: > > I wrote something like this except it just parses XML -- it doesn't go > through (mini)DOM. It also *produces* XML from the Python data > structures at request. > > It's not yet integrated anywhere but you can get it from SourceForge: > python.org/sf/1337648. > > I've been looking for feedback on this package -- let me know if it's > useful for you! > From the comments, I gather that it doesn't preserve the ordering of elements in the XML file. That would make it useless for me. -- Han-Wen Nienhuys - hanwen at xs4all.nl - http://www.xs4all.nl/~hanwen From hanwen at xs4all.nl Sat Dec 3 00:44:22 2005 From: hanwen at xs4all.nl (Han-Wen Nienhuys) Date: Sat, 03 Dec 2005 00:44:22 +0100 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: References: Message-ID: <4390DC56.1070305@xs4all.nl> Guido van Rossum wrote: > > I wrote something like this except it just parses XML -- it doesn't go > through (mini)DOM. It also *produces* XML from the Python data > structures at request. > > It's not yet integrated anywhere but you can get it from SourceForge: > python.org/sf/1337648. > > I've been looking for feedback on this package -- let me know if it's > useful for you! > From the comments, I gather that it doesn't preserve the ordering of elements in the XML file. That would make it useless for me. -- Han-Wen Nienhuys - hanwen at xs4all.nl - http://www.xs4all.nl/~hanwen From hanwen at xs4all.nl Sat Dec 3 00:42:37 2005 From: hanwen at xs4all.nl (Han-Wen Nienhuys) Date: Sat, 03 Dec 2005 00:42:37 +0100 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: <1133545955.15399.135.camel@borgia> References: <1133528836.43904704b33a1@webmail.unizar.es> <1133545955.15399.135.camel@borgia> Message-ID: <4390DBED.3010805@xs4all.nl> Uche Ogbuji wrote: > Thanks, Luis. > > Yep, and 'bar.bla[1].id == "2"' would work out of the box with Amara. > > One question, Han-Wen, do you have to use minidom as the source, or can > you go from straight XML? Just seems unnecessary to parse to minidom > and then bind. No, but I'd like to have the source as a complete, in-memory tree. I thought that DOM was just a word for such a tree. I'm a complete XML newbie. For the moment, I have concocted something simple with new.classobj() - if I need anything more complex, I suppose that I'll have a look at Amara. -- Han-Wen Nienhuys - hanwen at xs4all.nl - http://www.xs4all.nl/~hanwen From guido at python.org Sat Dec 3 01:09:53 2005 From: guido at python.org (Guido van Rossum) Date: Fri, 2 Dec 2005 16:09:53 -0800 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: <4390DC56.1070305@xs4all.nl> References: <4390DC56.1070305@xs4all.nl> Message-ID: On 12/2/05, Han-Wen Nienhuys wrote: > Guido van Rossum wrote: > > > > I wrote something like this except it just parses XML -- it doesn't go > > through (mini)DOM. It also *produces* XML from the Python data > > structures at request. > > > > It's not yet integrated anywhere but you can get it from SourceForge: > > python.org/sf/1337648. > > > > I've been looking for feedback on this package -- let me know if it's > > useful for you! > > > > From the comments, I gather that it doesn't preserve the ordering of > elements in the XML file. That would make it useless for me. It preserves the relative order of subelements of the *same* type (which are stored in a list, to match your example), but indeed it currently doesn't preserve the order of subelements of different types. I'll note that as a feature request. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From uche.ogbuji at fourthought.com Sat Dec 3 01:24:04 2005 From: uche.ogbuji at fourthought.com (Uche Ogbuji) Date: Fri, 02 Dec 2005 17:24:04 -0700 Subject: [XML-SIG] automatically building Python data structures from DOM trees? In-Reply-To: <4390DBED.3010805@xs4all.nl> References: <1133528836.43904704b33a1@webmail.unizar.es> <1133545955.15399.135.camel@borgia> <4390DBED.3010805@xs4all.nl> Message-ID: <1133569444.15399.262.camel@borgia> On Sat, 2005-12-03 at 00:42 +0100, Han-Wen Nienhuys wrote: > Uche Ogbuji wrote: > > Thanks, Luis. > > > > Yep, and 'bar.bla[1].id == "2"' would work out of the box with Amara. > > > > One question, Han-Wen, do you have to use minidom as the source, or can > > you go from straight XML? Just seems unnecessary to parse to minidom > > and then bind. > > No, but I'd like to have the source as a complete, in-memory tree. I > thought that DOM was just a word for such a tree. I'm a complete XML > newbie. Some people use the term that way. I wouldn't. There's a W3C standard called DOM, which is a tree. It's also very suboptimal for Python. Minidom is based on DOM but tries to make some concessions to Python's simpler world view. Many will tell you it's still way too Java-esque. There are other tree models for XML that have nothing to do with DOM, including Amara and ElementTree. > For the moment, I have concocted something simple with new.classobj() - > if I need anything more complex, I suppose that I'll have a look at Amara. -- 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/ From gandalf at designaproduct.biz Tue Dec 6 01:49:33 2005 From: gandalf at designaproduct.biz (Laszlo Zsolt Nagy) Date: Tue, 06 Dec 2005 01:49:33 +0100 Subject: [XML-SIG] Possible SOAP/ZSI bug? Message-ID: <4394E01D.7070504@designaproduct.biz> Hello, I'm new to SOAP and pyXML. I tried to use the ZSI. Not sure about SOAPpy - is it better for me? Here is my test program: import ZSI fname = 'eBaySvc.wsdl' version = 421 url = 'http://developer.ebay.com/webservices/%s/%s' % (version,fname) print "Creating proxy..." proxy = ZSI.ServiceProxy(url) print proxy Results in an exception: Traceback (most recent call last): File "T:/Python/Projects/eBay-SOAP/test.py", line 6, in ? proxy = ZSI.ServiceProxy(url) File "C:\Python24\Lib\site-packages\ZSI\ServiceProxy.py", line 34, in __init__ wsdl = ZSI.wstools.WSDLTools.WSDLReader().loadFromURL(wsdl) File "C:\Python24\Lib\site-packages\ZSI\wstools\WSDLTools.py", line 42, in loadFromURL wsdl.load(document) File "C:\Python24\Lib\site-packages\ZSI\wstools\WSDLTools.py", line 260, in load schema = reader.loadFromNode(WSDLToolsAdapter(self), item) File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line 80, in loadFromNode schema.load(reader) File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line 1116, in load tp.fromDom(node) File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line 2271, in fromDom self.content.fromDom(contents[indx]) File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line 2328, in fromDom self.derivation.fromDom(i) File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line 2388, in fromDom component = SplitQName(contents[indx].getTagName())[1] IndexError: list index out of range Thanks, Laszlo From gandalf at designaproduct.biz Tue Dec 6 02:27:42 2005 From: gandalf at designaproduct.biz (Laszlo Zsolt Nagy) Date: Tue, 06 Dec 2005 02:27:42 +0100 Subject: [XML-SIG] Possible SOAP/ZSI bug? In-Reply-To: <4394E01D.7070504@designaproduct.biz> References: <4394E01D.7070504@designaproduct.biz> Message-ID: <4394E90E.60808@designaproduct.biz> Laszlo Zsolt Nagy wrote: > Hello, > >I'm new to SOAP and pyXML. I tried to use the ZSI. Not sure about SOAPpy >- is it better for me? > > Now I also tried SOAPpy but it throws the same exception in XMLSchema.py (which belongs to wstools - the same code base for SOAPpy and ZSI). This is what the web service provider states on its home page: "If you choose to also try a different SOAP client, please be sure it supports document-style messaging (as we do not use RPC-style messaging). Also, the SOAP API only supports the UTF-8 encoding scheme." Sorry for the dumb question, but what is "document-style messaging"? This web service provider tells me that the supported platforms are Visual Studio .NET and Apache Axis. I have FreeBSD 4.8 which I must use, but AFAIK Java does not run on it. :-( I would like to use Python. Laszlo From gandalf at designaproduct.biz Tue Dec 6 02:59:35 2005 From: gandalf at designaproduct.biz (Laszlo Zsolt Nagy) Date: Tue, 06 Dec 2005 02:59:35 +0100 Subject: [XML-SIG] Possible SOAP/ZSI bug? In-Reply-To: References: Message-ID: <4394F087.3090303@designaproduct.biz> Olivier Collioud wrote: >I don't want to go in the detail but for interopability between all >platform you need this kind of WS: >Style=document >Use=literal > >This is what should define your WSDL file. > > I have similar things in the WDSL: So do you think it will work with SOAPpy or ZSI? The web service provider said "You are free to use other SOAP client environments, but the tool you use must support document/literal style SOAP messages." But I'm not sure if ZSI or SOAPpy supports this or not. Thanks, Laszlo From gandalf at designaproduct.biz Tue Dec 6 03:58:10 2005 From: gandalf at designaproduct.biz (Laszlo Zsolt Nagy) Date: Tue, 06 Dec 2005 03:58:10 +0100 Subject: [XML-SIG] Possible SOAP/ZSI bug? In-Reply-To: References: Message-ID: <4394FE42.8000908@designaproduct.biz> Olivier Collioud wrote: >I don't want to go in the detail but for interopability between all >platform you need this kind of WS: >Style=document >Use=literal > > I'm trying to create python source code for a wsdl. According to the ZSI documentation, there is a 'wsdl2py' program that can create python interfaces for a given wsdl. But there is no such program in the distribution. http://pywebsvcs.sourceforge.net/zsi.html#SECTION0012300000000000000000 For this reason, I tried to use the WriteServiceModule function: import ZSI import ZSI.wsdl2python from ZSI.wstools import WSDLTools fname = 'eBaySvc.wsdl' reader = WSDLTools.WSDLReader() wsdl = reader.loadFromFile(fname) print wsdl wsm = ZSI.wsdl2python.WriteServiceModule(wsdl) wsm.write() Result: C:/Python24/pythonw.exe -u "T:/Python/Projects/eBay-SOAP/create_interfaces.py" Traceback (most recent call last): File "T:/Python/Projects/eBay-SOAP/create_interfaces.py", line 28, in ? wsm.write() File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 213, in write esuffix=esuffix) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 264, in write_service_types esuffix=esuffix) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 367, in write_dependent_schema sd.fromWsdl(schema, alternateWriter) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1092, in fromWsdl self.generate(schema.getTypesDict(), alternateWriter) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1121, in generate tw.fromType(tp, ref) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1241, in fromType self._fromComplexType(tp) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1459, in _fromComplexType typecodelist += self._complexTypeAllOrSequence(tp, mg) File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1672, in _complexTypeAllOrSequence if e.getType(): File "C:\Python24\Lib\site-packages\ZSI\wsdlInterface.py", line 1800, in getType typ = self._dec.getTypeDefinition('type') File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line 1926, in getTypeDefinition raise Warning, 'invalid operation for <%s>' %self.tag Warning: invalid operation for It is only a warning but it terminates the operation. What am I doing wrong? Sorry for the bunch of questions. This is the first time I use SOAP. Laszlo From kroberts at abletronics.com Thu Dec 8 01:33:37 2005 From: kroberts at abletronics.com (Ken Roberts) Date: Wed, 07 Dec 2005 16:33:37 -0800 Subject: [XML-SIG] declaration missing in PrettyPrint() Message-ID: <43977F61.7040808@abletronics.com> I've seen something related to this in the archives, and it didn't look good. I'm writing a python script to convert a report to XML to import into another program. The problem is that the import function of the other program requires a declaration: === EXMAPLE === === I've created a script using: ==== SCRIPT ==== import sys from xml.dom import ext from xml.dom.ext.reader import Sax2 reader=Sax2.Reader() doc=reader.fromString(""" """) (create nodes) ext.PrettyPrint(doc) ==== Unfortunately, it does not output the line: === EXMAPLE === === Any suggestions? -- - Ken Roberts Registered Linux user #296561 Slackin' since 1993 http://www.slackware.com From ppetkov at gnucitizen.org Thu Dec 8 11:37:10 2005 From: ppetkov at gnucitizen.org (Petko Petkov) Date: Thu, 08 Dec 2005 10:37:10 +0000 Subject: [XML-SIG] XMLToolkit 0,7,BETA.2 Message-ID: <43980CD6.9070105@gnucitizen.org> Hello to everybody, This is XMLToolkit 0,7,BETA.2. I simplified most of the code. There are a few new features added as well. Now you can use the Binding tool to Bind XML documents to python objects. doc = Binding.fromfile('GoogleService.wsdl') doc.definitions.message doc.definitions.message[0] doc.definitions.message[1] doc.definitions.message.name doc.definitions.message.name = 'bla bla' doc.definitions.message = '

Hei I can assign XML to elements that will be parsed on the fly.

Good!' doc.definitions.message[1] = OtherBinding doc.definitions.message[2] = OtherElement doc.definitions.message[0] = doc.definitions.message[2] for m in doc.definitions.message: print m print m.name doc.xml doc.xml(encoding = 'utf-8') doc.xml(encoding = 'utf-8', stream = mystream) doc.xml(encoding = 'utf-8', file = 'myGoogle.wsdl') str(doc.xml) doc.xml.composestream(stream) As you can see the syntax is similar to Amara XMLToolkit. I am still stuck with PEXComposer. If anyone is willing to help me out with simplifying the code and writing proper Composer to assemble PEX Objects back to XML, feel free to let me know. It shouldn't take that long. I need your help more than ever. I believe that XT (XML Toolkit) is coming nicely and I want to complete it as soon as possible because I want to move forward and start doing something else. :) So, can you have a look on the code and suggest any corrections or recommendations? Or even help me out rewriting some of it. I believe that the current design is not bad at all, however, somebody may suggest a different approach to solve a problem. Thanks. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: xt.py Url: http://mail.python.org/pipermail/xml-sig/attachments/20051208/18b6d3c6/xt.pot From meonimarco at gmail.com Fri Dec 9 14:24:25 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Fri, 09 Dec 2005 14:24:25 +0100 Subject: [XML-SIG] Create XML string with python Message-ID: <43998589.4080507@gmail.com> Hi. I have to create a XML string from a GUI. In the GUI i have some "bottons". Clicking on this bottons the program should create a XML string (a STRING, the XML must be into a STRING ;-) ) If you have an idea or a .py please send me... I must include this function in a program soon and have a little bit of time!!! Thanks to all and sorry for my "italian" english... Bye -- mail address: meonimarco at gmail.com web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051209/291120aa/attachment.html From meonimarco at gmail.com Fri Dec 9 18:09:27 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Fri, 09 Dec 2005 18:09:27 +0100 Subject: [XML-SIG] Create XML string with python Message-ID: <4399BA47.3080602@gmail.com> Hi. I have to create a XML string from a GUI. In the GUI i have some "bottons". Clicking on this bottons the program should create a XML in a string (a STRING, the XML must be into a Python STRING ;-) ) If you have an idea or a .py please send me... All is welcome, you can send me example, ideas, the solution or what you want!! I must include this function in a program soon and have a little bit of time!!! Thanks to all and sorry for my "italian" english... Bye P.S. These are the detail of my project: I have to create a distribuited application to manage a wireless network. In the manager program there is a GUI in wxPython that has many commands to send to the agents. To send the command to the agent (that is in C++ language) the manager use XML in Python string. The agent uses the commands parsing the string but this is not a problem. -- mail address: meonimarco at gmail.com web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051209/8dabccb2/attachment.htm From noreply at sourceforge.net Sun Dec 11 07:37:28 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Sat, 10 Dec 2005 22:37:28 -0800 Subject: [XML-SIG] [ pyxml-Patches-1378015 ] html style element may contain text Message-ID: Patches item #1378015, was opened at 2005-12-11 06:37 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=306473&aid=1378015&group_id=6473 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Tom (thecap) Assigned to: Nobody/Anonymous (nobody) Summary: html style element may contain text Initial Comment: Currently given the input the output of xml.dom.ext.Print is * { font-family: Arial, Helvetica, sans-serif; font-size: small; } The fix is the same as that shown at http://cvs.sourceforge.net/viewcvs.py/pyxml/xml/xml/dom/html/__init__.py?r1=1.10&r2=1.11 # diff /usr/lib/python2.4/site-packages/_xmlplus/dom/html/__init__.py.orig /usr/lib/python2.4/site-packages/_xmlplus/dom/html/__init__.py 373c373 < 'style': [], --- > 'style': ['CDATA'], See also http://www.w3.org/TR/REC-html40/present/styles.html#edef-STYLE ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=306473&aid=1378015&group_id=6473 From ppetkov at gnucitizen.org Mon Dec 12 10:28:57 2005 From: ppetkov at gnucitizen.org (Petko Petkov) Date: Mon, 12 Dec 2005 09:28:57 +0000 Subject: [XML-SIG] XMLToolkit 0,7,BETA.2 In-Reply-To: <1134157807.15399.884.camel@borgia> References: <43980CD6.9070105@gnucitizen.org> <1134157807.15399.884.camel@borgia> Message-ID: <439D42D9.4030402@gnucitizen.org> Thanks for the advice. It is a good one. I am currently finishing up the library. For all of you who really cant get why I am wasting my time codding another XML library.... Well, I am security guy and I need small library that does the main things. I hope you can use XT in a similar way. The official 0.7 version will be out soon. Thanks for the advice again. Uche Ogbuji wrote: > On Thu, 2005-12-08 at 10:37 +0000, Petko Petkov wrote: > >> Hello to everybody, >> This is XMLToolkit 0,7,BETA.2. I simplified most of the code. There are >> a few new features added as well. Now you can use the Binding tool to >> Bind XML documents to python objects. >> >> doc = Binding.fromfile('GoogleService.wsdl') >> doc.definitions.message >> doc.definitions.message[0] >> doc.definitions.message[1] >> doc.definitions.message.name >> doc.definitions.message.name = 'bla bla' >> doc.definitions.message = '

Hei I can assign XML to elements that >> will be parsed on the fly.

Good!' >> > > This is a neat feature, and similar to the append_xml_fragment() method > in Amara. I do wonder whether it should be the default, though. As an > example, in Amara the above would set text in that element and escape > the angle brackets. If you wanted to add child elements you'd have to > do: > > doc.definitions.message.append_xml_fragment('

Hei I can assign XML to > elements that will be parsed on the fly.

Good!') > > My worry with your approach is that if I want to use such characters in > my regular XML, I'd have to escape them. Rather than doing: > > doc.definitions.message = '100 < 1000' > > I'd have to do: > > doc.definitions.message = '100 < 1000' > > Which seems a bit odd at the content API level? > > > >> doc.definitions.message[1] = OtherBinding >> doc.definitions.message[2] = OtherElement >> doc.definitions.message[0] = doc.definitions.message[2] >> for m in doc.definitions.message: >> print m >> print m.name >> >> doc.xml >> doc.xml(encoding = 'utf-8') >> doc.xml(encoding = 'utf-8', stream = mystream) >> doc.xml(encoding = 'utf-8', file = 'myGoogle.wsdl') >> str(doc.xml) >> doc.xml.composestream(stream) >> >> As you can see the syntax is similar to Amara XMLToolkit. >> > > Yes. Nice. What does doc.xml.composestream(stream) do, though? > > I'm sorry that I don't have much time to peruse your code. > > > From fredrik at pythonware.com Mon Dec 12 14:13:49 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 12 Dec 2005 14:13:49 +0100 Subject: [XML-SIG] XMLToolkit 0,7,BETA.2 References: <43980CD6.9070105@gnucitizen.org> Message-ID: Petko Petkov wrote: > return cdatastring.lstrip('') this doesn't do what you think it does: >>> data = "" >>> data.lstrip('') '' >>> data = "TADA!" >>> data.lstrip('') '' >>> data = "" >>> data.lstrip('') 'hello /' From ppetkov at gnucitizen.org Mon Dec 12 14:32:18 2005 From: ppetkov at gnucitizen.org (Petko Petkov) Date: Mon, 12 Dec 2005 13:32:18 +0000 Subject: [XML-SIG] XMLToolkit 0,7,BETA.2 In-Reply-To: References: <43980CD6.9070105@gnucitizen.org> Message-ID: <439D7BE2.4010002@gnucitizen.org> Oh, yes :) You are right. I guess the best thing to do is: return cdatastring[9:-3] Right now I am rearranging all the parsing methods. Also, I am adding methods that can compose xml. Thanks. Fredrik Lundh wrote: > Petko Petkov wrote: > > >> return cdatastring.lstrip('') >> > > this doesn't do what you think it does: > > >>>> data = "" >>>> data.lstrip('') >>>> > '' > >>>> data = "TADA!" >>>> data.lstrip('') >>>> > '' > >>>> data = "" >>>> data.lstrip('') >>>> > 'hello /' > > > > > > _______________________________________________ > XML-SIG maillist - XML-SIG at python.org > http://mail.python.org/mailman/listinfo/xml-sig > From mcharest at sogetel.net Mon Dec 12 16:51:11 2005 From: mcharest at sogetel.net (Michel Charest) Date: Mon, 12 Dec 2005 10:51:11 -0500 Subject: [XML-SIG] Errors when using PrettyPrint Class (xml.dom.ext) and latin-1 characters (iso-8859-1) ... Message-ID: Hi, * I seem to be having a problem when using the PrettyPrint class (from PyXML's xml.dom.ext) to generate an XML document using latin-1 characters (specifically, french text accents)? PYTHON CODE USED: ================ # -*- coding: iso-8859-1 -*- # XML Generation example from xml.dom import implementation from xml.dom.ext import PrettyPrint import StringIO # Create an XML document: doc = implementation.createDocument(None, 'cases', None) root = doc.documentElement celem = doc.createElement('case') pelem = doc.createElement('problem') felem = doc.createElement('feature') felem.appendChild(doc.createTextNode( "?l?ve" )) # Method1 (see ERROR 1) #felem.appendChild(doc.createTextNode( unicode("?l?ve", 'latin-1') )) # Method2 (see ERROR 2) felem.setAttribute("fid", "1") pelem.appendChild(felem) celem.appendChild(pelem) root.appendChild(celem) root.setAttribute("date", "jan 01 2005") # Print generated XML document: xml_str = StringIO.StringIO() PrettyPrint(doc, xml_str) # failure point ? print xml_str.getvalue() ERROR 1 - OBTAINED FROM ONLY USING (-*- coding: iso-8859-1 -*- as a script header): ============================================================================ ====== ---------- Capture Output ---------- > "C:\Program Files\Python24\python.exe" genxml.py Traceback (most recent call last): File "genxml.py", line 26, in ? PrettyPrint(doc, xml_str) # failure point ? File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\__init__.py", line 81, in PrettyPrint Printer.PrintWalker(visitor, root).run() File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 385, in run return self.step() File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 381, in step self.visitor.visit(self.start_node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 185, in visit return self.visitDocument(node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 231, in visitDocument self.visitNodeList(node.childNodes, exclude=node.doctype) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 201, in visitNodeList curr is not exclude and self.visit(curr) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 161, in visit return self.visitElement(node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 270, in visitElement self.visitNodeList(node.childNodes) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 201, in visitNodeList curr is not exclude and self.visit(curr) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 161, in visit return self.visitElement(node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 270, in visitElement self.visitNodeList(node.childNodes) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 201, in visitNodeList curr is not exclude and self.visit(curr) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 161, in visit return self.visitElement(node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 270, in visitElement self.visitNodeList(node.childNodes) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 201, in visitNodeList curr is not exclude and self.visit(curr) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 161, in visit return self.visitElement(node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 270, in visitElement self.visitNodeList(node.childNodes) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 201, in visitNodeList curr is not exclude and self.visit(curr) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 167, in visit return self.visitText(node) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 293, in visitText text = TranslateCdata(text, self.encoding) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 118, in TranslateCdata new_string = charsetHandler(new_string, encoding) File "C:\Program Files\Python24\lib\site-packages\_xmlplus\dom\ext\Printer.py", line 44, in utf8_to_code text = unicode(text, "utf-8") UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2: invalid data > Terminated with exit code 1. ERROR 2 - WHEN EXPLICITLY ENCODING MY STRING AS UNICODE: ======================================================== ---------- Capture Output ---------- > "C:\Program Files\Python24\python.exe" genxml.py ??leve > Terminated with exit code 0. COMMENT: As can be seen, when using Method1 (default encoding with iso8859-1, I get a UnicodeDecodeError. And, when using Metho2, explicitely encoding using using unicode("?l?ve", 'latin-1'), the PrettyPrint class does not raise an exception, but it garbles (does not correctly interpret) my latin-1 string (i.e. ?l?ve). EXTRA DETAILS: ============== * Running on Windows XP (sp2) * Python 2.4.2 * PyXML 0.8.4 * 4Suite 1.0b1 * I have tried many other encoding formats such as utf8, utf-16, utf16-le, etc. with no luck ! Any comments or suggestions would be most appreciated. Regards, Michel From mike.williams at globalgraphics.com Mon Dec 12 18:27:23 2005 From: mike.williams at globalgraphics.com (Mike Williams) Date: Mon, 12 Dec 2005 17:27:23 +0000 Subject: [XML-SIG] Errors when using PrettyPrint Class (xml.dom.ext) and latin-1 characters (iso-8859-1) ... In-Reply-To: References: Message-ID: <439DB2FB.4080202@globalgraphics.com> Hi, Michel Charest did utter on 12/12/2005 15:51: > COMMENT: As can be seen, when using Method1 (default encoding with > iso8859-1, I get > a UnicodeDecodeError. And, when using Metho2, explicitely encoding using > using > unicode("?l?ve", 'latin-1'), the PrettyPrint class does not raise an > exception, but > it garbles (does not correctly interpret) my latin-1 string (i.e. ?l?ve). The xml.dom.ext PrettyPrint can only handle 7-bit ASCII or Unicode encoded text node strings. Method1 will fail as your latin1 encoded string contains 8-bit values which are not valid utf-8 encodings, as the error message reports. Method2 is in fact working - the output you see is the utf-8 encoding for your text node string. If you look at the output generated in a Unicode editor you should see your original string. > EXTRA DETAILS: > ============== > * Running on Windows XP (sp2) > * Python 2.4.2 > * PyXML 0.8.4 > * 4Suite 1.0b1 > * I have tried many other encoding formats such as utf8, utf-16, utf16-le, > etc. with no luck ! The xml.dom.ext PrettyPrint can only produce utf-8 output. There is a bug report and patch on sourceforge to let it produce utf-16 output. TTFN Mike -- I was just getting used to yesterday when today came. From ppetkov at gnucitizen.org Mon Dec 12 21:02:37 2005 From: ppetkov at gnucitizen.org (Petko Petkov) Date: Mon, 12 Dec 2005 20:02:37 +0000 Subject: [XML-SIG] XMLToolkit 0,7,BETA.3 Module parser.py (QA) In-Reply-To: References: <43980CD6.9070105@gnucitizen.org> Message-ID: <439DD75D.4050804@gnucitizen.org> I decided to split the library to smaller files because it is getting bigger than I initially expected. But this is fine because now you can use just specific parts of the code for specific purposes in your application. The package will include a standalone version of the library as well which will be out 1500 lines of code including the documentation. First of all I would like to know if this is a good idea? Now, I am interested in something very specific and I would like to hear your comments. The attached file contains the parsing part of my library. So far I like the Parser and ParserNS classes. However, I would like to add classes that are opposite to them (these classes should contain methods that are opposite to those found in Parser and ParserNS, more over they have to be called almost in the same way to reduce developers frustration when using the library). The classes that are opposite to Parser and ParserNS are called Composer and ComposerNS. The reason I would like to do this kind of separation is because if both Parser and Composer are written in certain way using certain conventions, less XML would be lost when converting from xml to object and vice versa. I am kind of stuck with the Composition again. The Composer must be almost identical in nature to ParserNS but opposite if you know what I mean. This is how the parser works. Parser.parsestring(string, handler) -> None | | V Parser.splitstring(string) -> generator | | V Parser.parsenodes(generator, handler) -> None | | V handler - events The Composer should do exactly the opposite of Parsing. Composer.composestring(....) -> string | | V handler - events | | V Composer.composenodes(...., handler) -> generator | | V .... Maybe I am confused and I am complicating the overall design too much. KEEP IT SIMPLE, yes this is my philosophy in live but it is much easyer to complicate things. OK, I would like to have a generic interface for Composing xml. The Parser usually outputs to events in handler. The Composer should start by inputing events into handler and somehow composing string, streams, files, etc. Unfortunately, the more I think the more I realize that it will be much better if I give up. :) But, I am not a quieter and I really need this kind of library anyway. I was thinking about the traditional way of processing XML files. In DOM we have the following stages: Parse -> DOM -> Serialize If we expand this stages with SAX it should look like the following: XML -> Parser -> SAXHandlerToDOM -> DOM -> Serialize -> XML As you can see this is oneway pipe. I thought that my library should use something similar to the following XML -> Parser -> XMLTree | XML <- Composer <--+ If we expand it will look like this XML -> Parser -> Handler -> XMLTree | XML <- Composer <- Handler <--+ So this is exactly what I want to achieve. Unfortunately, I don't have fresh ideas how to do that. So, by looking at my parsing code (which is not complete), do you have any suggestions how to do that. I believe that you guys have more experience than me in this areas and maybe you are aware of some techniques which I am not. Thanks in advance and sorry for the long and not that clear to me email. If this email is bothering you please take my apologies and ignore. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: parser.py Url: http://mail.python.org/pipermail/xml-sig/attachments/20051212/2417dd5a/parser.asc From martin at v.loewis.de Tue Dec 13 02:03:48 2005 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 13 Dec 2005 02:03:48 +0100 Subject: [XML-SIG] [Python-Dev] ElementTree in stdlib In-Reply-To: <200512130001.jBD01bXZ007657@chilled.skew.org> References: <200512130001.jBD01bXZ007657@chilled.skew.org> Message-ID: <439E1DF4.9000204@v.loewis.de> Mike Brown wrote: > Catching up on some python-dev email, I was surprised to see that things seem > to be barrelling ahead with the adding of ElementTree to Python core without > any discussion on XML-SIG. Sidestepping XML-SIG and the proving grounds of > PyXML in order to satsify the demand for a Pythonic databinding+API for XML in > stdlib seems to be a bit of a raised middle finger to those folks who have > worked hard on competing or differently-scoped APIs, each of which deserves a > bit more peer review than just a single nomination on python-dev, which seems > to be all it took to obtain a blessing for ElementTree. That is not true. The single nomination actually triggered a (admittedly fast) process, where multiple people spoke in favour, not just a single one. It also followed a discussion on python-list. > I have nothing against > ElementTree, and would like to see more XML processing options in core, but it > seems to me like the XML-SIG is being deliberately left out of this process. I think your impression is wrong (atleast on my part): I did not deliberately side-step xml-sig; it just didn't occur to me to have the discussion there also. I implicitly assumed most people on xml-sig would agree. > Just last month, Guido submitted to XML-SIG a Pythonic XML API that he had > been tinkering with.[1] I don't think anyone was really bold enough to tell > him what they really thought of it (other than that it is a lot like XIST), > but it was admirable that he put it up for peer review rather than just > dropping it into stdlib. Again, your impression is somewhat wrong: Guido first submitted the code to the SF bug tracker; there I commented that he should discuss it on xml-sig. I based this recommendation on my view that any such library should see a wider audience first before being admitted to the core; this library of Guido had (to my knowledge) not been seen by a wider audience. This is unlike ElementTree, which had existed for quite some time, and collected a lot of community feedback. > But the problem of how to choose from > the many options also became immediately apparent.[2] The discussion stalled, > but I think it should start up again, in the proper forum, rather than letting > the first-mentioned API supplant the dozen+ alternatives that could also be > considered as candidates.[3] Well, this is one of the big problems with XML: there are so many libraries to chose from, for so many different kinds of applications. It took me some time to understand what kind of application Guido's library is targetting - and such an analysis always ends up with saying "It is like X, but has Y instead". In this setting, how should we chose a library? In the last round, it was "let's believe in standards". I personally still believe in standards, but it appears that the Python community views them as too bloated. So as that has more-or-less failed, the next natural approach is "let's believe in the community". For that, two things need to happen: the author of the package must indicate that he would like to see it incorporated, and the users must indicate that they like the package. Both has happened for ElementTree, but I think it could happen for other packages, as well. If it is merely the lack of due process you are complaining about, and you agree with the result, then IMO nothing would need to be changed about the result. Discussing it post-factum on xml-sig might still be valuable. Regards, Martin From mike at skew.org Tue Dec 13 02:34:44 2005 From: mike at skew.org (Mike Brown) Date: Mon, 12 Dec 2005 18:34:44 -0700 (MST) Subject: [XML-SIG] [Python-Dev] ElementTree in stdlib Message-ID: <200512130134.jBD1YiAd008569@chilled.skew.org> (Context: the thread starting at http://mail.python.org/pipermail/python-dev/2005-December/058638.html ) > So as that has more-or-less failed, the next natural approach is > "let's believe in the community". For that, two things need to > happen: the author of the package must indicate that he would like > to see it incorporated, and the users must indicate that they like > the package. Both has happened for ElementTree, but I think it > could happen for other packages, as well. > > If it is merely the lack of due process you are complaining about, > and you agree with the result, then IMO nothing would need to be > changed about the result. Discussing it post-factum on xml-sig > might still be valuable. Thanks Martin and others for responding. I full agree that ElementTree has proven to be useful, popular, and stable, and probably no one would object to ElementTree being given the endorsement that is implicit in its being made a part of stdlib. The lack of due process, given that XML-SIG seems to exist largely to provide that very service for all things XML in Python, is indeed all I'm complaining about. I am happy that for once, there is momentum behind this sort of thing, and more power to you for that. My fears are just that 1. XML-SIG is being seen as either irrelevant or as an obstacle (perhaps due to the friction between Fredrik and Uche) and are thus being sidestepped, and 2. other libs that could/should be contenders (Amara and 4Suite are not in this list, by the way) are going to become further marginalized by virtue of the fact that people will say "well, we have ElementTree in stdlib already, why do we need (fill in the blank)?" I suppose the same kind of implicit endorsements were given to minidom and SAX, and that obviously hasn't prevented people from going out and using ElementTree, lxml, etc., so I don't know... I can't predict the future. I'd just feel better about it if everyone on XML-SIG, where people hang out because they have a definite interest in this kind of thing, knew what was going on. Some authors of other libs may not even be aware that they could so easily have their code whisked into stdlib, if it's solid enough. Mike From mapajin at cs.vhebron.es Tue Dec 13 11:24:41 2005 From: mapajin at cs.vhebron.es (mapajin@cs.vhebron.es) Date: Tue, 13 Dec 2005 11:24:41 +0100 Subject: [XML-SIG] DELIVERY REPORTS ABOUT YOUR E-MAIL Message-ID: <200512131028.jBDASKBc021289@servmailp.cs.vhebron.es> This message was not delivered due to the following reason(s): Your message was not delivered because the destination computer was unreachable within the allowed queue period. The amount of time a message is queued before it is returned depends on local configura- tion parameters. Most likely there is a network problem that prevented delivery, but it is also possible that the computer is turned off, or does not have a mail system running right now. Your message could not be delivered within 1 days: Mail server 35.217.75.191 is not responding. The following recipients could not receive this message: Please reply to postmaster at python.org if you feel this message to be in error. From fdrake at acm.org Tue Dec 13 21:54:00 2005 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 13 Dec 2005 15:54:00 -0500 Subject: [XML-SIG] "xml" package in standard library In-Reply-To: References: <20051213063118.4eivt285x1f4sks0@login.werra.lunarpages.com> <200512131518.38810.fdrake@acm.org> Message-ID: <200512131554.00880.fdrake@acm.org> I've CC'd the XML-SIG list on this; discussion should probably continue on python-dev since we're well into the xml package at this point. On Tuesday 13 December 2005 15:29, Fredrik Lundh wrote: > what's the status of PyXML? is it time to move it over to svn.python.org > and bring it up to 1.0 (whatever that would mean?) I'm not entirely sure myself; I've had no real time to look at it for a while. I think before we need to worry about PyXML from the perspective of the standard library, we need to work out a better way to deal with the "xml" package. Not only is the current state a source of confusion for users, it's a problem for testing the standard library if there's also a PyXML installed for the same version of Python (the PyXML modules are imported instead of the stdlib modules, but the tests for the standard library may reflect fixed bugs). This has bit me a few times. I'd like to propose that a new package be created in the standard library: xmlcore. This package should contain what's currently in the "xml" package. The xml package should be replaced with a single module that's responsible for the magic that xml/__init__.py deals with now. The tests for the xml package will be changed to test the xmlcore package. Advantages: - People who specifically want the standard library code can get it without having PyXML get in the way if installed. - Existing code using the xml package will continue to work. Risks: - Pickles containing classes from the xml package will break if we're not really careful. But I think they're pretty fragile now. I'll be glad to make these or similar changes if there's concensus on this. -Fred -- Fred L. Drake, Jr. From amk at amk.ca Wed Dec 14 00:40:12 2005 From: amk at amk.ca (A.M. Kuchling) Date: Tue, 13 Dec 2005 18:40:12 -0500 Subject: [XML-SIG] [Python-Dev] "xml" package in standard library In-Reply-To: <200512131554.00880.fdrake@acm.org> References: <20051213063118.4eivt285x1f4sks0@login.werra.lunarpages.com> <200512131518.38810.fdrake@acm.org> <200512131554.00880.fdrake@acm.org> Message-ID: <20051213234012.GA19680@rogue.amk.ca> On Tue, Dec 13, 2005 at 03:54:00PM -0500, Fred L. Drake, Jr. wrote: > I'd like to propose that a new package be created in the standard library: > xmlcore. This package should contain what's currently in the "xml" package. +1; it's what should have been done in the first place. --amk From fdrake at acm.org Wed Dec 14 08:00:18 2005 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 14 Dec 2005 02:00:18 -0500 Subject: [XML-SIG] [Python-Dev] "xml" package in standard library In-Reply-To: <20051213234012.GA19680@rogue.amk.ca> References: <20051213063118.4eivt285x1f4sks0@login.werra.lunarpages.com> <200512131554.00880.fdrake@acm.org> <20051213234012.GA19680@rogue.amk.ca> Message-ID: <200512140200.18421.fdrake@acm.org> On Tuesday 13 December 2005 18:40, A.M. Kuchling wrote: > +1; it's what should have been done in the first place. If only I'd understood that when I added the xml/PyXML hack to the stdlib years ago. :-( Fixed now. I'll deal with the documentation in a few days; I actually expect to have some time. -Fred -- Fred L. Drake, Jr. From mal at egenix.com Wed Dec 14 12:17:33 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 14 Dec 2005 12:17:33 +0100 Subject: [XML-SIG] [Python-Dev] "xml" package in standard library In-Reply-To: <200512140200.18421.fdrake@acm.org> References: <20051213063118.4eivt285x1f4sks0@login.werra.lunarpages.com> <200512131554.00880.fdrake@acm.org> <20051213234012.GA19680@rogue.amk.ca> <200512140200.18421.fdrake@acm.org> Message-ID: <439FFF4D.8030607@egenix.com> Fred L. Drake, Jr. wrote: > On Tuesday 13 December 2005 18:40, A.M. Kuchling wrote: > > +1; it's what should have been done in the first place. > > If only I'd understood that when I added the xml/PyXML hack to the stdlib > years ago. :-( > > Fixed now. I'll deal with the documentation in a few days; I actually expect > to have some time. I saw your checkin: wouldn't it be better to keep the xml directory and xml/__init__.py instead of adding an xml.py module ? The semantics of a package import are different than that of a module import, so this may make a difference. I did the same for the mx packages some years ago (when I moved everything under the mx package) and then used code like this to make sure that pickles continued to work as well as have them redirected to the new package once they were stored again: DateTime/__init__.py: # Redirect all imports to the corresponding mx package def _redirect(mx_subpackage): global __path__ import os,mx __path__ = [os.path.join(mx.__path__[0],mx_subpackage)] _redirect('DateTime') # Now load all important symbols from mx.DateTime import * from mx.DateTime import __version__ Note that in doing so, pickles will get redirected to the new package. I'm not sure whether that's what you would want for the xml/PyXML package, though: it would either direct them to the xmlcore package (bypassing PyXML on systems where it's installed) or direct them to the PyXML versions (bypassing the xmlcore package and causing them only to be unpicklable on systems with PyXML installed). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Dec 14 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From uche.ogbuji at gmail.com Wed Dec 14 15:10:48 2005 From: uche.ogbuji at gmail.com (Uche Ogbuji) Date: Wed, 14 Dec 2005 07:10:48 -0700 Subject: [XML-SIG] Create XML string with python Message-ID: <57ac7f9e0512140610w29d25d8j6e3d2e674f163024@mail.gmail.com> On Fri, 2005-12-09 at 12:44 -0700, Uche Ogbuji wrote: On Fri, 2005-12-09 at 18:09 +0100, Marco Meoni wrote: > Hi. I have to create a XML string from a GUI. In the GUI i have some > "bottons". Clicking on this bottons the program should create a XML in > a string (a STRING, the XML must be into a Python STRING ;-) ) > If you have an idea or a .py please send me... > All is welcome, you can send me example, ideas, the solution or what > you want!! > I must include this function in a program soon and have a little bit > of time!!! > Thanks to all and sorry for my "italian" english... Almost all XML toolkits will allow you to serialize to a string. There are many toolkits you can choose from. Do you have any other details on your specific needs? My recommendation, just pick a toolkit and read its docs to see how to write XML to string. You may need to use the cStringIO module, but this is very easy. -- 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051214/47ecbe39/attachment.htm From uche.ogbuji at gmail.com Wed Dec 14 15:05:21 2005 From: uche.ogbuji at gmail.com (Uche Ogbuji) Date: Wed, 14 Dec 2005 07:05:21 -0700 Subject: [XML-SIG] ANN: 4Suite XML 1.0b3 Message-ID: <57ac7f9e0512140605l6fb04d49ibd24d22246b096dc@mail.gmail.com> Today we release 4Suite XML 1.0 beta 3, now available from Sourceforge and ftp.4suite.org. As of the last release (1.0b2) 4Suite is split into three separate packages: 4Suite XML - XML, XPath, XSLT, related technologies and support libraries 4Suite RDF - RDF processing libraries and stand-alone DBMS 4Suite Repository - XML and RDF repository This is a release of just the first component. Highlights of changes in 4Suite XML since the last release ------------------ * 4Suite now has native DTD validation for Domlette and Saxlette, implemented in C. PyXML (xmlproc) is no a requirement for validation, and thus PyXML is no longer required for any feature in 4Suite. For Domlette validation, simply use ValidatingReader. For Saxlette validation, use P.setFeature(xml.sax.handler.feature_validation, True). Also new to Saxlette are: DTDHandler, DeclHandler and ErrorHandler. * New Ft.Xml.Lib.BaseUri function, which attempts to implement the semantics of the baseURI DOM Level 3 attribute as a stop-gap until some improvements can be made directly in Domlette. * New Ft.Lib.Uri.Relativize function, which produces context-sensitive relative references from absolute URIs. * Platform fixes for 64-bit Intel/AMD and HP-UX * Deprecate Ft.Xml.ParsePath and Ft.Xml.Xslt.TransformPath (whose duties are now also taken up by Ft.Xml.Parse and Ft.Xml.Xslt.Transform) * Deprecate category metadata property for XSLT extension elements * Bug fixes, improvements to performance and documentation 4Suite is a comprehensive platform for XML and RDF processing, with base libraries and a server framework. It is implemented in Python and C, and provides Python and XSLT APIs, Web and command line interfaces. 4Suite XML is the core set of XML, XPath, XSLT, related technologies and support libraries. The manual is included in the documents, or you can browse it online at http://uche.ogbuji.net/tech/4suite/etc/CoreManual.html For general information, see: http://4suite.org http://uche.ogbuji.net/tech/4Suite/ For the files, see: ftp://ftp.4suite.org/pub/4Suite/ Sources: ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0b3.tar.gz ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0b3.tar.bz2 ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0b3.zip Windows installer: ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0b3.win32-py2.2.exe ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0b3.win32-py2.3.exe ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0b3.win32-py2.4.exe You can also get the files on Sourceforge: https://sourceforge.net/projects/foursuite/ https://sourceforge.net/project/showfiles.php?group_id=39954 Documentation: In the locations specified above, with filenames of the form 4Suite-XML-docs-1.0b3.* Release notes ------------------ The current installation directory layout document tells where package files are installed: http://4suite.org/docs/installation-locations.xhtml For insulation from Domlette implementation changes, developers should always use the generic Ft.Xml.Domlette APIs (rather than, say Ft.Xml.cDomlette). -- 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051214/c42cd3fe/attachment.html From uche.ogbuji at gmail.com Wed Dec 14 15:12:11 2005 From: uche.ogbuji at gmail.com (Uche Ogbuji) Date: Wed, 14 Dec 2005 07:12:11 -0700 Subject: [XML-SIG] XMLToolkit 0,7,BETA.2 Message-ID: <57ac7f9e0512140612ibbbe45fi16d704b42179149c@mail.gmail.com> On Sun, 2005-12-11 at 07:49 -0700, Uche Ogbuji wrote: I got a bounce saying this message had been blocked by XBL, even though the server in question is not listed in XBL. Busted config? On Thu, 2005-12-08 at 10:37 +0000, Petko Petkov wrote: > Hello to everybody, > This is XMLToolkit 0,7,BETA.2. I simplified most of the code. There are > a few new features added as well. Now you can use the Binding tool to > Bind XML documents to python objects. > > doc = Binding.fromfile('GoogleService.wsdl') > doc.definitions.message > doc.definitions.message[0] > doc.definitions.message[1] > doc.definitions.message.name > doc.definitions.message.name = 'bla bla' > doc.definitions.message = '

Hei I can assign XML to elements that > will be parsed on the fly.

Good!' This is a neat feature, and similar to the append_xml_fragment() method in Amara. I do wonder whether it should be the default, though. As an example, in Amara the above would set text in that element and escape the angle brackets. If you wanted to add child elements you'd have to do: doc.definitions.message.append_xml_fragment('

Hei I can assign XML to elements that will be parsed on the fly.

Good!') My worry with your approach is that if I want to use such characters in my regular XML, I'd have to escape them. Rather than doing: doc.definitions.message = '100 < 1000' I'd have to do: doc.definitions.message = '100 < 1000' Which seems a bit odd at the content API level? > doc.definitions.message[1] = OtherBinding > doc.definitions.message[2] = OtherElement > doc.definitions.message[0] = doc.definitions.message[2] > for m in doc.definitions.message: > print m > print m.name > > doc.xml > doc.xml(encoding = 'utf-8') > doc.xml(encoding = 'utf-8', stream = mystream) > doc.xml(encoding = 'utf-8', file = 'myGoogle.wsdl') > str(doc.xml) > doc.xml.composestream(stream) > > As you can see the syntax is similar to Amara XMLToolkit. Yes. Nice. What does doc.xml.composestream(stream) do, though? I'm sorry that I don't have much time to peruse your code. -- 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051214/393e2ec3/attachment.htm From uche.ogbuji at gmail.com Wed Dec 14 15:09:52 2005 From: uche.ogbuji at gmail.com (Uche Ogbuji) Date: Wed, 14 Dec 2005 07:09:52 -0700 Subject: [XML-SIG] Possible SOAP/ZSI bug? Message-ID: <57ac7f9e0512140609l102dea38h467f048e4876313d@mail.gmail.com> I'm having trouble mailing XML-SIG from my Fourthought addess. On Wed, 2005-12-07 at 16:51 -0700, Uche Ogbuji wrote: I don't know how many Web services types hang around here. I have seen that such questions do tend to be addressed on the pywebsvcs-talk mailing list. I'd suggest asking there. Best of luck. http://sourceforge.net/mailarchive/forum.php?forum_id=1729 --Uche On Tue, 2005-12-06 at 03:58 +0100, Laszlo Zsolt Nagy wrote: > Olivier Collioud wrote: > > >I don't want to go in the detail but for interopability between all > >platform you need this kind of WS: > >Style=document > >Use=literal > > > > > I'm trying to create python source code for a wsdl. > According to the ZSI documentation, there is a 'wsdl2py' program that > can create python interfaces for a given wsdl. > But there is no such program in the distribution. > > http://pywebsvcs.sourceforge.net/zsi.html#SECTION0012300000000000000000 > > For this reason, I tried to use the WriteServiceModule function: > > import ZSI > import ZSI.wsdl2python > from ZSI.wstools import WSDLTools > > fname = 'eBaySvc.wsdl' > reader = WSDLTools.WSDLReader() > wsdl = reader.loadFromFile(fname) > print wsdl > wsm = ZSI.wsdl2python.WriteServiceModule(wsdl) > wsm.write() > > Result: > > C:/Python24/pythonw.exe -u > "T:/Python/Projects/eBay-SOAP/create_interfaces.py" > > Traceback (most recent call last): > File "T:/Python/Projects/eBay-SOAP/create_interfaces.py", line 28, in ? > wsm.write() > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 213, in > write > esuffix=esuffix) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 264, in > write_service_types > esuffix=esuffix) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 367, in > write_dependent_schema > sd.fromWsdl(schema, alternateWriter) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1092, in > fromWsdl > self.generate(schema.getTypesDict(), alternateWriter) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1121, in > generate > tw.fromType(tp, ref) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1241, in > fromType > self._fromComplexType(tp) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1459, in > _fromComplexType > typecodelist += self._complexTypeAllOrSequence(tp, mg) > File "C:\Python24\Lib\site-packages\ZSI\wsdl2python.py", line 1672, in > _complexTypeAllOrSequence > if e.getType(): > File "C:\Python24\Lib\site-packages\ZSI\wsdlInterface.py", line 1800, > in getType > typ = self._dec.getTypeDefinition('type') > File "C:\Python24\Lib\site-packages\ZSI\wstools\XMLSchema.py", line > 1926, in getTypeDefinition > raise Warning, 'invalid operation for <%s>' %self.tag > Warning: invalid operation for > > It is only a warning but it terminates the operation. What am I doing wrong? > Sorry for the bunch of questions. This is the first time I use SOAP. > -- Uche http://uche.ogbuji.net http://copia.ogbuji.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051214/d16fe2d8/attachment.html From fdrake at acm.org Wed Dec 14 18:41:26 2005 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 14 Dec 2005 12:41:26 -0500 Subject: [XML-SIG] [Python-Dev] "xml" package in standard library In-Reply-To: References: <20051213063118.4eivt285x1f4sks0@login.werra.lunarpages.com> <200512140200.18421.fdrake@acm.org> Message-ID: <200512141241.26354.fdrake@acm.org> On Wednesday 14 December 2005 12:13, Fredrik Lundh wrote: > looks like you broken installation (the libinstall target hasn't been > updated); from comp.lang.python: Ouch! Thanks for fixing this. > you also broke my subversion: > > $ svn up > svn: subversion/libsvn_ra_svn/marshal.c:434: vwrite_tuple: Assertion `opt > || cstr' failed. Aborted I've never seen anything like that from Subversion before. -Fred -- Fred L. Drake, Jr. From uche.ogbuji at gmail.com Wed Dec 14 18:53:43 2005 From: uche.ogbuji at gmail.com (Uche Ogbuji) Date: Wed, 14 Dec 2005 10:53:43 -0700 Subject: [XML-SIG] ANN: Amara XML Toolkit 1.1.7 Message-ID: <57ac7f9e0512140953m4874767dk8a5d24eb2057dcd0@mail.gmail.com> http://uche.ogbuji.net/tech/4suite/amara ftp://ftp.4suite.org/pub/Amara/ Changes since Amara 1.1.6: * Deprecate xml_text_content property * Add xml_child_text property that concatenates all immediate child text nodes (no recursive descent) * Change unicode coercion for documents and elements to recurse through all descendant text (now analogous to XPath's string() coercion) * Return added or removed node in - xml_append - xml_insert_after - xml_insert_before - xml_remove_child - xml_remove_child_at * Update allinone bundle to 4Suite 1.0b3 * Packaging fixes Amara XML Toolkit is a collection of Python tools for XML processing-- not just tools that happen to be written in Python, but tools built from the ground up to use Python idioms and take advantage of the many advantages of Python. Amara builds on 4Suite [http://4Suite.org], but whereas 4Suite focuses more on literal implementation of XML standards in Python, Amara focuses on Pythonic idiom. It provides tools you can trust to conform with XML standards without losing the familiar Python feel. The components of Amara are: * Bindery: data binding tool (a very Pythonic XML API) * Scimitar: implementation of the ISO Schematron schema language for XML; converts Schematron files to Python scripts * domtools: set of tools to augment Python DOMs * saxtools: set of tools to make SAX easier to use in Python * Flextyper: user-defined datatypes in Python for XML processing There's a lot in Amara, but here are highlights: Amara Bindery: XML as easy as py -------------------------------- Bindery turns an XML document into a tree of Python objects corresponding to the vocabulary used in the XML document, for maximum clarity. For example, the document What do you mean "bleh" But I was looking for argument Becomes a data structure such that you can write binding.monty.python.spam In order to get the value "eggs" or binding.monty.python[1] In order to get the value "But I was looking for argument". There are other such tools for Python, and what makes Anobind unique is that it's driven by a very declarative rules-based system for binding XML to the Python data. You can register rules that are triggered by XPattern expressions specialized binding behavior. It includes XPath support and supports mutation. Bindery is very efficient, using SAX to generate bindings. Scimitar: Schematron for Pytthon -------------------------------- Merged in from a separate project, Scimitar is an implementation of ISO Schematron that compiles a Schematron schema into a Python validator script. You typically use scimitar in two phases. Say you have a schematron schema schema1.stron and you want to validate multiple XML files against it, instance1.xml, instance2.xml, instance3.xml. First you run schema1.stron through the scimitar compiler script, scimitar.py: scimitar.py schema1.stron The generated file, schema1.py, can be used to validate XML instances: python schema1.py instance1.xml Which emits a validation report. Amara DOM Tools: giving DOM a more Pythonic face ------------------------------------------------ DOM came from the Java world, hardly the most Pythonic API possible. Some DOM-like implementations such as 4Suite's Domlettes mix in some Pythonic idiom. Amara DOM Tools goes even further. Amara DOM Tools feature pushdom, similar to xml.dom.pulldom, but easier to use. It also includes Python generator-based tools for DOM processing, and a function to return an XPath location for any DOM node. Amara SAX Tools: SAX without the brain explosion ------------------------------------------------ Tenorsax (amara.saxtools.tenorsax) is a framework for "linerarizing" SAX logic so that it flows more naturally, and needs a lot less state machine wizardry. License ------- Amara is open source, provided under the 4Suite variant of the Apache license. See the file COPYING for details. Installation ------------ Amara 1.1.7 requires Python 2.4 or more recent. If you do not have 4Suite XML 1.0b2 or better, grab the Amara-allinone package. If you already have 4Suite XML installed, grab the stand along Amara package. In either case, unpack to a convenient location and run: python setup.py install -- Uche http://uche.ogbuji.net http://copia.ogbuji.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051214/1004d6f6/attachment.htm From martin at v.loewis.de Wed Dec 14 20:12:33 2005 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 14 Dec 2005 20:12:33 +0100 Subject: [XML-SIG] [Python-Dev] "xml" package in standard library In-Reply-To: <200512131554.00880.fdrake@acm.org> References: <20051213063118.4eivt285x1f4sks0@login.werra.lunarpages.com> <200512131518.38810.fdrake@acm.org> <200512131554.00880.fdrake@acm.org> Message-ID: <43A06EA1.90908@v.loewis.de> Fred L. Drake, Jr. wrote: > - Pickles containing classes from the xml package will break if we're not > really careful. But I think they're pretty fragile now. > > I'll be glad to make these or similar changes if there's concensus on this. I don't agree with the change. You just broke source compatibility between the core package and PyXML. Regards, Martin From henrypijames at lycos.com Thu Dec 15 02:09:46 2005 From: henrypijames at lycos.com (Henry James) Date: Wed, 14 Dec 2005 20:09:46 -0500 Subject: [XML-SIG] Bug in xml.dom.minidom.NamedNodeMap ? Message-ID: <20051215010946.3921286B13@ws7-1.us4.outblaze.com> According to the documentation, xml.dom.minidom.NamedNodeMap has "experimental methods that give this class more mapping behavior". But this is what happens: >>> import xml.dom.minidom >>> s = '' >>> n = xml.dom.minidom.parseString(s).documentElement.firstChild >>> n.attributes.keys() [u'attr_2', u'attr_1'] >>> [a for a in n.attributes] Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/xml/dom/minidom.py", line 529, in __getitem__ KeyError: 0 I can't quite understand why access to a key "0" is being attempted here. -- _______________________________________________ Search for businesses by name, location, or phone number. -Lycos Yellow Pages http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10 From fz.3 at arcor.de Fri Dec 16 08:54:22 2005 From: fz.3 at arcor.de (fz.3@arcor.de) Date: Fri, 16 Dec 2005 08:54:22 +0100 (CET) Subject: [XML-SIG] An 'XMLic' binding for Python objects Message-ID: <27182750.1134719662274.JavaMail.ngmail@webmail-01.arcor-online.net> Looking at Uche Ogbuji?s Amara and David Mertz? Gnosis Objectify, I was impressed by their simple 'pythonic' bindings ? the network of Python objects generated from an XML document reflect the document's (schema's) object model, rather than impose a fixed (meta)model on the data, the way DOM does. Dave Kuhlman's generateDS does something similar, but starts with an XML Schema rather than an instance document. These approaches presuppose the existence of XML data (or of an XML Schema in the case of generateDS). I need to go the opposite direction, however: I have a network of Python objects and need to generate XML from it. In the past, I have simply persisted my object network using pickle. This was sufficient until our customer discovered the need to generate reports from this data using (non-python) XML tools, so the idea was born to persist the data as XML document(s). Xml_pickle immediately sprang to mind . The problem is that it generates the XML according to a fixed (meta)DTD, like the DOM approach in reverse. What we really need is a more 'XMLic' approach ;-), i.e. an XML that reflects the object model of our Python object network. Ideally, this approach should also supply the DTD/XSD/RelaxNG schema (our customer favours XML Schema). What would be the best way to go about it? Is there any alternative to xml_pickle that is more 'XMLic'? AFAIK there are tools that can infer the schema from an instance document, which could be a way of satisfying the second requirement, once we have succeeded in dumping an XML instance document. I should also mention that our Python classes are modelled in UML using Enterprise Architect from Sparx Systems. This tool has the capability of generating XSD for a model. The XSD that it generates for our model would require quite a lot of post-editing, however. Thanks a lot in advance Fritz Bosch Machen Sie aus 14 Cent spielend bis zu 100 Euro! Die neue Gaming-Area von Arcor - ?ber 50 Onlinespiele im Angebot. http://www.arcor.de/rd/emf-gaming-1 From bortzmeyer at nic.fr Fri Dec 16 11:21:28 2005 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Fri, 16 Dec 2005 11:21:28 +0100 Subject: [XML-SIG] An 'XMLic' binding for Python objects In-Reply-To: <27182750.1134719662274.JavaMail.ngmail@webmail-01.arcor-online.net> References: <27182750.1134719662274.JavaMail.ngmail@webmail-01.arcor-online.net> Message-ID: <20051216102128.GA16938@nic.fr> On Fri, Dec 16, 2005 at 08:54:22AM +0100, fz.3 at arcor.de wrote a message of 25 lines which said: > AFAIK there are tools that can infer the schema from an instance > document, Examplotron (http://examplotron.org). It generates RelaxNG schemas from an instance document. You can use trang to produce DTD or W3C schemas. It allows you to specify (with namespaced attributes in the document) constraints when they are not inferable from the document (for instance, the fact that an element is optional, something that Examplotron cannot find itself). From fredrik at pythonware.com Fri Dec 16 13:45:08 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Dec 2005 13:45:08 +0100 Subject: [XML-SIG] Bug in xml.dom.minidom.NamedNodeMap ? References: <20051215010946.3921286B13@ws7-1.us4.outblaze.com> Message-ID: Henry James wrote: > According to the documentation, xml.dom.minidom.NamedNodeMap has > "experimental methods that give this class more mapping behavior". But this > is what happens: > >>>> import xml.dom.minidom >>>> s = '>>> attr_2="2"/>' >>>> n = xml.dom.minidom.parseString(s).documentElement.firstChild >>>> n.attributes.keys() > [u'attr_2', u'attr_1'] >>>> [a for a in n.attributes] > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/lib/python2.4/xml/dom/minidom.py", line 529, in __getitem__ > KeyError: 0 > > I can't quite understand why access to a key "0" is being attempted here. being able to iterate over certain mappings is a relatively new addition to Python. if an object doesn't implement the __iter__ hook required for iteration, the for-loop will call __getitem__ until it gets an IndexError. any other error will be propagated to the caller (like the KeyError you get in this case). try [a for a in n.attributes.keys()] instead. From fz.3 at arcor.de Fri Dec 16 10:05:31 2005 From: fz.3 at arcor.de (fz.3@arcor.de) Date: Fri, 16 Dec 2005 10:05:31 +0100 (CET) Subject: [XML-SIG] An 'XMLic' binding for Python objects Message-ID: <28141252.1134723931254.JavaMail.ngmail@webmail-03.arcor-online.net> Looking at Uche Ogbuji's Amara and David Mertz' Gnosis Objectify, I was impressed by their simple 'pythonic' bindings - the network of Python objects generated from an XML document reflect the document's (schema's) object model, rather than impose a fixed (meta)model on the data, the way DOM does. Dave Kuhlman's generateDS does something similar, but starts with an XML Schema rather than an instance document. These approaches presuppose the existence of XML data (or of an XML Schema in the case of generateDS). I need to go the opposite direction, however: I have a network of Python objects and need to generate XML from it. In the past, I have simply persisted my object network using pickle. This was sufficient until our customer discovered the need to generate reports from this data using (non-python) XML tools, so the idea was born to persist the data as XML document(s). Xml_pickle immediately sprang to mind . The problem is that it generates the XML according to a fixed (meta)DTD, like the DOM approach in reverse. What we really need is a more 'XMLic' approach ;-), i.e. an XML that reflects the object model of our Python object network. Ideally, this approach should also supply the DTD/XSD/RelaxNG schema (our customer favours XML Schema). What would be the best way to go about it? Is there any alternative to xml_pickle that is more 'XMLic'? AFAIK there are tools that can infer the schema from an instance document, which could be a way of satisfying the second requirement, once we have succeeded in dumping an XML instance document. I should also mention that our Python classes are modelled in UML using Enterprise Architect from Sparx Systems. This tool has the capability of generating XSD for a model. The XSD that it generates for our model would require quite a lot of post-editing, however. Thanks a lot in advance Fritz Bosch Machen Sie aus 14 Cent spielend bis zu 100 Euro! Die neue Gaming-Area von Arcor - ?ber 50 Onlinespiele im Angebot. http://www.arcor.de/rd/emf-gaming-1 From meonimarco at gmail.com Mon Dec 19 11:10:00 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Mon, 19 Dec 2005 11:10:00 +0100 Subject: [XML-SIG] xmlproc Message-ID: <43A686F8.6020901@gmail.com> Hi. I'm new in using xmlproc. Have you a example-file to show me to help me in using it? I prefer if you have an example in dtd APIs, but i accept all that you send me! What you suggest me to use xmlproc? Have you tips or trikcs for using it? Bye. Marco -- mail address: meonimarco at gmail.com web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051219/82f9a586/attachment.html From werner.bruhin at free.fr Mon Dec 19 14:13:29 2005 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 19 Dec 2005 14:13:29 +0100 Subject: [XML-SIG] elementtree, element.text = value problem and a couple other questions Message-ID: <43A6B1F9.7020807@free.fr> I just don't get it. Excerpt from my code: def addElement(doc, name): new = et.SubElement(doc, name) return new def addValueElement(doc, name, value): new = et.SubElement(doc, name) new.text = value new.text = '\n' return new doc_header = """""" doc = et.XML(doc_header) addValueElement(xml, u'name', string.strip(dbItem.winename)) addValueElement(xml, u'additionalname', string.strip(dbItem.winename2)) .... more But the "value" writing to new.text doesn't show up in the xml file. What am I missing? By the way is it possible to write the file in a "pretty" format? One last question (at least for the moment) is how to get something along the following lines into the header/beginning of the file: Message-ID: Werner F. Bruhin wrote: >I just don't get it. > > Excerpt from my code: > > def addElement(doc, name): > new = et.SubElement(doc, name) > return new > > def addValueElement(doc, name, value): > new = et.SubElement(doc, name) > new.text = value > new.text = '\n' did you perhaps mean to write > new.text = value + '\n' ? From werner.bruhin at free.fr Mon Dec 19 17:00:45 2005 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 19 Dec 2005 17:00:45 +0100 Subject: [XML-SIG] elementtree ProcessingInstructions Message-ID: <43A6D92D.5000109@free.fr> I think that the following are considered ProcessingInstructions. Am I correct? If yes how do I get them into file? doc = et.XML(doc_header) pi1 = et.ProcessingInstruction('xml version="1.0" encoding="UTF-8') doc.append(pi1) # append is not what I want/need pi2 = et.ProcessingInstruction(("twcb version=%s;xsd=wineXML.xsd") % (__version__.twcbVERSION_STRING)) doc.append(pi2) # append is not what I want/need Thanks in advance for any help Werner From werner.bruhin at free.fr Mon Dec 19 17:03:48 2005 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 19 Dec 2005 17:03:48 +0100 Subject: [XML-SIG] elementtree and namespace Message-ID: <43A6D9E4.3030604@free.fr> How can I define in a doc the following namespace? And what do I need to do that subsequent "Element" and "SubElement" additions use the name space? Would I have to name the elements "nsw:name" instead of just "name"? Again thanks in advance for any hints. Werner From fredrik at pythonware.com Mon Dec 19 17:12:11 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Dec 2005 17:12:11 +0100 Subject: [XML-SIG] elementtree and namespace References: <43A6D9E4.3030604@free.fr> Message-ID: Werner F. Bruhin wrote: > How can I define in a doc the following namespace? > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.winexml.org/XMLSchema wineXML.xsd"> > > > And what do I need to do that subsequent "Element" and "SubElement" > additions use the name space? Would I have to name the elements > "nsw:name" instead of just "name"? ElementTree uses universal names for this purpose: http://effbot.org/zone/element.htm#xml-namespaces From larsga at ontopia.net Mon Dec 19 17:17:02 2005 From: larsga at ontopia.net (Lars Marius Garshol) Date: Mon, 19 Dec 2005 17:17:02 +0100 Subject: [XML-SIG] elementtree ProcessingInstructions In-Reply-To: <43A6D92D.5000109@free.fr> References: <43A6D92D.5000109@free.fr> Message-ID: * Werner F. Bruhin > > I think that the following are considered ProcessingInstructions. > > > > > Am I correct? Only about the second one. The first one is the XML declaration, and is not considered a processing instruction, despite being syntactically extremely similar. > If yes how do I get them into file? Well, that particular XML declaration is equivalent to not having one, since UTF-8 is the default encoding. If the system at the other end requires one, then either your MIME types need fixing, or the system at the other end is broken. > pi2 = et.ProcessingInstruction(("twcb version=% > s;xsd=wineXML.xsd") % > (__version__.twcbVERSION_STRING)) > doc.append(pi2) # append is not what I want/need What's wrong with append here? Does it give the right result, or some problem? -- Lars Marius Garshol, Ontopian http://www.ontopia.net +47 98 21 55 50 http://www.garshol.priv.no From cfbearden at gmail.com Mon Dec 19 17:43:18 2005 From: cfbearden at gmail.com (Chuck Bearden) Date: Mon, 19 Dec 2005 10:43:18 -0600 Subject: [XML-SIG] elementtree ProcessingInstructions In-Reply-To: <43A6D92D.5000109@free.fr> References: <43A6D92D.5000109@free.fr> Message-ID: <433ebc870512190843t7719802bm1185eb84538f0efe@mail.gmail.com> On 12/19/05, Werner F. Bruhin wrote: > I think that the following are considered ProcessingInstructions. > > > > > Am I correct? The first is an XML declaration, rather than a processing instruction.. See the XML specification for more info on this: Best wishes, Chuck Bearden From werner.bruhin at free.fr Mon Dec 19 18:54:50 2005 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 19 Dec 2005 18:54:50 +0100 Subject: [XML-SIG] elementtree ProcessingInstructions In-Reply-To: References: <43A6D92D.5000109@free.fr> Message-ID: <43A6F3EA.7070104@free.fr> Hi Lars, Lars Marius Garshol wrote: >* Werner F. Bruhin > > >>I think that the following are considered ProcessingInstructions. >> >> >> >> >>Am I correct? >> >> > >Only about the second one. The first one is the XML declaration, and >is not considered a processing instruction, despite being >syntactically extremely similar. > > > >>If yes how do I get them into file? >> >> > >Well, that particular XML declaration is equivalent to not having >one, since UTF-8 is the default encoding. If the system at the other >end requires one, then either your MIME types need fixing, or the >system at the other end is broken. > Just about any file I came acros they have these things in there, so is this just overkill or is it a convention that one puts them in. So, if they were not the default, i.e. if I would use "ISO-8859-1" how would I add them. > > >> pi2 = et.ProcessingInstruction(("twcb version=% >>s;xsd=wineXML.xsd") % >> (__version__.twcbVERSION_STRING)) >> doc.append(pi2) # append is not what I want/need >> >> > >What's wrong with append here? Does it give the right result, or some >problem? > > I like it at the top of the file and not in the middle. I was starting with a doc containing the root, but I think I am changing this in which case I could do this append as the first thing. Thanks for your hints and sorry if these are stupid questions or are answered in the specifications (frankly they are more confusing then helpful to me). I am trying to figure out what tools to use (easy to use, but still pretty full featured) and at the same time learn XML. I was jumping between lxml, elementtree and amara and just got more confused along the lines. So, as elementtree will become part of Python, I assume that this is happening as it is the best of the crop, I will just use it. Best regards Werner >-- >Lars Marius Garshol, Ontopian http://www.ontopia.net >+47 98 21 55 50 http://www.garshol.priv.no > > >_______________________________________________ >XML-SIG maillist - XML-SIG at python.org >http://mail.python.org/mailman/listinfo/xml-sig > > > > > From werner.bruhin at free.fr Mon Dec 19 19:39:20 2005 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 19 Dec 2005 19:39:20 +0100 Subject: [XML-SIG] elementtree ProcessingInstructions In-Reply-To: References: <43A6D92D.5000109@free.fr> <43A6F3EA.7070104@free.fr> Message-ID: <43A6FE58.3040106@free.fr> Lars Marius Garshol wrote: > > * Werner F. Bruhin > ..... > >> I like it at the top of the file and not in the middle. I was starting >> with a doc containing the root, but I think I am changing this in which >> case I could do this append as the first thing. > > > Exactly. :) But :-( it does not work. If I do this: pi = et.ProcessingInstruction("twcb version=1.7;xsd=wineXML.xsd") >>> wine = et.Element('wine') >>> pi.append(wine) >>> et.dump(pi) There is no "wine" element. And if I do this: >>> wine = et.Element('wine') >>> wine.insert(0, pi) >>> et.dump(wine) Then I have it in the middle again (same result with append or insert). So back to square one. Is there another way of building the document/tree which allows me to put the PI at the top? Sorry to be a bother Werner From fredrik at pythonware.com Mon Dec 19 22:10:12 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Dec 2005 22:10:12 +0100 Subject: [XML-SIG] elementtree, element.text = value problem and a couple other questions References: <43A6B1F9.7020807@free.fr> Message-ID: Werner F. Bruhin wrote: > By the way is it possible to write the file in a "pretty" format? here's a simple (and only lightly tested) in-place indenter: def indent(elem, level=0): i = "\n" + level*" " if len(elem): if not elem.text or not elem.text.strip(): elem.text = i + " " for elem in elem: indent(elem, level+1) if not elem.tail or not elem.tail.strip(): elem.tail = i else: if level and (not elem.tail or not elem.tail.strip()): elem.tail = i to prettyprint, just call this before you serialize the tree. (note that this doesn't work well on documents that contain mixed content). From fredrik at pythonware.com Mon Dec 19 22:24:27 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Dec 2005 22:24:27 +0100 Subject: [XML-SIG] elementtree, element.text = value problem and a couple other questions References: <43A6B1F9.7020807@free.fr> Message-ID: Fredrik Lundh wrote: > here's a simple (and only lightly tested) in-place indenter: > > def indent(elem, level=0): > i = "\n" + level*" " > if len(elem): > if not elem.text or not elem.text.strip(): > elem.text = i + " " > for elem in elem: > indent(elem, level+1) > if not elem.tail or not elem.tail.strip(): > elem.tail = i > else: > if level and (not elem.tail or not elem.tail.strip()): > elem.tail = i which can, in fact, be simplified too: def indent(elem, level=0): i = "\n" + level*" " if not elem.text or not elem.text.strip(): elem.text = i + " " for elem in elem: indent(elem, level+1) if not elem.tail or not elem.tail.strip(): elem.tail = i (however, this is perhaps a bit too clever...) From werner.bruhin at free.fr Tue Dec 20 19:33:29 2005 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Tue, 20 Dec 2005 19:33:29 +0100 Subject: [XML-SIG] Ebbeding image data in XML Message-ID: <43A84E79.4040609@free.fr> I would like to embed an image in an XML file. I was thinking of using PIL.tostring() and put it into the imageasstring element. RGB (540, 982) HERE GOES IMAGE DATA Currently I use lxml.etree and get encoding errors when I write the image into the element. I would like the file to XML Schema complient, so what "xs:" type should one use for the imageasstring element? Any hints as always much appreciated. Werner From alexandre.fayolle at logilab.fr Tue Dec 20 19:50:38 2005 From: alexandre.fayolle at logilab.fr (Alexandre Fayolle) Date: Tue, 20 Dec 2005 19:50:38 +0100 Subject: [XML-SIG] Ebbeding image data in XML In-Reply-To: <43A84E79.4040609@free.fr> References: <43A84E79.4040609@free.fr> Message-ID: <20051220185038.GF17916@crater.logilab.fr> On Tue, Dec 20, 2005 at 07:33:29PM +0100, Werner F. Bruhin wrote: > I would like to embed an image in an XML file. > > I was thinking of using PIL.tostring() and put it into the imageasstring > element. > > > RGB > (540, 982) > HERE GOES IMAGE DATA > > > Currently I use lxml.etree and get encoding errors when I write the > image into the element. > > I would like the file to XML Schema complient, so what "xs:" type should > one use for the imageasstring element? You'll need to encode the imagestring data to base64, and use the appropriate type. -- Alexandre Fayolle LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Retrait du projet de loi DADVSI: http://eucd.info/petitions/index.php?petition=2 Signez cette p?tition, et faites-la circuler autour de vous, avant le 20 d?cembre -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 481 bytes Desc: Digital signature Url : http://mail.python.org/pipermail/xml-sig/attachments/20051220/c833eb57/attachment.pgp From meonimarco at gmail.com Wed Dec 21 14:39:18 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Wed, 21 Dec 2005 14:39:18 +0100 Subject: [XML-SIG] Problem with xmlproc Message-ID: <43A95B06.7030104@gmail.com> Hello everybody. I have a problem with xmlproc. If I have a dtd in the direcory of this file, the parser send me to video the elelments and the attirbutes of the dtd. this is the video output: sbaush at sbaush:/media/hda5/Universita'/Tesi/Manager$ python parser2.py ELEMENTO: meshap-manager - (u'|', [(u'iptables-request', ''), (u'iptables-response', ''), (u'routing-table-request', ''), (u'routing-table-response', '')], '') ELEMENTO: iptables-request - (u'|', [(u'policy', ''), (u'list', ''), (u'flush', ''), (u'append', ''), (u'delete', '')], '') ELEMENTO: policy - EMPTY ATTRIBUTO: chain - Elemento: policy - Contenuto: [u'INPUT', u'OUTPUT', u'FORWARD'] #REQUIRED - Default:[None] ATTRIBUTO: target - Elemento: policy - Contenuto: [u'DROP', u'ACCEPT', u'REJECT'] #REQUIRED - Default:[None] ELEMENTO: list - EMPTY ATTRIBUTO: chain - Elemento: list - Contenuto: [u'INPUT', u'OUTPUT', u'FORWARD'] #IMPLIED - Default:[None] ELEMENTO: flush - EMPTY ATTRIBUTO: chain - Elemento: flush - Contenuto: [u'INPUT', u'OUTPUT', u'FORWARD'] #IMPLIED - Default:[None] ELEMENTO: append - (u',', [(u'protocol', u'?'), (u'source', u'?'), (u'destination', u'?'), (u'jump', '')], '') ATTRIBUTO: chain - Elemento: append - Contenuto: [u'INPUT', u'OUTPUT', u'FORWARD'] #REQUIRED - Default:[None] ELEMENTO: protocol - EMPTY ATTRIBUTO: type - Elemento: protocol - Contenuto: [u'tcp', u'udp', u'icmp'] #REQUIRED - Default:[None] ELEMENTO: source - EMPTY ATTRIBUTO: address - Elemento: source - Contenuto: CDATA #REQUIRED - Default:[None] ELEMENTO: destination - EMPTY ATTRIBUTO: address - Elemento: destination - Contenuto: CDATA #REQUIRED - Default:[None] ELEMENTO: jump - EMPTY ATTRIBUTO: option - Elemento: jump - Contenuto: [u'DROP', u'ACCEPT', u'REJECT'] #REQUIRED - Default:[None] ELEMENTO: delete - (u'|', [(u',', [(u'protocol', u'?'), (u'source', ''), (u'jump', '')], ''), (u'number', '')], '') ATTRIBUTO: chain - Elemento: delete - Contenuto: [u'INPUT', u'OUTPUT', u'FORWARD'] #REQUIRED - Default:[None] ELEMENTO: number - EMPTY ATTRIBUTO: line - Elemento: number - Contenuto: CDATA #REQUIRED - Default:[None] ELEMENTO: iptables-response - (u'|', [(u'done', ''), (u'listtable', '')], '') ELEMENTO: done - EMPTY ATTRIBUTO: value - Elemento: done - Contenuto: [u'true', u'false'] #REQUIRED - Default:[None] ELEMENTO: listtable - ('', [(u'table', u'+')], '') ELEMENTO: table - ('', [(u'rule', u'*')], '') ATTRIBUTO: chain - Elemento: table - Contenuto: [u'INPUT', u'OUTPUT', u'FORWARD'] #REQUIRED - Default:[None] ATTRIBUTO: policy - Elemento: table - Contenuto: [u'ACCEPT', u'DROP', u'REJECT'] #REQUIRED - Default:[None] ELEMENTO: rule - EMPTY ATTRIBUTO: number - Elemento: rule - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: target - Elemento: rule - Contenuto: [u'ACCEPT', u'DROP', u'REJECT'] #REQUIRED - Default:[None] ATTRIBUTO: protocol - Elemento: rule - Contenuto: [u'tcp', u'udp', u'icmp'] #REQUIRED - Default:[None] ATTRIBUTO: option - Elemento: rule - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: source - Elemento: rule - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: destination - Elemento: rule - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: description - Elemento: rule - Contenuto: CDATA #REQUIRED - Default:[None] ELEMENTO: routing-table-request - EMPTY ELEMENTO: routing-table-response - ('', [(u'route', '')], '') ELEMENTO: route - ('', [(u'row', u'*')], '') ELEMENTO: row - EMPTY ATTRIBUTO: interface - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: destination - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: gateway - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: flags - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: refcnt - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: use - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: metric - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: mask - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: mtu - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: window - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] ATTRIBUTO: irtt - Elemento: row - Contenuto: CDATA #REQUIRED - Default:[None] It works perfectly. The question is: what is the "u" in the elements?? Thanks to all. below there is my code. from xml.parsers.xmlproc import xmlproc import sys class DTDReporter(xmlproc.DTDConsumer): "A simple class that just prints out the events it receives." def __init__(self,parser,out=sys.stdout): xmlproc.DTDConsumer.__init__(self,parser) self.out=out def new_attribute(self,elem,attr,a_type,a_decl,a_def): self.out.write("ATTRIBUTO: %s - Elemento: %s - Contenuto: %s %s - Default:[%s]\n" % (attr,elem,a_type,a_decl,a_def)) def new_element_type(self,elem_name,elem_cont): self.out.write("ELEMENTO: %s - %s\n" % (elem_name,elem_cont)) # --- Client methods def close(self): self.out.close() # --- Main program if __name__ == '__main__': t=xmlproc.DTDParser() t.set_dtd_consumer(DTDReporter(t)) #Si sceglie se parsare il file messo come input da tastiera o se il file sul disco. Si puo' dare anche il percorso di localizzazione del file. #t.parse_resource(sys.argv[1]) t.parse_resource("MeshAP2.dtd") -- mail address: meonimarco at gmail.com web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051221/185022f0/attachment.html From meonimarco at gmail.com Wed Dec 21 15:55:13 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Wed, 21 Dec 2005 15:55:13 +0100 Subject: [XML-SIG] Problem with xmlproc In-Reply-To: <43A96550.10305@free.fr> References: <43A95B06.7030104@gmail.com> <43A96550.10305@free.fr> Message-ID: <7d14f3a90512210655s34807b3ag@mail.gmail.com> thanks!!! i have understood the u operator. One question: WHY 2005/12/21, Werner F. Bruhin : > > Marco Meoni wrote: > > > Hello everybody. > > I have a problem with xmlproc. > > If I have a dtd in the direcory of this file, the parser send me to > > video the elelments and the attirbutes of the dtd. > > this is the video output: > > > > sbaush at sbaush:/media/hda5/Universita'/Tesi/Manager$ python parser2.py > > ELEMENTO: meshap-manager - (u'|', [(u'iptables-request', ''), > > (u'iptables-response', ''), (u'routing-table-request', ''), > > (u'routing-table-response', '')], '') > > ELEMENTO: iptables-request - (u'|', [(u'policy', ''), (u'list', ''), > > (u'flush', ''), (u'append', ''), (u'delete', '')], '') > > ELEMENTO: policy - EMPTY > > ATTRIBUTO: chain - Elemento: policy - Contenuto: [u'INPUT', u'OUTPUT', > > u'FORWARD'] #REQUIRED - Default:[None] > > ATTRIBUTO: target - Elemento: policy - Contenuto: [u'DROP', u'ACCEPT', > > u'REJECT'] #REQUIRED - Default:[None] > > ELEMENTO: list - EMPTY > > ATTRIBUTO: chain - Elemento: list - Contenuto: [u'INPUT', u'OUTPUT', > > u'FORWARD'] #IMPLIED - Default:[None] > > ELEMENTO: flush - EMPTY > > ATTRIBUTO: chain - Elemento: flush - Contenuto: [u'INPUT', u'OUTPUT', > > u'FORWARD'] #IMPLIED - Default:[None] > > ELEMENTO: append - (u',', [(u'protocol', u'?'), (u'source', u'?'), > > (u'destination', u'?'), (u'jump', '')], '') > > ATTRIBUTO: chain - Elemento: append - Contenuto: [u'INPUT', u'OUTPUT', > > u'FORWARD'] #REQUIRED - Default:[None] > > ELEMENTO: protocol - EMPTY > > ATTRIBUTO: type - Elemento: protocol - Contenuto: [u'tcp', u'udp', > > u'icmp'] #REQUIRED - Default:[None] > > ELEMENTO: source - EMPTY > > ATTRIBUTO: address - Elemento: source - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ELEMENTO: destination - EMPTY > > ATTRIBUTO: address - Elemento: destination - Contenuto: CDATA > > #REQUIRED - Default:[None] > > ELEMENTO: jump - EMPTY > > ATTRIBUTO: option - Elemento: jump - Contenuto: [u'DROP', u'ACCEPT', > > u'REJECT'] #REQUIRED - Default:[None] > > ELEMENTO: delete - (u'|', [(u',', [(u'protocol', u'?'), (u'source', > > ''), (u'jump', '')], ''), (u'number', '')], '') > > ATTRIBUTO: chain - Elemento: delete - Contenuto: [u'INPUT', u'OUTPUT', > > u'FORWARD'] #REQUIRED - Default:[None] > > ELEMENTO: number - EMPTY > > ATTRIBUTO: line - Elemento: number - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ELEMENTO: iptables-response - (u'|', [(u'done', ''), (u'listtable', > > '')], '') > > ELEMENTO: done - EMPTY > > ATTRIBUTO: value - Elemento: done - Contenuto: [u'true', u'false'] > > #REQUIRED - Default:[None] > > ELEMENTO: listtable - ('', [(u'table', u'+')], '') > > ELEMENTO: table - ('', [(u'rule', u'*')], '') > > ATTRIBUTO: chain - Elemento: table - Contenuto: [u'INPUT', u'OUTPUT', > > u'FORWARD'] #REQUIRED - Default:[None] > > ATTRIBUTO: policy - Elemento: table - Contenuto: [u'ACCEPT', u'DROP', > > u'REJECT'] #REQUIRED - Default:[None] > > ELEMENTO: rule - EMPTY > > ATTRIBUTO: number - Elemento: rule - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: target - Elemento: rule - Contenuto: [u'ACCEPT', u'DROP', > > u'REJECT'] #REQUIRED - Default:[None] > > ATTRIBUTO: protocol - Elemento: rule - Contenuto: [u'tcp', u'udp', > > u'icmp'] #REQUIRED - Default:[None] > > ATTRIBUTO: option - Elemento: rule - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: source - Elemento: rule - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: destination - Elemento: rule - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: description - Elemento: rule - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ELEMENTO: routing-table-request - EMPTY > > ELEMENTO: routing-table-response - ('', [(u'route', '')], '') > > ELEMENTO: route - ('', [(u'row', u'*')], '') > > ELEMENTO: row - EMPTY > > ATTRIBUTO: interface - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: destination - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: gateway - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: flags - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: refcnt - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: use - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: metric - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: mask - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: mtu - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: window - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > ATTRIBUTO: irtt - Elemento: row - Contenuto: CDATA #REQUIRED - > > Default:[None] > > > > It works perfectly. The question is: what is the "u" in the elements?? > > Thanks to all. > > below there is my code. > > The 'u' creates a Unicode object from the string in quotes. > > x = u'sometext' > >>> x > u'sometext' > >>> type(x) > > > You could also use unicode() if you need to define an encoding or want > to define what happens on error. > > y = unicode('sometext', 'iso-8859-1') > >>> y > u'sometext' > >>> type(y) > > > See you > Werner > > > > > > > from xml.parsers.xmlproc import xmlproc > > import sys > > > > class DTDReporter(xmlproc.DTDConsumer): > > "A simple class that just prints out the events it receives." > > > > def __init__(self,parser,out=sys.stdout): > > xmlproc.DTDConsumer.__init__(self,parser) > > self.out=out > > > > def new_attribute(self,elem,attr,a_type,a_decl,a_def): > > self.out.write("ATTRIBUTO: %s - Elemento: %s - Contenuto: %s > > %s - Default:[%s]\n" % (attr,elem,a_type,a_decl,a_def)) > > > > def new_element_type(self,elem_name,elem_cont): > > self.out.write("ELEMENTO: %s - %s\n" % (elem_name,elem_cont)) > > > > # --- Client methods > > > > def close(self): > > self.out.close() > > > > # --- Main program > > > > if __name__ == '__main__': > > t=xmlproc.DTDParser() > > t.set_dtd_consumer(DTDReporter(t)) > > #Si sceglie se parsare il file messo come input da tastiera o se > > il file sul disco. Si puo' dare anche il percorso di localizzazione > > del file. > > #t.parse_resource(sys.argv[1]) > > t.parse_resource("MeshAP2.dtd") > > > > > > > > -- > > > > mail address: meonimarco at gmail.com > > web site: www.marcomeoni.net > > > >------------------------------------------------------------------------ > > > >_______________________________________________ > >XML-SIG maillist - XML-SIG at python.org > >http://mail.python.org/mailman/listinfo/xml-sig > > > > > > > -- Mail address: meonimarco at gmail.com Web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051221/5f8fbf2e/attachment.htm From meonimarco at gmail.com Wed Dec 21 15:56:54 2005 From: meonimarco at gmail.com (Marco Meoni) Date: Wed, 21 Dec 2005 15:56:54 +0100 Subject: [XML-SIG] Problem with xmlproc In-Reply-To: <7d14f3a90512210655s34807b3ag@mail.gmail.com> References: <43A95B06.7030104@gmail.com> <43A96550.10305@free.fr> <7d14f3a90512210655s34807b3ag@mail.gmail.com> Message-ID: <7d14f3a90512210656g27574c54j@mail.gmail.com> thanks!!! i have understood the u operator. One question: 1)WHY MY CODE PUT THE u OPERATOR IN THE VIDEO OUTPUT? 2005/12/21, Marco Meoni : > > thanks!!! > i have understood the u operator. > One question: > WHY > > 2005/12/21, Werner F. Bruhin : > > > > Marco Meoni wrote: > > > > > Hello everybody. > > > I have a problem with xmlproc. > > > If I have a dtd in the direcory of this file, the parser send me to > > > video the elelments and the attirbutes of the dtd. > > > this is the video output: > > > > > > sbaush at sbaush:/media/hda5/Universita'/Tesi/Manager$ python parser2.py > > > ELEMENTO: meshap-manager - (u'|', [(u'iptables-request', ''), > > > (u'iptables-response', ''), (u'routing-table-request', ''), > > > (u'routing-table-response', '')], '') > > > ELEMENTO: iptables-request - (u'|', [(u'policy', ''), (u'list', ''), > > > (u'flush', ''), (u'append', ''), (u'delete', '')], '') > > > ELEMENTO: policy - EMPTY > > > ATTRIBUTO: chain - Elemento: policy - Contenuto: [u'INPUT', u'OUTPUT', > > > u'FORWARD'] #REQUIRED - Default:[None] > > > ATTRIBUTO: target - Elemento: policy - Contenuto: [u'DROP', u'ACCEPT', > > > u'REJECT'] #REQUIRED - Default:[None] > > > ELEMENTO: list - EMPTY > > > ATTRIBUTO: chain - Elemento: list - Contenuto: [u'INPUT', u'OUTPUT', > > > u'FORWARD'] #IMPLIED - Default:[None] > > > ELEMENTO: flush - EMPTY > > > ATTRIBUTO: chain - Elemento: flush - Contenuto: [u'INPUT', u'OUTPUT', > > > u'FORWARD'] #IMPLIED - Default:[None] > > > ELEMENTO: append - (u',', [(u'protocol', u'?'), (u'source', u'?'), > > > (u'destination', u'?'), (u'jump', '')], '') > > > ATTRIBUTO: chain - Elemento: append - Contenuto: [u'INPUT', u'OUTPUT', > > > u'FORWARD'] #REQUIRED - Default:[None] > > > ELEMENTO: protocol - EMPTY > > > ATTRIBUTO: type - Elemento: protocol - Contenuto: [u'tcp', u'udp', > > > u'icmp'] #REQUIRED - Default:[None] > > > ELEMENTO: source - EMPTY > > > ATTRIBUTO: address - Elemento: source - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ELEMENTO: destination - EMPTY > > > ATTRIBUTO: address - Elemento: destination - Contenuto: CDATA > > > #REQUIRED - Default:[None] > > > ELEMENTO: jump - EMPTY > > > ATTRIBUTO: option - Elemento: jump - Contenuto: [u'DROP', u'ACCEPT', > > > u'REJECT'] #REQUIRED - Default:[None] > > > ELEMENTO: delete - (u'|', [(u',', [(u'protocol', u'?'), (u'source', > > > ''), (u'jump', '')], ''), (u'number', '')], '') > > > ATTRIBUTO: chain - Elemento: delete - Contenuto: [u'INPUT', u'OUTPUT', > > > u'FORWARD'] #REQUIRED - Default:[None] > > > ELEMENTO: number - EMPTY > > > ATTRIBUTO: line - Elemento: number - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ELEMENTO: iptables-response - (u'|', [(u'done', ''), (u'listtable', > > > '')], '') > > > ELEMENTO: done - EMPTY > > > ATTRIBUTO: value - Elemento: done - Contenuto: [u'true', u'false'] > > > #REQUIRED - Default:[None] > > > ELEMENTO: listtable - ('', [(u'table', u'+')], '') > > > ELEMENTO: table - ('', [(u'rule', u'*')], '') > > > ATTRIBUTO: chain - Elemento: table - Contenuto: [u'INPUT', u'OUTPUT', > > > u'FORWARD'] #REQUIRED - Default:[None] > > > ATTRIBUTO: policy - Elemento: table - Contenuto: [u'ACCEPT', u'DROP', > > > u'REJECT'] #REQUIRED - Default:[None] > > > ELEMENTO: rule - EMPTY > > > ATTRIBUTO: number - Elemento: rule - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: target - Elemento: rule - Contenuto: [u'ACCEPT', u'DROP', > > > u'REJECT'] #REQUIRED - Default:[None] > > > ATTRIBUTO: protocol - Elemento: rule - Contenuto: [u'tcp', u'udp', > > > u'icmp'] #REQUIRED - Default:[None] > > > ATTRIBUTO: option - Elemento: rule - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: source - Elemento: rule - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: destination - Elemento: rule - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: description - Elemento: rule - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ELEMENTO: routing-table-request - EMPTY > > > ELEMENTO: routing-table-response - ('', [(u'route', '')], '') > > > ELEMENTO: route - ('', [(u'row', u'*')], '') > > > ELEMENTO: row - EMPTY > > > ATTRIBUTO: interface - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: destination - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: gateway - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: flags - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: refcnt - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: use - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: metric - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: mask - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: mtu - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: window - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > ATTRIBUTO: irtt - Elemento: row - Contenuto: CDATA #REQUIRED - > > > Default:[None] > > > > > > It works perfectly. The question is: what is the "u" in the elements?? > > > Thanks to all. > > > below there is my code. > > > > The 'u' creates a Unicode object from the string in quotes. > > > > x = u'sometext' > > >>> x > > u'sometext' > > >>> type(x) > > > > > > You could also use unicode() if you need to define an encoding or want > > to define what happens on error. > > > > y = unicode('sometext', 'iso-8859-1') > > >>> y > > u'sometext' > > >>> type(y) > > > > > > See you > > Werner > > > > > > > > > > > from xml.parsers.xmlproc import xmlproc > > > import sys > > > > > > class DTDReporter( xmlproc.DTDConsumer): > > > "A simple class that just prints out the events it receives." > > > > > > def __init__(self,parser,out=sys.stdout): > > > xmlproc.DTDConsumer.__init__(self,parser) > > > self.out=out > > > > > > def new_attribute(self,elem,attr,a_type,a_decl,a_def): > > > self.out.write("ATTRIBUTO: %s - Elemento: %s - Contenuto: %s > > > %s - Default:[%s]\n" % (attr,elem,a_type,a_decl,a_def)) > > > > > > def new_element_type(self,elem_name,elem_cont): > > > self.out.write("ELEMENTO: %s - %s\n" % (elem_name,elem_cont)) > > > > > > # --- Client methods > > > > > > def close(self): > > > self.out.close() > > > > > > # --- Main program > > > > > > if __name__ == '__main__': > > > t=xmlproc.DTDParser() > > > t.set_dtd_consumer(DTDReporter(t)) > > > #Si sceglie se parsare il file messo come input da tastiera o se > > > il file sul disco. Si puo' dare anche il percorso di localizzazione > > > del file. > > > #t.parse_resource(sys.argv[1]) > > > t.parse_resource("MeshAP2.dtd") > > > > > > > > > > > > -- > > > > > > mail address: meonimarco at gmail.com > > > web site: www.marcomeoni.net > > > > > > > >------------------------------------------------------------------------ > > > > > >_______________________________________________ > > >XML-SIG maillist - XML-SIG at python.org > > >http://mail.python.org/mailman/listinfo/xml-sig > > > > > > > > > > > > > > > -- > Mail address: meonimarco at gmail.com > Web site: www.marcomeoni.net -- Mail address: meonimarco at gmail.com Web site: www.marcomeoni.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051221/97f3aa01/attachment.html From mike at skew.org Wed Dec 21 20:13:15 2005 From: mike at skew.org (Mike Brown) Date: Wed, 21 Dec 2005 12:13:15 -0700 (MST) Subject: [XML-SIG] Problem with xmlproc In-Reply-To: <7d14f3a90512210656g27574c54j@mail.gmail.com> Message-ID: <200512211913.jBLJDFOI021729@chilled.skew.org> Marco Meoni wrote: > thanks!!! > i have understood the u operator. > One question: > 1)WHY MY CODE PUT THE u OPERATOR IN THE VIDEO OUTPUT? Fundamentally, an XML document is a sequence of Unicode characters, independent of any encoding. Therefore, when a the contents of a document or DTD are being read, it is often very convenient for APIs to use Python's unicode type as a means of reporting what is in the document. That's why the unicode objects exist for you. (Although, I would not count on xmlproc to be consistent about returning unicode). As for why you see them printed as u'...', that's because you are "print"-ing tuples and lists that contain unicode objects. If you instead print the unicode objects individually, rather than their containers, then the unicode strings will be encoded for you automatically to whatever Python thinks your screen can handle. >>> print [u'hello world', u'greetings'] [u'hello world', u'greetings'] >>> print u'hello world' hello world From mr_ankit_rastogi at yahoo.com Thu Dec 22 06:35:29 2005 From: mr_ankit_rastogi at yahoo.com (Ankit Rastogi) Date: Wed, 21 Dec 2005 21:35:29 -0800 (PST) Subject: [XML-SIG] Query: Schema package for python Message-ID: <20051222053529.19345.qmail@web54101.mail.yahoo.com> Hi All, Is there any independent package availaible for schema validation in python which I can use with pyxml or 4suite? The platform I am using is Unix. -- Regards Ankit Rastogi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051221/c7af84be/attachment.html From ht at inf.ed.ac.uk Thu Dec 22 12:26:41 2005 From: ht at inf.ed.ac.uk (Henry S. Thompson) Date: Thu, 22 Dec 2005 11:26:41 +0000 Subject: [XML-SIG] Query: Schema package for python In-Reply-To: <20051222053529.19345.qmail@web54101.mail.yahoo.com> (Ankit Rastogi's message of "Wed, 21 Dec 2005 21:35:29 -0800 (PST)") References: <20051222053529.19345.qmail@web54101.mail.yahoo.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 XSV [1] is an open-source Python W3C XML Schema validator. ht [1] http://www.ltg.ed.ac.uk/~ht/xsv-status.html - -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh Half-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht at inf.ed.ac.uk URL: http://www.ltg.ed.ac.uk/~ht/ [mail really from me _always_ has this .sig -- mail without it is forged spam] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQFDqo1xkjnJixAXWBoRArekAJ93do98Y1DbQYM7YCpH5Rw9o2Qn9ACfRpAw rbaPkmyEnSdJYx11NBtgBSA= =LnIQ -----END PGP SIGNATURE----- From mike at skew.org Fri Dec 23 03:41:19 2005 From: mike at skew.org (Mike Brown) Date: Thu, 22 Dec 2005 19:41:19 -0700 (MST) Subject: [XML-SIG] Query: Schema package for python In-Reply-To: <20051222053529.19345.qmail@web54101.mail.yahoo.com> Message-ID: <200512230241.jBN2fKkV092595@chilled.skew.org> Ankit Rastogi wrote: > Hi All, > Is there any independent package availaible for schema validation in python which I can use with > pyxml or 4suite? The platform I am using is Unix. Which kind of schema? W3C XML Schema? RELAX NG? I assume not DTD since PyXML has xmlproc and 4Suite XML 1.0b3 has built-in validation. From mr_ankit_rastogi at yahoo.com Fri Dec 23 13:52:52 2005 From: mr_ankit_rastogi at yahoo.com (Ankit Rastogi) Date: Fri, 23 Dec 2005 04:52:52 -0800 (PST) Subject: [XML-SIG] Query: Schema package for python In-Reply-To: <200512230241.jBN2fKkV092595@chilled.skew.org> Message-ID: <20051223125252.99952.qmail@web54110.mail.yahoo.com> I am looking for W3C schema package which can work with pyxml or any other package which is pythonic. and which works on unix platform. Mike Brown wrote: Ankit Rastogi wrote: > Hi All, > Is there any independent package availaible for schema validation in python which I can use with > pyxml or 4suite? The platform I am using is Unix. Which kind of schema? W3C XML Schema? RELAX NG? I assume not DTD since PyXML has xmlproc and 4Suite XML 1.0b3 has built-in validation. --------------------------------- Yahoo! Photos Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051223/3afc017a/attachment.htm From fredrik at pythonware.com Fri Dec 23 14:06:29 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Dec 2005 14:06:29 +0100 Subject: [XML-SIG] Query: Schema package for python References: <200512230241.jBN2fKkV092595@chilled.skew.org> <20051223125252.99952.qmail@web54110.mail.yahoo.com> Message-ID: Ankit Rastogi wrote: > I am looking for W3C schema package which can work with > pyxml or any other package which is pythonic. and which > works on unix platform. I'm not sure references to recent W3C standards, pyxml, and pythonic can really be used in a sentence without negations, but here's another schema implementation that you might find interesting: http://www.leuthe.homepage.t-online.de/minixsv/minixsv_overview.html From michael.s.gilbert at gmail.com Fri Dec 23 21:22:53 2005 From: michael.s.gilbert at gmail.com (Michael Gilbert) Date: Fri, 23 Dec 2005 15:22:53 -0500 Subject: [XML-SIG] best way to parse a simple xml string? Message-ID: <8e2a98be0512231222t787ffdd0r3097b5e55045ed99@mail.gmail.com> Hello all, I appologize for positing such a trivial question, but I am having trouble decrypting the python XML documentation. I am parsing a relatively simple strings, each of which consist of a single xml tag. For example: What is the best way to determine only the user's hobby? pulldom, sax, something else? is there guidance on using xml tools for single tags? This is what I have so far from xml.dom.pulldom import * a = parseString('') I've tried getEvent() and expandNode(), but am not getting any closer to accessing the content in the string. What are your suggestions on the best way to retrieve the hobby? Thank you very much any help. Hope you all have a happy holiday, Mike Gilbert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051223/053a1c68/attachment.html From michael.s.gilbert at gmail.com Fri Dec 23 21:53:33 2005 From: michael.s.gilbert at gmail.com (Michael Gilbert) Date: Fri, 23 Dec 2005 15:53:33 -0500 Subject: [XML-SIG] best way to parse a simple xml string? In-Reply-To: <8e2a98be0512231222t787ffdd0r3097b5e55045ed99@mail.gmail.com> References: <8e2a98be0512231222t787ffdd0r3097b5e55045ed99@mail.gmail.com> Message-ID: <8e2a98be0512231253w7fe81d6dk8affe1d6eb86270c@mail.gmail.com> Hello again, I think I found a way to accomplish my goal with minidom. Is this the most direct solution for my goal, or is there a simpler way? Thanks again. import xml.dom.minidom document = '' dom = xml.dom.minidom.parseString(document) t = dom.getElementsByTagName("user")[0] if t.hasAttributes(): for cnt in range(0, t.attributes.length): if t.attributes.item(cnt).nodeName == "hobby": print 'hobby = ' + t.attributes.item(cnt).nodeValue On 12/23/05, Michael Gilbert wrote: > > Hello all, > > I appologize for positing such a trivial question, but I am having trouble > decrypting the python XML documentation. > > I am parsing a relatively simple strings, each of which consist of a > single xml tag. For example: > > hobby="stealing bread" /> > > What is the best way to determine only the user's hobby? pulldom, sax, > something else? is there guidance on using xml tools for single tags? This > is what I have so far > > from xml.dom.pulldom import * > a = parseString(' children="1" hobby="stealing bread" />') > > I've tried getEvent() and expandNode(), but am not getting any closer to > accessing the content in the string. What are your suggestions on the best > way to retrieve the hobby? Thank you very much any help. > > Hope you all have a happy holiday, > Mike Gilbert > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051223/ecd018a3/attachment.html From dkuhlman at cutter.rexx.com Sat Dec 24 06:27:25 2005 From: dkuhlman at cutter.rexx.com (Dave Kuhlman) Date: Fri, 23 Dec 2005 21:27:25 -0800 Subject: [XML-SIG] best way to parse a simple xml string? In-Reply-To: <8e2a98be0512231253w7fe81d6dk8affe1d6eb86270c@mail.gmail.com> References: <8e2a98be0512231222t787ffdd0r3097b5e55045ed99@mail.gmail.com> <8e2a98be0512231253w7fe81d6dk8affe1d6eb86270c@mail.gmail.com> Message-ID: <20051224052725.GA9033@cutter.rexx.com> On Fri, Dec 23, 2005 at 03:53:33PM -0500, Michael Gilbert wrote: > Hello again, > > I think I found a way to accomplish my goal with minidom. Is this the most > direct solution for my goal, or is there a simpler way? Thanks again. minidom is a good choice because it is part of the standard Python library. If you, or your users, are willing to install extra software, you may want to look at ElementTree and lxml: - ElementTree: http://effbot.org/zone/element-index.htm - lxml: http://codespeak.net/lxml/ They are DOM-like, but some consider it a better DOM. > > import xml.dom.minidom > > document = ' hobby="stealing bread" />' > > dom = xml.dom.minidom.parseString(document) > > t = dom.getElementsByTagName("user")[0] > > if t.hasAttributes(): > for cnt in range(0, t.attributes.length): > if t.attributes.item(cnt).nodeName == "hobby": > print 'hobby = ' + t.attributes.item(cnt).nodeValue Yes. But, there may be a slightly more direct way. minidom attributes are a NamedNodeMap which is a sort of dictionary-like object. So you can use indexing, for example, in your case, something like: t.attributes['hobby'] and also: if t.attributes.has_key('hobby'): val = t.attributes['hobby'] Use dir(t.attributes) to get a list of other methods. Dave [snip] -- Dave Kuhlman http://www.rexx.com/~dkuhlman From michael.s.gilbert at gmail.com Sat Dec 24 15:43:49 2005 From: michael.s.gilbert at gmail.com (Michael Gilbert) Date: Sat, 24 Dec 2005 09:43:49 -0500 Subject: [XML-SIG] best way to parse a simple xml string? In-Reply-To: <20051224052725.GA9033@cutter.rexx.com> References: <8e2a98be0512231222t787ffdd0r3097b5e55045ed99@mail.gmail.com> <8e2a98be0512231253w7fe81d6dk8affe1d6eb86270c@mail.gmail.com> <20051224052725.GA9033@cutter.rexx.com> Message-ID: <8e2a98be0512240643r77b93532u1cb634c011b8f7bc@mail.gmail.com> Thank you so much Dave, This is very helpful. Have a happy holiday. Mike On 12/24/05, Dave Kuhlman wrote: > > On Fri, Dec 23, 2005 at 03:53:33PM -0500, Michael Gilbert wrote: > > Hello again, > > > > I think I found a way to accomplish my goal with minidom. Is this the > most > > direct solution for my goal, or is there a simpler way? Thanks again. > > minidom is a good choice because it is part of the standard Python > library. If you, or your users, are willing to install extra > software, you may want to look at ElementTree and lxml: > > - ElementTree: http://effbot.org/zone/element-index.htm > > - lxml: http://codespeak.net/lxml/ > > They are DOM-like, but some consider it a better DOM. > > > > > import xml.dom.minidom > > > > document = ' children="1" > > hobby="stealing bread" />' > > > > dom = xml.dom.minidom.parseString(document) > > > > t = dom.getElementsByTagName("user")[0] > > > > if t.hasAttributes(): > > for cnt in range(0, t.attributes.length): > > if t.attributes.item(cnt).nodeName == "hobby": > > print 'hobby = ' + t.attributes.item(cnt).nodeValue > > Yes. But, there may be a slightly more direct way. minidom > attributes are a NamedNodeMap which is a sort of dictionary-like > object. So you can use indexing, for example, in your case, > something like: > > t.attributes['hobby'] > > and also: > > if t.attributes.has_key('hobby'): > val = t.attributes['hobby'] > > Use dir(t.attributes) to get a list of other methods. > > Dave > > [snip] > > -- > Dave Kuhlman > http://www.rexx.com/~dkuhlman > _______________________________________________ > XML-SIG maillist - XML-SIG at python.org > http://mail.python.org/mailman/listinfo/xml-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051224/5b027655/attachment.html From info-requests-admin at lists.clusterfs.com Mon Dec 26 14:33:12 2005 From: info-requests-admin at lists.clusterfs.com (info-requests-admin@lists.clusterfs.com) Date: Mon, 26 Dec 2005 08:33:12 -0500 Subject: [XML-SIG] Your message to info-requests awaits moderator approval Message-ID: <20051226133312.9744.89008.Mailman@lists.clusterfs.com> Your mail to 'info-requests' with the subject hi,_ive_a_new_mail_address Is being held until the list moderator can review it for approval. The reason it is being held: Message body is too big: 75466 bytes but there's a limit of 40 KB Either the message will get posted to the list, or you will receive notification of the moderator's decision. From mr_ankit_rastogi at yahoo.com Tue Dec 27 11:44:07 2005 From: mr_ankit_rastogi at yahoo.com (Ankit Rastogi) Date: Tue, 27 Dec 2005 02:44:07 -0800 (PST) Subject: [XML-SIG] LIBXML2DOM PROBLEM Message-ID: <20051227104407.64294.qmail@web54111.mail.yahoo.com> Hi All, I am using libxml2dom for DOM support in libxml2. There are some test examples in the package itself. but when I try to run those sample examples, I face following error: Traceback (most recent call last): File "namespaces.py", line 23, in ? document = libxml2dom.parse("test_ns.xml") File "/usr/lib/python2.2/site-packages/libxml2dom/__init__.py", line 472, in parse return parseFile(stream_or_string, html) File "/usr/lib/python2.2/site-packages/libxml2dom/__init__.py", line 484, in parseFile return Document(Node_parseFile(filename, html)) File "/usr/lib/python2.2/site-packages/libxml2dom/macrolib/macrolib.py", line 431, in parseFile libxml2mod.xmlCtxtUseOptions(context, XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NONET) AttributeError: 'module' object has no attribute 'xmlCtxtUseOptions' This error comes in all those parts where libxml2dom.parse() is called. Please let me know what the problem can be. and what is its solution. Where I am wrong? --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051227/2231bb67/attachment.html From mr_ankit_rastogi at yahoo.com Wed Dec 28 13:21:41 2005 From: mr_ankit_rastogi at yahoo.com (Ankit Rastogi) Date: Wed, 28 Dec 2005 04:21:41 -0800 (PST) Subject: [XML-SIG] problem installing libxml2dom on windows Message-ID: <20051228122141.66213.qmail@web54109.mail.yahoo.com> I had installed libxml2 for python (libxml2-python-2.6.22.win32-py2.4) on WINDOWS. For having dom support I am installing libxml2dom (0.3). My python version on win is 2.4 but when I give run the install as: python setup.py install I get following error: ---- Traceback (most recent call last): File "setup.py", line 5, in ? import libxml2dom File "C:\Python24\libxml2dom-0.3\libxml2dom\__init__.py", line 9, in ? from libxml2dom.macrolib import * File "C:\Python24\libxml2dom-0.3\libxml2dom\macrolib\__init__.py", line 9, in ? from libxml2dom.macrolib.macrolib import * File "C:\Python24\libxml2dom-0.3\libxml2dom\macrolib\macrolib.py", line 8, in ? import libxml2mod ImportError: No module named libxml2mod --- It cant find libxml2mod package. I suppose it installs with libxml2. Am I right? From where I will get this package for WINDOWS? Plz, tell me the site. I tried googling but it didnt give me any links for download. Can any one help. --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051228/e7101d9e/attachment.html From mr_ankit_rastogi at yahoo.com Wed Dec 28 15:05:19 2005 From: mr_ankit_rastogi at yahoo.com (Ankit Rastogi) Date: Wed, 28 Dec 2005 06:05:19 -0800 (PST) Subject: [XML-SIG] problem installing libxml_domlib on linux Message-ID: <20051228140519.33810.qmail@web54108.mail.yahoo.com> I am installing libxml_domlib(1.2a) on linux but when I build it it searches for includes of libxml2 in folder /usr/local/include/libxml2 but libxml2 have includes under /usr/include/libxml2. For this reason it gives me following error: -- gcc -DNDEBUG -O2 -g -pipe -march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC -I. -I/usr/local/include/libxml2 -I/usr/include/python2.2 -c libxml_domlib.c -o build/temp.linux-i686-2.2/libxml_domlib.o libxml_domlib.c:32:30: libxml/xmlmemory.h: No such file or directory libxml_domlib.c:33:27: libxml/parser.h: No such file or directory -- In makefile I changed the places for libs and given the correct path for includes of libxml2 under INCL_DIR instead of that its picking up /usr/local/include/libxml2 and searches headers there . the makefile(afer chages) I am using is following: --- PYTHON_DIR=/usr/include/python2.2/ INCL_DIRS=-I/usr/include/libxml2/ \ -I${PYTHON_DIR} CFLAGS=-c -g ${INCL_DIRS} -Wall -fPIC #LINKFLAGS=-shared -L/usr/local/lib/python2.1/config/ -lpython2.1 \ # -L/usr/local/lib -lxml2 -lz -lm -lz LINKFLAGS=-shared -L/usr/lib/python2.2/config/ -lpython2.2 \ -L/usr/lib -lxml2 -lm OBJS=libxml_domlib.o domlib_node.o domlib_doc.o \ domlib_ns.o domlib_attrs.o libxml_domlib.so: ${OBJS} gcc ${LINKFLAGS} ${OBJS} -o libxml_domlib.so libxml_domlib.o: libxml_domlib.c domlib_node.h gcc ${CFLAGS} libxml_domlib.c -o libxml_domlib.o domlib_node.o: domlib_node.c domlib_node.h gcc ${CFLAGS} domlib_node.c -o domlib_node.o domlib_doc.o: domlib_doc.c domlib_doc.h gcc ${CFLAGS} domlib_doc.c -o domlib_doc.o domlib_ns.o: domlib_ns.c domlib_ns.h gcc ${CFLAGS} domlib_ns.c -o domlib_ns.o domlib_attrs.o: domlib_attrs.c domlib_attrs.h gcc ${CFLAGS} domlib_attrs.c -o domlib_attrs.o clean: rm -f ${OBJS} libxml_domlib.so --- How can I override this behaviour of inclusions of header? and Also is there any version of libxml_domlib availaible for windows. ? Can anyone help --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051228/7d36ed41/attachment.html From goodger at python.org Wed Dec 28 16:12:19 2005 From: goodger at python.org (David Goodger) Date: Wed, 28 Dec 2005 10:12:19 -0500 Subject: [XML-SIG] PyCon TX 2006: Early-bird registration ends Dec. 31! Message-ID: <43B2AB53.1000409@python.org> Early bird registration for PyCon TX 2006 ends on December 31st, so there are only a few days LEFT. To register, please visit: http://us.pycon.org/TX2006/Registration You can still register after Dec. 31st, but the cost will go up by US$65 (US$25 for students). This year PyCon will feature a day of tutorials before the three days of regular presentations. Course outlines for all the tutorials have been posted; see http://wiki.python.org/moin/PyCon2006/Tutorials All of the PyCon tutorials are still open for new registrations, but space is limited, and we suspect they'll all be filled up by the time early-bird registration closes. Don't forget to book your hotel room, too. PyCon TX 2006 is being held at a Dallas/Addison hotel, and we have negotiated a special low rate: http://us.pycon.org/Addison/Hotels We hope to see you in Texas! -- David Goodger (on behalf of A.M. Kuchling, Chair, PyCon 2006) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 249 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/xml-sig/attachments/20051228/5fef451d/signature.pgp From mr_ankit_rastogi at yahoo.com Wed Dec 28 17:02:37 2005 From: mr_ankit_rastogi at yahoo.com (Ankit Rastogi) Date: Wed, 28 Dec 2005 08:02:37 -0800 (PST) Subject: [XML-SIG] parsing CDATA section Message-ID: <20051228160237.26673.qmail@web54115.mail.yahoo.com> I am having problem with parsing CDATA section. I am using PyXml and minidom for parsing the xml document. My motive is to get the data back in the same format in one string as it is writen in xml file. Here is the sample: -- -- put when I print all its childs using: --- print StChg.childNodes #StChg. is instance to element -- It gives following output -- [, , , , , , , , , ] -- The output Shows it is text node but we had declare it as CDATA_SECTION_NODE. and also the output is not desired ( format lost and some data is lost), Why its happening. What I have to do to get the same output as in xml with the format and indentation. Please,correct me, where I am wrong --------------------------------- Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/xml-sig/attachments/20051228/8fbb063e/attachment.html From dieter at handshake.de Thu Dec 29 19:22:05 2005 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 29 Dec 2005 19:22:05 +0100 Subject: [XML-SIG] parsing CDATA section In-Reply-To: <20051228160237.26673.qmail@web54115.mail.yahoo.com> References: <20051228160237.26673.qmail@web54115.mail.yahoo.com> Message-ID: <17332.10573.986195.988935@gargle.gargle.HOWL> Ankit Rastogi wrote at 2005-12-28 08:02 -0800: >I am having problem with parsing CDATA section. I am using PyXml and minidom for parsing the xml document. > My motive is to get the data back in the same format in one string as it is writen in xml file. Here is the sample: > -- > > check.. its cdata section > > all data is printed in it s format > ]]> > > -- > put when I print all its childs using: > --- > print StChg.childNodes #StChg. is instance to element > -- > It gives following output > -- > [, , , , , , , , , ] >-- You might be interested in the "normalize" DOM method: it combined adjacent text nodes into a single one. -- Dieter From mike at skew.org Fri Dec 30 01:25:10 2005 From: mike at skew.org (Mike Brown) Date: Thu, 29 Dec 2005 17:25:10 -0700 (MST) Subject: [XML-SIG] parsing CDATA section In-Reply-To: <20051228160237.26673.qmail@web54115.mail.yahoo.com> Message-ID: <200512300025.jBU0PAq0082591@chilled.skew.org> Ankit Rastogi wrote: > I am having problem with parsing CDATA section. I am using PyXml and minidom for parsing the xml document. > My motive is to get the data back in the same format in one string as it is writen in xml file. Here is the sample: > -- > > check.. its cdata section > > all data is printed in it s format > ]]> > > -- > put when I print all its childs using: > --- > print StChg.childNodes #StChg. is instance to element > -- > It gives following output > -- > [, , , , , , , , , ] > -- > > The output Shows it is text node but we had declare it as CDATA_SECTION_NODE. > > and also the output is not desired ( format lost and some data is lost), > > Why its happening. What I have to do to get the same output as in xml with the format and indentation. > > Please,correct me, where I am wrong In XML, you have the logical constructs: elements, attributes, character data, processing instructions, and comments. You use markup to represent these constructs. And you are currently using the DOM API to access an abstract representation of them -- an implicit tree of nodes. At the markup level, a span of character data can be written using either (1) literal characters, numeric character references, and entity references, or (2) a CDATA section, consisting of literal characters only, bounded by start and end markers. There is no semantic difference between the two ways of writing character data; it is just two different ways of writing the same thing. Thus "1 & 2 are < 3" in regular markup is exactly the same as "1 & 2 are < 3" in a CDATA section. It is common for a parser to report each span of character data separately. It may say "this character data was written using a CDATA section" and "this character data was written with regular markup"; or it may just say "I saw this character data, and then I saw this other character data". It is also possible that character and entity references in the markup will be treated as separate spans of character data. Very long spans might be split as well. Consequently, in both the SAX and DOM APIs, these separate reports from the parser *may* manifest as separate, subsequent 'characters' events (in SAX) or as separate Text nodes (in DOM). You must be prepared to see them in chunks. You must also realize that it is not incorrect to see CDATA sections as Text nodes in an implementation that only supports the Core Interfaces of DOM. DOM does have a CDATASection node, which is a subclass of Text, but it is only in the Extended Interfaces, which are optional. So if an implementation chooses to support DOM's Extended Interfaces, then CDATA will manifest as CDATASection instead of Text. CDATASection nodes are in fact supported in newer versions of minidom, despite the docs at http://python.org/doc/2.4.2/lib/minidom-and-dom.html which say otherwise. These nodes and some of the other extended interfaces blur the distinction between lexical markup and logical constructs that the markup is intended to represent, so they actually make things more difficult for users, typically, which is why they're optional. As Dieter Maurer pointed out, you can merge adjacent Text nodes by calling the normalize() method on any ancestor of the nodes. However, by design, this only works on Text nodes, not CDATASection nodes, as per DOM requirements. Python 2.2.3: >>> from xml.dom.minidom import getDOMImplementation, parseString >>> impl = getDOMImplementation() >>> impl.hasFeature('Core', '2.0') # core interfaces? 1 >>> impl.hasFeature('XML', '2.0') # extended interfaces? 0 >>> doc = parseString('1 & 2 are < 3 ... ') >>> doc.childNodes[0].childNodes [, , , , , ] >>> doc.normalize() >>> doc.childNodes[0].childNodes [] >>> doc.childNodes[0].childNodes[0].data u'1 & 2 are < 3 ... 1 & 2 are < 3' Python 2.4.2: >>> from xml.dom.minidom import getDOMImplementation, parseString >>> impl = getDOMImplementation() >>> from xml.dom.minidom import parseString >>> impl.hasFeature('Core', '2.0') # core interfaces? True >>> impl.hasFeature('XML', '2.0') # extended interfaces? True >>> doc = parseString('1 & 2 are < 3 ... ') >>> doc.childNodes[0].childNodes [, ] >>> doc.normalize() >>> doc.childNodes[0].childNodes [, ] >>> doc.childNodes[0].childNodes[0].data u'1 & 2 are < 3 ... ' >>> doc.childNodes[0].childNodes[1].data u'1 & 2 are < 3' If you need to merge adjacent CDATASection nodes and/or mixed Text and CDATASection nodes, there are no functions built-in to do that. You'll have to roll your own. There's no way to disable the creation of CDATASection nodes in minidom. Anyway, you should not expect to be able to precisely reproduce or even know exactly what was in the lexical markup in your original, unparsed document when you run it through a parser, and especially not after you access the parser's reports through a relatively abstract API like DOM or SAX or the XPath tree model. You can produce XML that *means* the same thing as the original, but you're not going to get XML That *looks* exactly like the original. If you expect to do that, then you shouldn't be running your XML through a real XML parser at all. Mike