This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cannot force generation of " inside attribute value string


greg keraunen wrote:
> 
> dear friends,
> 
> I am having a problem producing xml output that includes double-quotes
> inside of an attribute value.

I'll assume that single quotes don't work. It would actually be nice if XSLT
processors occasionally output attributes surrounded by single quotes, as this
would solve your problem. What is your output method incidentally - if it is
XML or HTML, the quotes are the least of your worries - the '<' at the start
of the attribute is much harder to deal with.

Anyway, to produce dubious output, you have to resort to dubious methods ...

As of saxon 5.4, there is an extension attribute that disables output escaping
in attribute values, allowing you to create the kind of invalid output you're
looking for.

The following stylesheet

<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:template match="/">
  <input type="text">
    <xsl:attribute name="value" saxon:disable-output-escaping="yes"
        xmlns:saxon="http://icl.com/saxon">
      <xsl:text>&lt;?php echo global_get("vg_answer.qa[1]" ); ?></xsl:text>
    </xsl:attribute>
  </input>
</xsl:template>

</xsl:stylesheet>

produces

<?xml version="1.0" encoding="utf-8"?>
<input type="text" value="<?php echo global_get("vg_answer.qa[1]" ); ?>"/>

Hope this helps.

-- 
Warren Hedley


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]