You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beyaNet <an...@beyanet.com> on 2004/07/31 10:59:17 UTC

html entity problem

Hi,
what code do I need to place inside my xsl template to handle html 
entities such as &nbsp; ?

thanks

Andrew


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


Re: html entity problem

Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Ben" == Ben Pope <no...@hotmail.com> writes:

    Ben> Try being a bit more specific, I still don't know what it is
    Ben> that you intend to do.

    Ben> I have no idea why you created a DTD for the entity.

    Ben> If you want to output html by writing it inside your XSLT as
    Ben> you would in an editor, without having to worry about the
    Ben> parser parsing it, or the serialiser playing with it, do
    Ben> this:

    Ben> <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp; <!--
    Ben> and other html stuff -->]]></xsl:text>

    Ben> The CDATA section makes the parser leave it alone, and the
    Ben> DOE makes the serialiser leave it alone.

No it doesn't - the processor is not required to honour DOE.
-- 
Colin Paul Adams
Preston Lancashire

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


Re: html entity problem

Posted by "J.Pietschmann" <j3...@yahoo.de>.
beyaNet wrote:
> What I cannot now understand is why
> 
> <![CDATA[
> function MM_swapImgRestore() { //v3.0
> var i,x,a=document.MM_sr; for(i=0;a && i<a.length && (x=a[i]) && 
> x.oSrc;i++) x.src=x.oSrc;
> }
> ]]>
> 
> is being output to the browser as:
> 
> function MM_swapImgRestore() { //v3.0
> var i,x,a=document.MM_sr; for(i=0;a &amp;&amp; i&lt;a.length &amp;&amp; 
> (x=a[i]) &amp;&amp; x.oSrc;i++) x.src=x.oSrc;
> }
> 

 From the viewpoint of an XML parser, it's the same. Both
representations encode the same content, just in different
ways.
If you want to tell the serializer to use CDATA, check
cdata-section-elements.

J.Pietschmann

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


RE: html entity problem

Posted by Ben Pope <no...@hotmail.com>.
The CDATA section is only for the parser, not the serialiser.
 
So the parser is not turning your CDATA into xml events or trying to
understand it at all, which means you do not need to escape the characters.
 
However, that has nothing to do with how it is output.  The serialiser
doesn't even get to see the CDATA element, the parser stripped it and
replaced it with the text you specified in side the CDATA element.
 
So now the serialiser is looking at your "&" and thinking, thats not XML, he
must mean "&amp;"
 
On the processor I use (XERCES/XALAN shipped with 2.1.5), DOE seems to work.
 
So do what I said do, enclose it in a DOE "disable-output-escaping" tag, if
you're using a standard install.
 
Ben
 

________________________________

From: beyaNet [mailto:andrew@beyanet.com] 
Sent: 31 July 2004 20:55
To: users@cocoon.apache.org
Subject: Re: html entity problem


Hi Ben,
sorry for being vague ;-) I am am serialising my output to xhtml:

<map:serializer name="xhtml"
src="org.apache.cocoon.serialization.XMLSerializer" mime-type="text/html"
logger="sitemap.serializer.xhtml" pool-grow="2" pool-max="64" pool-min="2">
<doctype-public>-//W3C//DTD XHTML 1.1//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</doctype-system
>
<!--<encoding>UTF-8</encoding>//-->
<encoding>US-ASCII</encoding>
<indent>yes</indent>
</map:serializer>

I have now manages to solve the previous problem. What I cannot now
understand is why 

<![CDATA[
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a && i<a.length && (x=a[i]) && x.oSrc;i++)
x.src=x.oSrc;
}
]]> 

is being output to the browser as:

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a &amp;&amp; i&lt;a.length &amp;&amp;
(x=a[i]) &amp;&amp; x.oSrc;i++) x.src=x.oSrc;
}

I have included my xsl stylesheet or your attention

regards

Andrew



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


Re: html entity problem

Posted by beyaNet <an...@beyanet.com>.
Hi Ben,
sorry for being vague ;-) I am am serialising my output to xhtml:

		    <map:serializer name="xhtml"  
src="org.apache.cocoon.serialization.XMLSerializer"  
mime-type="text/html" logger="sitemap.serializer.xhtml" pool-grow="2"  
pool-max="64" pool-min="2">
			 <doctype-public>-//W3C//DTD XHTML 1.1//EN</doctype-public>
			  
<doctype-system>http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</doctype- 
system>
			 <!--<encoding>UTF-8</encoding>//-->
			 <encoding>US-ASCII</encoding>
			 <indent>yes</indent>
			</map:serializer>

I have now manages to solve the previous problem. What I cannot now  
understand is why

<![CDATA[
function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for(i=0;a && i<a.length && (x=a[i]) &&  
x.oSrc;i++) x.src=x.oSrc;
}
]]>

is being output to the browser as:

function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for(i=0;a &amp;&amp; i&lt;a.length  
&amp;&amp; (x=a[i]) &amp;&amp; x.oSrc;i++) x.src=x.oSrc;
}

I have included my xsl stylesheet or your attention

regards

Andrew


RE: html entity problem

Posted by Ben Pope <no...@hotmail.com>.
Try being a bit more specific, I still don't know what it is that you intend
to do.

I have no idea why you created a DTD for the entity.

If you want to output html by writing it inside your XSLT as you would in an
editor, without having to worry about the parser parsing it, or the
serialiser playing with it, do this:

<xsl:text disable-output-escaping="yes"><![CDATA[&nbsp; <!-- and other html
stuff -->]]></xsl:text>

The CDATA section makes the parser leave it alone, and the DOE makes the
serialiser leave it alone.

Which should have been described fully in the references I gave.

Enjoy.

Ben




________________________________

From: beyaNet [mailto:andrew@beyanet.com] 
Sent: 31 July 2004 10:36
To: users@cocoon.apache.org
Subject: Re: html entity problem


Hi Ben,
thanks for your reply. I have included the following code into my xsl
template which seems to solve the problem, but introduces another one:

<?xml version="1.0"?>

<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#160;">
]> 

When the xhtml page is generated it renders the following character to the
screen:

 

How do i resolve that?

thanks

Andrew
On 31 Jul 2004, at 10:14, Ben Pope wrote:



	Hi,
	
	Handle them how?
	
	You may find these two pages useful, that basically deal with the
input and
	output:
	http://www.dpawson.co.uk/xsl/sect2/cdata.html
	
	http://www.dpawson.co.uk/xsl/sect2/N2215.html
	
	Pay particular attention to:
	http://www.dpawson.co.uk/xsl/sect2/N2215.html#d3358e217
	
	To determine when each is useful (Might as well read this first, if
it
	doesn't make sense, look above)
	
	Ben
	
	
	
	-----Original Message-----
	From: beyaNet [mailto:andrew@beyanet.com] 
	Sent: 31 July 2004 09:59
	To: users@cocoon.apache.org
	Subject: html entity problem
	
	Hi,
	what code do I need to place inside my xsl template to handle html
entities
	such as &nbsp; ?
	
	thanks
	
	Andrew
	
	
	
---------------------------------------------------------------------
	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
	
	


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


Re: html entity problem

Posted by beyaNet <an...@beyanet.com>.
Hi Ben,
thanks for your reply. I have included the following code into my xsl 
template which seems to solve the problem, but introduces another one:

<?xml version="1.0"?>

<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#160;">
]>

When the xhtml page is generated it renders the following character to 
the screen:

 

How do i resolve that?

thanks

Andrew
On 31 Jul 2004, at 10:14, Ben Pope wrote:

> Hi,
>
> Handle them how?
>
> You may find these two pages useful, that basically deal with the 
> input and
> output:
> http://www.dpawson.co.uk/xsl/sect2/cdata.html
>
> http://www.dpawson.co.uk/xsl/sect2/N2215.html
>
> Pay particular attention to:
> http://www.dpawson.co.uk/xsl/sect2/N2215.html#d3358e217
>
> To determine when each is useful (Might as well read this first, if it
> doesn't make sense, look above)
>
> Ben
>
>
>
> -----Original Message-----
> From: beyaNet [mailto:andrew@beyanet.com]
> Sent: 31 July 2004 09:59
> To: users@cocoon.apache.org
> Subject: html entity problem
>
> Hi,
> what code do I need to place inside my xsl template to handle html 
> entities
> such as &nbsp; ?
>
> thanks
>
> Andrew
>
>
> ---------------------------------------------------------------------
> 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
>

RE: html entity problem

Posted by Ben Pope <no...@hotmail.com>.
Hi,

Handle them how?

You may find these two pages useful, that basically deal with the input and
output:
http://www.dpawson.co.uk/xsl/sect2/cdata.html

http://www.dpawson.co.uk/xsl/sect2/N2215.html

Pay particular attention to:
http://www.dpawson.co.uk/xsl/sect2/N2215.html#d3358e217

To determine when each is useful (Might as well read this first, if it
doesn't make sense, look above)

Ben

 

-----Original Message-----
From: beyaNet [mailto:andrew@beyanet.com] 
Sent: 31 July 2004 09:59
To: users@cocoon.apache.org
Subject: html entity problem

Hi,
what code do I need to place inside my xsl template to handle html entities
such as &nbsp; ?

thanks

Andrew


---------------------------------------------------------------------
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