Re: [xsl] nbsp and copy-of and output xml

Subject: Re: [xsl] nbsp and copy-of and output xml
From: "Mandar Jagtap" <mandar.jagtap@xxxxxxxxx>
Date: Mon, 18 Aug 2008 13:46:05 +0530
Try using <xsl:text>&#160;</xsl:text>... I think you need to keep
output method as html also.

Regards
Mandar Jagtap

On 8/16/08, Henner Graubitz <graubitz@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi there,
>
> I have a problem which nearly kills me now for 4 weeks. What I want to
> do is to convert - via jdom - xsl and xml to html
>
> The problem is: the html should be
>
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
>
> Thats why I use <xsl:output method="xml" omit-xml-declaration="yes"/>
> instead of method="html" (the output is unfortunatelly not XHTML 1.0.
>
> All converters produce the same output, so it has nothing to do with
> jdom, saxon, xalan, etc.
>
> Let me take for example xalan:
>
> java org.apache.xalan.xslt.Process -IN 02.xml -XSL 02.xsl -OUT 02.html
>
> WHAT I WANT TO PRODUCE: &nbsp; WITH copy-of with output method="xml"
>
>
> Here is my xml-file what I tried:
>
>
> ------------------ 02.xml begin -----------------------------
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE myroot [
> <!ELEMENT myroot (#PCDATA)>
> <!ENTITY nbsp '&#160;'>
> <!ENTITY d '&#228;'>
> <!ENTITY auml '&#228;'>
> <!ENTITY ouml '&#246;'>
> <!ENTITY Auml '&#196;'>
> <!ENTITY Ouml '&#214;'>
> <!ENTITY  bull '&#8226;'>
> <!ENTITY szlig '&#223;'>
> <!ENTITY copy '&#169;'>
> <!ENTITY Uuml '&#220;'>
> <!ENTITY uuml '&#252;'>
> <!ENTITY lt '&#60;'>
> <!ENTITY gt '&#62;'>
> <!ENTITY  amp '&#38;'>
> ]>
>
> <myroot>
>  <row type="soft">
>      <oneline type="1">EASY: This write a <![CDATA[&nbsp;]]> while
>      using XML and CDATA AND USES a XML file.</oneline>
>  </row>
>
> <row type="hard">
> <table>
>        <p>This stuff does not work!!!</p>
>        <td id="1">&nbsp;</td>
>        <td id="2"><![CDATA[&nbsp;]]></td>
>        <td id="3"><![CDATA[&]]>nbsp;</td>
>        <td id="4">&#160;</td>
>        <td id="5">| </td>
>        <td id="6"><![CDATA[&#160;]]></td>
>        <td id="7"><![CDATA[&]]>#160;</td>
>        <td id="8">&#xA0;</td>
> </table>
> </row>
> </myroot>
>
> ------------------ 02.xml end -----------------------------
>
> ------------------ 02.xsl begin -----------------------------
>
> <!DOCTYPE tutorial [
> <!ENTITY ouml "&#160;">
> <!ENTITY  auml "&#228;">
> <!ENTITY  Auml "&#196;">
> <!ENTITY  ouml "&#246;">
> <!ENTITY  Ouml "&#214;">
> <!ENTITY nbsp "&#160;">
> <!ENTITY  szlig "&#223;">
> <!ENTITY Uuml "&#220;">
> <!ENTITY uuml "&#252;">
> <!ENTITY  copy "&#169;">
> <!ENTITY bull "&#8226;">
> <!ENTITY bull "&#8226;">
>
> ]>
>
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="2.0">
>
>
> <xsl:output method="xml" use-character-maps="example-map"/>
>        <xsl:character-map name="example-map">
>        <xsl:output-character character="&#228;" string="&amp;auml;"/>
>        <xsl:output-character character="&#160;" string="&amp;nbsp;"/>
> </xsl:character-map>
>
> <xsl:template match="/myroot"> <html xmlns="http://www.w3.org/1999/xhtml";
xml:lang="de" lang="de">
> <xsl:text disable-output-escaping="yes">EASY: this writes a simple <![CDATA[
&nbsp;]]> into the output NOT USING an XML-File. </xsl:text>
> <xsl:for-each select="row">
> <xsl:choose>
>        <!-- TYPE HARD -->
>        <xsl:when test="@type=&apos;hard&apos;">
>        <xsl:copy-of select="table"/>
>        </xsl:when>
>
>        <!-- TYPE SOFT -->
>        <xsl:when test="@type=&apos;soft&apos;">
>                <xsl:for-each select="oneline">
>                        <xsl:value-of select="."
disable-output-escaping="yes"/>
>                </xsl:for-each>
>        </xsl:when>
> </xsl:choose>
>
> </xsl:for-each>
> </html>
> </xsl:template>
> </xsl:stylesheet>
>
>
> ------------------ 02.xsl end -----------------------------
>
> For the copy-of problem: I can never convert to &nbsp;
> Instead I have these results:
>
> <td id="1">| </td>
> <td id="2">&amp;nbsp;</td>
> <td id="3">&amp;nbsp;</td>
> <td id="4">| </td>
> <td id="5">| </td>
> <td id="6">&amp;#160;</td>
> <td id="7">&amp;#160;</td>
> <td id="8">| </td>
>
>
> So does anybody have an idea what to provide as XML or XSL to receive
&nbsp;
>
> Really appreciate this.
>
> Thanks for any link, advice, help.
>
>
> Holm
>
>


--
Thanks & Regards,
Mandar

Current Thread