You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by greg keraunen <gk...@valinux.com> on 2000/07/11 20:38:04 UTC
can't output '>' from ; no problem from
Friends,
I am trying to output PHP code which sometimes includes the '>'
character.
<xsl:template match="PROBLEM_CANT_OUPUT_CORRECTLY">
<xsl:call-template name="php">
<xsl:with-param name="code">
$this->messages_display();
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="php">
<xsl:param name="code"/>
<xsl:text disable-output-escaping="yes"><</xsl:text>?php
<xsl:value-of select="$code" />
<xsl:text disable-output-escaping="yes">?></xsl:text>
</xsl:template>
The '>' in '$this->' gets translated internally to > and my php
template ouputs > instead of '>' which causes the PHP interpreter to
die.
This is not a problem if I don't use a named template and output the
character as a final result, as in:
<xsl:text disable-output-escaping="yes"><?php echo
$this->messages_display(); ?></xsl:text>
In this case PHP sees '<?php echo $this->messages_display(); ?>', which
is what I want <xsl:template name="php"> to produce.
Any suggestions?
Could I have my php template re-translate '>' back into '$gt;'
somehow (???)
Or do I perhaps need to write an extension function for this kind
of thing?
my system:
VA Linux-supplied Red Hat 6.2
jdk118_v1-glibc-2.1.2
xalan-j_1_0_1
--
greg keraunen <gk...@valinux.com> 408-542-8600 x8085
web software engineer
Re: can't output '>' from ; no problem from
Posted by greg keraunen <gk...@valinux.com>.
Brilliant! Thank you very much. It works like a charm, with no ugly
hacking required (didn't know xslt could do that)!
Curt Arnold wrote:
>
> Disabling output escaping is, of course, a hack that is widely warned
> against.
>
> Why can't you just use the xsl:processing-instruction command to
> generate the PI that you want.
>
> <xsl:template name="php">
> <xsl:param name="code"/>
> <xsl:processing-instruction name="php"><xsl:value-of
> select="$code"/></xsl:processing-instruction>
> </xsl:template>
--
greg keraunen <gk...@valinux.com> 408-542-8600 x8085
web software engineer
Re: can't output '>' from ; no problem from
Posted by Curt Arnold <Cu...@techie.com>.
Disabling output escaping is, of course, a hack that is widely warned
against.
Why can't you just use the xsl:processing-instruction command to
generate the PI that you want.
<xsl:template name="php">
<xsl:param name="code"/>
<xsl:processing-instruction name="php"><xsl:value-of
select="$code"/></xsl:processing-instruction>
</xsl:template>
Re: can't output '>' from ; no problem from
Posted by Gary L Peskin <ga...@firstech.com>.
Greg --
Adding the attribute 'disable-output-escaping="yes"' to the xsl:value-of
element did the trick in my testing.
Gary
greg keraunen wrote:
>
> Friends,
> I am trying to output PHP code which sometimes includes the '>'
> character.
>
> <xsl:template match="PROBLEM_CANT_OUPUT_CORRECTLY">
> <xsl:call-template name="php">
> <xsl:with-param name="code">
> $this->messages_display();
> </xsl:with-param>
> </xsl:call-template>
> </xsl:template>
> <xsl:template name="php">
> <xsl:param name="code"/>
> <xsl:text disable-output-escaping="yes"><</xsl:text>?php
> <xsl:value-of select="$code" />
> <xsl:text disable-output-escaping="yes">?></xsl:text>
> </xsl:template>
>
> The '>' in '$this->' gets translated internally to > and my php
> template ouputs > instead of '>' which causes the PHP interpreter to
> die.
>
> This is not a problem if I don't use a named template and output the
> character as a final result, as in:
>
> <xsl:text disable-output-escaping="yes"><?php echo
> $this->messages_display(); ?></xsl:text>
>
> In this case PHP sees '<?php echo $this->messages_display(); ?>', which
> is what I want <xsl:template name="php"> to produce.
>
> Any suggestions?
> Could I have my php template re-translate '>' back into '$gt;'
> somehow (???)
> Or do I perhaps need to write an extension function for this kind
> of thing?
>
> my system:
> VA Linux-supplied Red Hat 6.2
> jdk118_v1-glibc-2.1.2
> xalan-j_1_0_1
>
> --
> greg keraunen <gk...@valinux.com> 408-542-8600 x8085
> web software engineer