[xsl] Converting an element tree to a string representation

Subject: [xsl] Converting an element tree to a string representation
From: Nicholas Piper <nick-xsllist@xxxxxxxxxxxxxxx>
Date: Wed, 3 Sep 2003 16:22:39 +0100
I've had a good look at http://www.dpawson.co.uk/xsl/index.html, and
google. Google is hard, because I can't think of good keywords; I may
have missed something in the list archive for that reason too.

I'm trying to write a series of XSLT files to transform an
XHTML+MathML document into new documents that can be shown on 'big
browsers', PDA browsers, WML phones, etc.

I'm planning to manage the MathML thin browsers by converting a block
like this:

 <math xmlns="http://www.w3.org/1998/Math/MathML";>

in my source document, to this in my output document:

<img src="http://i.haus/i/el/mathml_to_png.py?math=%3Cmath++++

(obviously without the line breaks).

Then my python script converts that XML fragment into a PNG, or WBMP,
etc. I've got the server-side part sorted, but am having very great
difficulty trying to convince my xslt engine (xmlspy, xsltproc) to
output what I'd like.

My current attempt looks like:

 <xsl:template match="math:math">
   <xsl:attribute name="src">
    http://i.haus/cgi-bin/mathmltopng?m=<xsl:value-of select="."/>

But of course this doesn't work, I just get 

 [...] src="http://i.haus/cgi-bin/mathmltopng?m=Cost=_n=1_(-1)nn" [...]

as it concatenates together the text nodes, rather than reproducing
the node as a string.

Is what I want to do possible? Should I pre or post-process the file
with a parser of my own, instead of trying to do this with an XSLT
engine? That doesn't seem quite as nice.

Thank you,


Part 4 MEng Cybernetics; Reading, UK       http://www.nickpiper.co.uk/
GPG Encrypted mail welcome!                             1024D/3ED8B27F
Choose life. Be Vegan :-) Please reduce needless cruelty + suffering !

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread