[XSL-LIST Mailing List Archive Home]
Re: [xsl] Troubles with libxslt in PHP again: CDATA in
Subject: Re: [xsl] Troubles with libxslt in PHP again: CDATA in <script>|
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 13 Oct 2007 14:45:06 +0200
See my comments below
Martynas Jusevicius wrote:
well, on my machine I'm using PHP 5.2.2 which is giving me problems,
but my hosting uses 5.2.5 which seems to behave yet again differently.
That's PHP. I am interested in XSLT: what processor version do you use?
Please follow the list guidelines and use the info you get in any
subsequent posts so we can more easily help you:
That link doesn't work for me, it points to the google signup page.
So it looked like this:(sample truncated)
var children = ]><xsl:call-template name="js-children-array"/><![CDATA;
map.setCenter(locationLatLng, ]]><xsl:value-of select="$zoom-level"/><![CDATA[);
Ah, that's an interesting piece of XSLT! Thanks, that makes it easier to
find a remedy. But first of all: I ran your code (after removing the
pieces that gave a compile time error) and guess what: no sign of
<![CDATA[ in the output *at all*! So my guess is still that your
serializer has some funny tidbits, or for the oddest reason, your ISP's
HTTP daemon adds them...
But rest assured, you can easily resolve it: just remove all the CDATA
opening and closing tags. They have no business there. The only reason
you should use them is for easier writing of < and &. Any other
symbol can be left as is, including > and ' and " (in all but
a few situations).
To make this work, simply change the single "<" with < or reverse the
statement to read "children.length >= i". This will output these as <
or >. And IIRC, modern browsers have no trouble with xml entities
(sample output truncated)
(I hope I didn't introduce errors by cutting out not so important stuff).
And what I get as output is:
var children = [new Location("Denmark", 55.329144, 23.950195)];
For now I switched to "html" output method as David suggested and all
is working fine.
Of course, if this works fine and you are content with the HTML (and you
don't intend to parse it back as XML) then there's no worry about
resolving this issue. Still I am wondering why you manage to get such a
strange output, I hope you can update with information on your processor
*and* please run your code from the commandline to be sure PHP or your
ISP isn't messing things up, the output from the commandline will proof
*very* interesting. I've send you the details of a download site for
xsltproc in my previous mail.
-- Abel Braaksma