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/12 00:06:06 UTC

xsl:processing-instruction sometimes doesn't output closing '?' (was: "Re: can't output '>' from ; no problem from " )

I'm afraid xsl:processing-instruction isn't working quite like a charm
after all.
It seems to behave inconsistently, depending on the levels of nesting in
the XML file, but problems occure ONLY when using -HTML output
formatting.
If I explicitly add -XML to the command line parameters, this produces
the desired output.

Perhaps this is not a bug but since it seems hard to reproduce, I have
documented it for anyone interested.

They welcome message for this list didn't say if attached files are ok
so I have not included the examples to reproduce the failed test. I
would be happy to provide these on request.

My environment is:

VA Linux-supplied Red Hat 6.2
jdk118_v1-glibc-2.1.2
xalan-j_1_0_1


--- begin working example ---

--- XML:

<PHP>
	$this->display_messages();
</PHP>

--- XSL:

<xsl:template match="PHP">
	<xsl:call-template name="php">
		<xsl:with-param name="code">
			<xsl:apply-templates />
		</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template name="php">
        <xsl:param name="code"/>
        <xsl:processing-instruction name="php">
		<xsl:value-of select="$code"/>
	</xsl:processing-instruction>
</xsl:template>

--- OUTPUT:
<?php
        $this->display_messages();
?>   

--- end working example ---
--- begin failing example ---

--- XML:

file available on request: valence_app.xml
in the above example file, the xml below is nested within other
elements; if you transform only the element below with the
valence_app.xsl file, the problem does NOT occur.
....
<ELEMENT TYPE="checkbox-input" NAME="debug" >
	<PROMPT>Debugging</PROMPT>
	<VALUE>1</VALUE>
	<CHECKED>
		<ELEMENT TYPE="dynamic-boolean" NAME="debug">
			<VALUE>CHECKED</VALUE>						
		</ELEMENT>
	</CHECKED>
</ELEMENT>
....

--- XSL:
entire file available on request:  valence_app.xsl
....
<xsl:template match="ELEMENT[@TYPE='dynamic-boolean']">

	<xsl:call-template name="php">
		<xsl:with-param name="code">
			if( $GLOBALS["<xsl:value-of select="@NAME" />"] ){
				echo "<xsl:value-of select="VALUE"/>";
			}
		</xsl:with-param>
	</xsl:call-template>

</xsl:template>

<xsl:template name="php">
        <xsl:param name="code"/>
        <xsl:processing-instruction name="php">
		<xsl:value-of select="$code"/>
	</xsl:processing-instruction>
</xsl:template>
....
--- DESIRED OUTPUT:
<INPUT type="checkbox" name="debug" value="1"
<?php
    if( $GLOBALS["debug"] ){
       echo "CHECKED";
    }
?>   
>
--- OUTPUT: missing closing '?'
<INPUT type="checkbox" name="debug" value="1"
<?php 
	if( $GLOBALS["debug"] ){
		echo "CHECKED";
	}
>
>
--- end failing example ---

greg keraunen wrote:
> 
> 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