logo       

How to insert an HTML entity with an XSL stylesheet into a DOM result and t: msg#00043

java.enhydra.general

Subject: How to insert an HTML entity with an XSL stylesheet into a DOM result and then serialize it in HTML ?

Dear colleagues,

I'm trying to
- take an XML document: xmlSource
- applying an XSL stylesheet to it:
transformer.transform (new DOMSource(xmlSource),new DOMResult(myDOMTree));
- appending the result to an existing XMLC HTML object myContentHTML.java
myContent.getElementMydoc.appendChild(myContent.importNode(myDOMTree, true));
- and displaying the result through a presentation object
OutputOptions.setDropHtmlSpanIds(true);

OutputOptions.setXmlEncoding("UTF-8");
DOMFormatter fFormatter = new DOMFormatter(OutputOptions);
buffer = fFormatter.toBytes(myContent.getLayout());
comms.response.setContentLength(buffer.length);
out = comms.response.getOutputStream();
out.write(buffer);

Everything works fine except when I want to add html entities in my XSL stylesheet:

<xsl:stylesheet version="1.0" ... >


<xsl:output method="html" encoding="utf-8" indent="yes"/">

<xsl:template match="/">
<xsl:text>&lceil;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylessheet>

I tried several methods:

The first one:
<xsl:text>&lceil;</xsl:text>
I cannot even parse my xsl stylesheet because
Reason: class main.business.PapillonBusinessException: Exception in parseXslSheet(): The entity "lceil" was referenced, but not declared.

The second one:
<xsl:text>&amp;lceil;</xsl:text>
Works but displays the entire entity "&lceil;" instead of its content "⌈" !

The third one:
<xsl:text disable-output-escaping="yes">
Does not work !

Reason: class org.enhydra.xml.io.XMLIOError: Unexpected call to handleProcessingInstruction
Java Call Stack:

org.enhydra.xml.io.XMLIOError: Unexpected call to handleProcessingInstruction
at org.enhydra.xml.io.HTMLFormatter.handleProcessingInstruction(HTMLFormatter.java:274)
at org.enhydra.xml.dom.DOMTraversal.processNode(DOMTraversal.java:369)

The fourth one: <![CDATA[ &lceil; ]]>
Is like the second one: works but displays the entire entity "&lceil;" instead of its content "⌈" !

The fifth one:
<xsl:text><![CDATA[ &lceil; ]]></xsl:text>
Is like the second one: works but displays the entire entity "&lceil;" instead of its content "⌈" !

The last one: I also tried to write directly the character in UTF-8 "
⌈" instead of an entity
but the result is displayed with the ISO-8859-1 characters representing the entity: åà.
(when I have UTF-8 characters in the XML document, I have no problem)


Anyone has an idea ?

Thank you for your help !

Mathieu

Mathieu MANGEOT-LEREBOURS
Visiting Researcher National Institute of Informatics
Hitotsubashi 2-1-2-1913 Chiyoda-ku Tokyo 101-8430 Japan
Tel: +81-3-4212-2672 Fax: +81-3-3556-1916
http://www-clips.imag.fr/geta/mathieu.mangeot
Papillon project: www.papillon-dictionary.org
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise