Hi, I am wondering how to use JSTL XML <x:transform> tag with "result"
attribute.
I am using the jakarta-taglibs/standard-1.0.2 with Tomcat 4.1.3 on
Windows2000.
I have a String variable "${pipeline_final_output_String}" within the
request scope in which a XML document is contained.
I needed to transform the String via a simple identityTransform because the
original XML is in a canonical-form; therefore no \n and no line
indentation is used. I want to perform <xsl:output indent="yes"/> on the
original.
Also I want to print the variable's content while escaping "<" and "&"
characters into "<" and "&" respectively;
All these are meant to provide a debug-view to see "XML as it is" in the
resulting HTML.
I coded a JSP as follows :
----------------------------------------------------------------------------------
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
<h3>raw Model</h3>
<c:import var="xslturl2" url="/WEB-INF/transform/IdentityTransform.xsl"
charEncoding="Shift_JIS"/>
<%@ page import="javax.xml.transform.stream.StreamResult" %>
<%@ page import="javax.xml.transform.Result" %>
<%@ page import="java.io.StringWriter" %>
<%
StringWriter sw = new StringWriter();
StreamResult outputResult = new StreamResult(sw);
%>
<x:transform xml="${pipeline_final_output_String}" xslt="${xslturl2}"
result="outputResult"/>
<%
String escapedString = escape(sw.toString());
%>
<table>
<tr><td><pre><%= escapedString %></pre></td></tr>
</table>
<%!
String escape(String s) {
StringBuffer buffer = new StringBuffer(1024);
if (s != null) {
for (int i = 0; i < s.length(); i++) {
String c = s.substring(i,i+1);
if (c.equals("<")) {
buffer.append("<");
} else if (c.equals(">")) {
buffer.append(">");
} else if (c.equals("&")) {
buffer.append("&");
} else {
buffer.append(c);
}
}
return buffer.toString();
} else {
return null;
}
}
------------------------------------------------------------
When executed, a ServletException occured. The diagnostics says something
as follows (in Japanse) :
"An error occured during evaluating the custome action attribute "result"
with the value "outputResult".
When tried to convert a String "outputResutl" into the type of
"javax.xml.transform.Result",
there is not a PropertyEditor to the type."
I could not find a instructive articles on Web how to use "result"
attribute of <x:transform>.
Anyone knows how?
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>