XSLT to Python script conversion?

M

Matej Cepl

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
 
S

Stefan Behnel

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
 
M

Mike C. Fletcher

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/~mcfletch/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
 
T

Tim Arnold

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
 
M

Matej Cepl

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
 
R

Ross Ridge

Matej Cepl said:
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
 
S

Stefan Behnel

Ross Ridge, 17.02.2012 21:37:
The XSLT language is one of the worst misuses of XML, which puts it way
beyond bad.

Clearly a matter of opinion.

Stefan
 
R

Ross Ridge

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

Stefan Behnel said:
Clearly a matter of opinion.

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

Ross Ridge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top