xsl-list
[Top] [All Lists]

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

2008-04-16 04:27:44
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(_at_)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(_at_)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(_at_)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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>