This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How to disable escaping of '<' characters --- Additional Inforomation
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] How to disable escaping of '<' characters --- Additional Inforomation
- From: Satish Patil <Satish dot Patil at ctp dot com>
- Date: Sun, 11 Mar 2001 19:04:47 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
I am using XSL stylesheet to generate HTML output. The requirement I have is
to compare two XML structures and highlight the difference. The way I
thought I can accomplish this is compare two DOM structures and whenever
there is a difference, add high lighting HTML tags to the DOM & print the
dom using XSLT.
If there is a better solution, let me know.
Thank you for your help.
-------------------------------------------------------------
Hi
I want to disable the escaping of '<' ,'>' characters in XML.
Ex:
I create a dom tree
<PARENT>
<CHILD>
<font size = '2'>XML</font>
<CHILD>
<PARENT>
and apply xls sheet which prints the value CHILD element.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="PARENT">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="CHILD">
<html>
<xsl:value-of select="." />
</html>
</xsl:template>
</xsl:stylesheet>
The o/p I want is
<html>
<font size='2'>XML</font>
</html>
what I am getting is
<html>
<font size='2'>XML</font>
<html>
Is there a solution for this.
The java program which creates the DOM is
Document doc = new DocumentImpl();
Element parent = doc.createElement("PARENT");
Element child = doc.createElement("CHILD");
child.appendChild(doc.createCDATASection("<font
size='2'>XML</font>"));
//child.appendChild(doc.createTextNode("<font
size='2'>XML</font>"));
parent.appendChild(child);
doc.appendChild(parent);
DOMSource domSource = new DOMSource(doc);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("Temp.xsl"));
transformer.transform(domSource, new StreamResult(new
FileOutputStream("Temp.html")));
Thank you in advance.
Satish
-----Original Message-----
From: Mike Brown [mailto:mike@skew.org]
Sent: Sunday, March 11, 2001 1:54 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] How to disable escaping of '<' characters
Satish Patil wrote:
> I want to disable the escaping of '<' ,'>' characters in XML.
FAQ. Those are markup characters. If you put them in a document as
character data (such as in text nodes or attribute nodes, in XPath
terminology), and you don't escape them, then you can't distinguish them
from markup when the document is serialized. While this may be your intent,
you're really abusing XML by trying to use it as a vehicle for more markup.
XSLT allows a disable-output-escaping="yes" attribute to be added to an
xsl:text or xsl:value-of instruction, but be warned that XSLT processors
don't have to support it.
Besides, the point of using the DOM, and XPath in XSLT, is so you don't
have to mess around with the serialized markup-and-character-data; the idea
is to work with the abstract node structures that are represented by that
string of characters.
- Mike
____________________________________________________________________
Mike J. Brown, software engineer at My XML/XSL resources:
webb.net in Denver, Colorado, USA http://skew.org/xml/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list