Hi Guys,
I'm new to XSLT, and I'm trying to do a very simple transformation using the Xerces DOMParser and the Xalan XSL engine. However I can't get it to work.
Here is what my xml
doc looks like (slightly trimmed):
<?xml version="1.0" encoding="UTF-8"?>
<storydetail>
<title>Network Status: Important notice</title>
<byline>Last Update</byline>
<date>10/28/03 5:10 AM</date>
<body>Various text in here</body>
</storydetail>
My xsl stylesheet is extremely simple:
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl

utput method="html" media-type="text/html" encoding="ISO-8859-1"/>
<xsl:template match="storydetail">
<br />
<b><xsl:value-of select="title"/></b><br />
<p><xsl:apply-templates select="body"/></p>
</xsl:template>
<xsl:template match="htmltag" mode="hidename">
<xsl:text disable-output-escaping="yes"><</xsl:text>
<xsl:value-of select="@htmlname"/>
<xsl:value-of select="@htmlattrs"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="image">
<img src="{.}" align="right" vspace="10" hspace="8"/>
<br clear="all"/>
</xsl:template>
<xsl:template match="a[@href]">
<a class="textred" href="javascript:launch('{@href}')">
<xsl:value-of select="."/>
</a>
</xsl:template>
<xsl:template match="@* | * | text()">
<xsl:copy>
<xsl:apply-templates select="@* | * | text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The XML document basically sits at a URI on a separate web server. I'm just trying to build the Document object using the DOMParser, and feed the entire Document into XSL.
Here is the guts of my code (stripped down for space):
String strBulletinUrl = "http:www.site.com";
DocumentBuilder objDB = null;
DocumentBuilderFactory objDBF = null;
org.jdom.input.DOMBuilder objDOMBuilder = null;
objDBF = DocumentBuilderFactory.newInstance();
objDB = objDBF.newDocumentBuilder();
objDocument = objDB.parse(strBulletinUrl);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(new File("stylesheet.xsl")) );
DOMSource xmlSource = new DOMSource(objDocument);
DOMResult xmlResult = new DOMResult();
transformer.transform(xmlSource, xmlResult);
Seems simple enough but it keeps bombing on me big time . I keep getting the following error:
javax.xml.transform.TransformerException: XSL-1103: (Fatal Error) DOMResult can not be this kind of node.
Just a little background info. I'm trying to run this from a
jsp page and I have all the proper jar files installed. Any help would be appreciated.