Re: [xsl] Copying nodes in XSLT, quoting goes funny.

Subject: Re: [xsl] Copying nodes in XSLT, quoting goes funny.
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Wed, 16 Apr 2008 13:27:15 +0200
David schrieb:
Trouble is, on the outputted document it gives me a tag like this :

<span style="background-color: #ff4411;"
onclick='doSomethingFun("Hello world!!!");' />

Looks like because there are double quotes within the value, it is
using single quotes. But the other attribute is using double quotes.

This works for me:


mludwig@forelle:~/Werkstatt/xsl > cat quotes.php
<?php
$doc = new DOMDocument;
$doc->load('quotes.xsl');
$xsl = new XSLTProcessor;
$xsl->importStyleSheet($doc);
$doc->loadXML('<Urmel/>');
echo $xsl->transformToXML($doc);
mludwig@forelle:~/Werkstatt/xsl > expand -t2 quotes.xsl
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<span>
<xsl:attribute
name="style">background-color: #ff4411;</xsl:attribute>
<xsl:attribute
name="onclick">doSomethingFun("Hello world!!!");</xsl:attribute>
</span>
</xsl:template>
</xsl:transform>
mludwig@forelle:~/Werkstatt/xsl > php quotes.php
<?xml version="1.0"?>
<span style="background-color: #ff4411;" onclick="doSomethingFun(&quot;Hello world!!!&quot;);"/>


It's using entities without needing special instruction.

Michael

Current Thread