You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2012/11/13 19:38:31 UTC

Trouble with disable-output-escaping

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I'm running Cocoon 2.1.11 on Oracle Java 1.6.0_26. I'm using the
default Xalan 2.7.1 XSLT processor.

All examples are roughly mocked-up from a much more complicated
configuration so I apologize if there are typos, etc. -- I hand-typed
this message with no copy/paste.

I have some text data wrapped-up in XML like this:

<node>
  <subnode>
    There is &lt;b&gt;HTML text&lt;/b&gt; in here.
  </submode>
</node>

I'd like to spit-out that text as if it were HTML -- that is, without
escaping it on output. I would like to get this text output:

There is <b>HTML</b> in here.

But instead I get this:

    There is &lt;b&gt;HTML text&lt;/b&gt; in here.

Which, of course, is no surprise given no other instructions.

So I tried using disable-output-escaping, which seems uniquely-suited
for this purpose:

<xsl:template match="subnode">
  <xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>

I observe no change in the output. The XSL file has definitely been
re-read from the disk (I made other changes so I could verify at least
that much), so that's not an issue.

Here's my (rough) configuration:

sitemap:
<map:match pattern="foo.html">
  <map:generate src="source.xml" />

  <map:transform src="generate-cincludes-1.xsl" />

  <map:transform src="generate-cincludes-2.xsl" />

  <map:transform type="cinclude" />

  <!-- this is the XSL I'm working with: -->
  <map:transform src="the-transformer-in-question.xsl" />

  <map:transform type="cinclude" label="content" />

  <map:transform type="i18n" />
  <map:transform src="strip-namespace.xsl" />
  <map:serialize type="xhtml" />
</map:match>

My template header:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
    xmlns:cinclude="http://apache.org/cocoon/include/1.0"
    xmlns:java="http://xml.apache.org/xalan/java"
> 
    <xsl:output method="html" indent="yes" />
...

My understanding is that Xalan itself does support
disable-output-escaping, and I can't see why Cocoon would interfere
with that.

Am I trying to use disable-output-escaping incorrectly? Do I need to
run Cocoon (or Xalan) in any special mode or with any particular
settings in order to enable disable-output-escaping?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCik6cACgkQ9CaO5/Lv0PAqZgCeIX65HKLVa6rEe6TnL65wEdoi
48gAmgJfBNT+082ehqg7DhduZtEg/4RV
=l8ul
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Trouble with disable-output-escaping

Posted by Robby Pelssers <Ro...@nxp.com>.
Lol... Ok... I had similar issues and one way I solved this issue is by just wrapping that content in a special custom tag.  In the last XSLT I matched on that tag and used disable-output-escaping.


http://robbypelssers.blogspot.nl/2009/06/escaping-html-with-xslt.html


Let's see if that's worth a beer ;-)

Cheers,
Robby

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Wednesday, November 14, 2012 5:03 PM
To: users@cocoon.apache.org
Subject: Re: Trouble with disable-output-escaping

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robby,

On 11/13/12 1:41 PM, Robby Pelssers wrote:
> Allright...
> 
> You should reminder this tip.  It will only work if you do this in the 
> very last transformer right before calling the serializer.

Okay, since I have a number of transform operations, I'll have to do some fancy footwork. Would this work?

> <map:match pattern="foo.html"> <map:generate src="source.xml" />
> 
> <map:transform src="generate-cincludes-1.xsl" />
> 
> <map:transform src="generate-cincludes-2.xsl" />
> 
> <map:transform type="cinclude" />
> 
> <!-- this is the XSL I'm working with: --> <map:transform 
> src="the-transformer-in-question.xsl" />

In the above XSL, add an attribute (or element) to the text I want to un-escape.

> <map:transform type="cinclude" label="content" />
> 
> <map:transform type="i18n" /> <map:transform src="strip-namespace.xsl" 
> />

Here, I could modify the strip-namespace.xsl to also find anything wrapped in the special un-escapify element (or with a similar
attribute) and use disable-output-escaping="yes" here?

> <map:serialize type="xhtml" /> </map:match>

> You owe me a beer ;-)

Not quite yet: I haven't got this sorted, yet. I'll buy you one if you are going to attend ApacheCon NA 2013.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCjwM8ACgkQ9CaO5/Lv0PBIkwCcC6NGOvLl1Qc15mrZDMk5iuGg
noQAn0MFKEzBAcXNu63J1MXHGp7Kwths
=kyBO
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org



Re: Trouble with disable-output-escaping

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robby,

On 11/13/12 1:41 PM, Robby Pelssers wrote:
> Allright...
> 
> You should reminder this tip.  It will only work if you do this in
> the very last transformer right before calling the serializer.

Okay, since I have a number of transform operations, I'll have to do
some fancy footwork. Would this work?

> <map:match pattern="foo.html"> <map:generate src="source.xml" />
> 
> <map:transform src="generate-cincludes-1.xsl" />
> 
> <map:transform src="generate-cincludes-2.xsl" />
> 
> <map:transform type="cinclude" />
> 
> <!-- this is the XSL I'm working with: --> <map:transform
> src="the-transformer-in-question.xsl" />

In the above XSL, add an attribute (or element) to the text I want to
un-escape.

> <map:transform type="cinclude" label="content" />
> 
> <map:transform type="i18n" /> <map:transform
> src="strip-namespace.xsl" />

Here, I could modify the strip-namespace.xsl to also find anything
wrapped in the special un-escapify element (or with a similar
attribute) and use disable-output-escaping="yes" here?

> <map:serialize type="xhtml" /> </map:match>

> You owe me a beer ;-)

Not quite yet: I haven't got this sorted, yet. I'll buy you one if you
are going to attend ApacheCon NA 2013.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCjwM8ACgkQ9CaO5/Lv0PBIkwCcC6NGOvLl1Qc15mrZDMk5iuGg
noQAn0MFKEzBAcXNu63J1MXHGp7Kwths
=kyBO
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Trouble with disable-output-escaping

Posted by Robby Pelssers <Ro...@nxp.com>.
Allright...

You should reminder this tip.  It will only work if you do this in the very last transformer right before calling the serializer.

You owe me a beer ;-)

Robby

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Tuesday, November 13, 2012 7:39 PM
To: users@cocoon.apache.org
Subject: Trouble with disable-output-escaping

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I'm running Cocoon 2.1.11 on Oracle Java 1.6.0_26. I'm using the default Xalan 2.7.1 XSLT processor.

All examples are roughly mocked-up from a much more complicated configuration so I apologize if there are typos, etc. -- I hand-typed this message with no copy/paste.

I have some text data wrapped-up in XML like this:

<node>
  <subnode>
    There is &lt;b&gt;HTML text&lt;/b&gt; in here.
  </submode>
</node>

I'd like to spit-out that text as if it were HTML -- that is, without escaping it on output. I would like to get this text output:

There is <b>HTML</b> in here.

But instead I get this:

    There is &lt;b&gt;HTML text&lt;/b&gt; in here.

Which, of course, is no surprise given no other instructions.

So I tried using disable-output-escaping, which seems uniquely-suited for this purpose:

<xsl:template match="subnode">
  <xsl:value-of select="." disable-output-escaping="yes" /> </xsl:template>

I observe no change in the output. The XSL file has definitely been re-read from the disk (I made other changes so I could verify at least that much), so that's not an issue.

Here's my (rough) configuration:

sitemap:
<map:match pattern="foo.html">
  <map:generate src="source.xml" />

  <map:transform src="generate-cincludes-1.xsl" />

  <map:transform src="generate-cincludes-2.xsl" />

  <map:transform type="cinclude" />

  <!-- this is the XSL I'm working with: -->
  <map:transform src="the-transformer-in-question.xsl" />

  <map:transform type="cinclude" label="content" />

  <map:transform type="i18n" />
  <map:transform src="strip-namespace.xsl" />
  <map:serialize type="xhtml" />
</map:match>

My template header:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
    xmlns:cinclude="http://apache.org/cocoon/include/1.0"
    xmlns:java="http://xml.apache.org/xalan/java"
> 
    <xsl:output method="html" indent="yes" /> ...

My understanding is that Xalan itself does support disable-output-escaping, and I can't see why Cocoon would interfere with that.

Am I trying to use disable-output-escaping incorrectly? Do I need to run Cocoon (or Xalan) in any special mode or with any particular settings in order to enable disable-output-escaping?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCik6cACgkQ9CaO5/Lv0PAqZgCeIX65HKLVa6rEe6TnL65wEdoi
48gAmgJfBNT+082ehqg7DhduZtEg/4RV
=l8ul
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org