Subject: [xsl] nbsp and copy-of and output xml From: Henner Graubitz <graubitz@xxxxxxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 16 Aug 2008 10:18:41 +0200 |
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: 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 ' '> <!ENTITY d 'ä'> <!ENTITY auml 'ä'> <!ENTITY ouml 'ö'> <!ENTITY Auml 'Ä'> <!ENTITY Ouml 'Ö'> <!ENTITY bull '•'> <!ENTITY szlig 'ß'> <!ENTITY copy '©'> <!ENTITY Uuml 'Ü'> <!ENTITY uuml 'ü'> <!ENTITY lt '<'> <!ENTITY gt '>'> <!ENTITY amp '&'> ]> <myroot> <row type="soft"> <oneline type="1">EASY: This write a <![CDATA[ ]]> 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"> </td> <td id="2"><![CDATA[ ]]></td> <td id="3"><![CDATA[&]]>nbsp;</td> <td id="4"> </td> <td id="5">| </td> <td id="6"><![CDATA[ ]]></td> <td id="7"><![CDATA[&]]>#160;</td> <td id="8"> </td> </table> </row> </myroot> ------------------ 02.xml end ----------------------------- ------------------ 02.xsl begin ----------------------------- <!DOCTYPE tutorial [ <!ENTITY ouml " "> <!ENTITY auml "ä"> <!ENTITY Auml "Ä"> <!ENTITY ouml "ö"> <!ENTITY Ouml "Ö"> <!ENTITY nbsp " "> <!ENTITY szlig "ß"> <!ENTITY Uuml "Ü"> <!ENTITY uuml "ü"> <!ENTITY copy "©"> <!ENTITY bull "•"> <!ENTITY bull "•"> ]> <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="ä" string="&auml;"/> <xsl:output-character character=" " string="&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[ ]]> into the output NOT USING an XML-File. </xsl:text> <xsl:for-each select="row"> <xsl:choose> <!-- TYPE HARD --> <xsl:when test="@type='hard'"> <xsl:copy-of select="table"/> </xsl:when> <!-- TYPE SOFT --> <xsl:when test="@type='soft'"> <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 Instead I have these results: <td id="1">| </td> <td id="2">&nbsp;</td> <td id="3">&nbsp;</td> <td id="4">| </td> <td id="5">| </td> <td id="6">&#160;</td> <td id="7">&#160;</td> <td id="8">| </td> So does anybody have an idea what to provide as XML or XSL to receive Really appreciate this. Thanks for any link, advice, help. Holm
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Getting node w/ lowest at, Bordeman, Chris | Thread | Re: [xsl] nbsp and copy-of and outp, Dave Pawson |
RE: [xsl] understanding generate-id, Michael Kay | Date | Re: [xsl] nbsp and copy-of and outp, Dave Pawson |
Month |