Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20342 > unrolled thread

XSLT to Python script conversion?

Started byMatej Cepl <mcepl@redhat.com>
First post2012-02-13 12:20 +0100
Last post2012-02-17 16:11 -0500
Articles 8 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  XSLT to Python script conversion? Matej Cepl <mcepl@redhat.com> - 2012-02-13 12:20 +0100
    Re: XSLT to Python script conversion? Stefan Behnel <stefan_ml@behnel.de> - 2012-02-13 14:34 +0100
    Re: XSLT to Python script conversion? "Mike C. Fletcher" <mcfletch@vrplumber.com> - 2012-02-13 11:28 -0500
    Re: XSLT to Python script conversion? Tim Arnold <Tim.Arnold@sas.com> - 2012-02-15 12:48 -0500
      Re: XSLT to Python script conversion? Matej Cepl <mcepl@redhat.com> - 2012-02-16 18:17 +0100
        Re: XSLT to Python script conversion? Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-02-17 15:37 -0500
          Re: XSLT to Python script conversion? Stefan Behnel <stefan_ml@behnel.de> - 2012-02-17 21:53 +0100
            Re: XSLT to Python script conversion? Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-02-17 16:11 -0500

#20342 — XSLT to Python script conversion?

FromMatej Cepl <mcepl@redhat.com>
Date2012-02-13 12:20 +0100
SubjectXSLT to Python script conversion?
Message-ID<jharfo$1rij$1@ns.felk.cvut.cz>
Hi,

I am getting more and more discouraged from using XSLT for a 
transformation from one XML scheme to another one. Does anybody could 
share any experience with porting moderately complicated XSLT stylesheet 
(https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) 
into a Python script using ElementTree's interparse or perhaps xml.sax?

Any tools for this? Speed differences (currently I am using xsltproc)? 
Any thoughts?

Thank you,

Matěj

[toc] | [next] | [standalone]


#20344

FromStefan Behnel <stefan_ml@behnel.de>
Date2012-02-13 14:34 +0100
Message-ID<mailman.5759.1329140063.27778.python-list@python.org>
In reply to#20342
Matej Cepl, 13.02.2012 12:20:
> I am getting more and more discouraged from using XSLT for a transformation
> from one XML scheme to another one.

Could you explain what it is that discourages you about it? That would
allow us to come up with better alternatives for your specific problem.


> Does anybody could share any experience
> with porting moderately complicated XSLT stylesheet
> (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl)
> into a Python script using ElementTree's interparse or perhaps xml.sax?
> 
> Any tools for this? Speed differences (currently I am using xsltproc)? Any
> thoughts?

You could try switching to lxml. It would at least allow you to do a part
of the processing in Python and only use XSLT when it seems more
appropriate and/or easier.

Stefan

[toc] | [prev] | [next] | [standalone]


#20350

From"Mike C. Fletcher" <mcfletch@vrplumber.com>
Date2012-02-13 11:28 -0500
Message-ID<mailman.5763.1329150904.27778.python-list@python.org>
In reply to#20342
On 12-02-13 06:20 AM, Matej Cepl wrote:
> Hi,
>
> I am getting more and more discouraged from using XSLT for a 
> transformation from one XML scheme to another one. Does anybody could 
> share any experience with porting moderately complicated XSLT 
> stylesheet 
> (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) 
> into a Python script using ElementTree's interparse or perhaps xml.sax?
>
> Any tools for this? Speed differences (currently I am using xsltproc)? 
> Any thoughts?
>
> Thank you,
>
> Matěj
I wound up rewriting the Docbook to XSL transformation for PyOpenGL's 
docs in Python using lxml.etree and Kid (now reworked to use Genshi).  
However, that was a fairly direct translation, it has only a handful of 
strategies for transforming nodes from docbook to xhtml.  That said, it 
took our processing time down from 
so-long-I-just-didn't-want-to-work-on-the-docs down to 
regenerate-whenever-I-make-a-trivial-change.

http://bazaar.launchpad.net/~mcfletch/pyopengl/directdocs/files 
<http://bazaar.launchpad.net/%7Emcfletch/pyopengl/directdocs/files>

Is the repository where the project lives.  It *also* does a lot of 
other processing, but the generate.py, model.py and 
templates/section.kid files are all you need to look at to understand 
the docbook processing.

HTH,
Mike

-- 
________________________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://www.vrplumber.com
   http://blog.vrplumber.com

[toc] | [prev] | [next] | [standalone]


#20503

FromTim Arnold <Tim.Arnold@sas.com>
Date2012-02-15 12:48 -0500
Message-ID<jhgr4t$lt9$1@foggy.unx.sas.com>
In reply to#20342
On 2/13/2012 6:20 AM, Matej Cepl wrote:
> Hi,
>
> I am getting more and more discouraged from using XSLT for a
> transformation from one XML scheme to another one. Does anybody could
> share any experience with porting moderately complicated XSLT stylesheet
> (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl)
> into a Python script using ElementTree's interparse or perhaps xml.sax?
>
> Any tools for this? Speed differences (currently I am using xsltproc)?
> Any thoughts?
>
> Thank you,
>
> Matěj

Just a note to encourage you to stick with XSLT. I also use lxml for 
creating and postprocessing my DocBook documents and it is great.  But I 
use the DocBook XSL stylesheets to convert to html; if you're like me, 
you got discouraged at the strangeness of the XSLT language.

I'm no expert with it by any means, but I'm amazed at some of the things 
it does. It is a great tool to add to your programming toolbox.

Also, I used xsltproc for a while but bogged down in processing time. 
Now I use SAXON which is much faster for my documents.

Good luck,
--Tim

[toc] | [prev] | [next] | [standalone]


#20519

FromMatej Cepl <mcepl@redhat.com>
Date2012-02-16 18:17 +0100
Message-ID<jhjdgj$1r0q$1@ns.felk.cvut.cz>
In reply to#20503
On 15.2.2012 18:48, Tim Arnold wrote:
> Just a note to encourage you to stick with XSLT. I also use lxml for
> creating and postprocessing my DocBook documents and it is great. But I
> use the DocBook XSL stylesheets to convert to html; if you're like me,
> you got discouraged at the strangeness of the XSLT language.

No, the strangness is not that bad (well, it is bad ... almost anything 
feels bad comparing to Python, to be honest, but not the reason I would 
give up; after all I spent couple of years with Javascript).

The terrible debugging is one thing, and even worse, I just still cannot 
get over rules around spaces: whitespace just jumps at me randomly in 
random places and is erased in others.

Matěj

[toc] | [prev] | [next] | [standalone]


#20570

FromRoss Ridge <rridge@csclub.uwaterloo.ca>
Date2012-02-17 15:37 -0500
Message-ID<jhmdr5$8rb$1@rumours.uwaterloo.ca>
In reply to#20519
Matej Cepl  <mcepl@redhat.com> wrote:
>No, the strangness is not that bad (well, it is bad ... almost anything 
>feels bad comparing to Python, to be honest, but not the reason I would 
>give up; after all I spent couple of years with Javascript).

The XSLT language is one of the worst misuses of XML, which puts it way
beyond bad.

>The terrible debugging is one thing, and even worse, I just still cannot 
>get over rules around spaces: whitespace just jumps at me randomly in 
>random places and is erased in others.

I use explicit <xsl:text> nodes exclusively to avoid this problem.

				Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#20571

FromStefan Behnel <stefan_ml@behnel.de>
Date2012-02-17 21:53 +0100
Message-ID<mailman.5926.1329512047.27778.python-list@python.org>
In reply to#20570
Ross Ridge, 17.02.2012 21:37:
> Matej Cepl wrote:
>> No, the strangness is not that bad (well, it is bad ... almost anything 
>> feels bad comparing to Python, to be honest, but not the reason I would 
>> give up; after all I spent couple of years with Javascript).
> 
> The XSLT language is one of the worst misuses of XML, which puts it way
> beyond bad.

Clearly a matter of opinion.

Stefan

[toc] | [prev] | [next] | [standalone]


#20572

FromRoss Ridge <rridge@csclub.uwaterloo.ca>
Date2012-02-17 16:11 -0500
Message-ID<jhmfpl$d9u$1@rumours.uwaterloo.ca>
In reply to#20571
Ross Ridge writes:
> The XSLT language is one of the worst misuses of XML, which puts it way
> beyond bad.

Stefan Behnel  <stefan_ml@behnel.de> wrote:
>Clearly a matter of opinion.

No.  There's no excuse for using XML as the syntax of a language like
XLST.

					Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web