[prev in list] [next in list] [prev in thread] [next in thread]
List: taglibs-user
Subject: Re: JSTL c/x:out and XML-fragments
From: matsuhashi () quick ! co ! jp
Date: 2003-03-19 12:51:59
[Download RAW message or body]
Here I cut&pasted a code fragment of my JSP.
----------------------------------------------------------------
<h3>raw Model</h3>
<c:import var="xslturl2" url="/WEB-INF/transform/IdentityTransform.xsl"
charEncoding="Shift_JIS"/>
<%@ page import="java.io.StringWriter" %>
<%@ page import="javax.xml.transform.stream.StreamResult" %>
<%
StringWriter sw = new StringWriter();
pageContext.setAttribute("resultString",sw);
StreamResult outputResult = new StreamResult(sw);
pageContext.setAttribute("outputResult", outputResult);
%>
<x:transform xml="${pipeline_final_output_String}" xslt="${xslturl2}"
result="${outputResult}"/>
<table border="1">
<tr><td><pre><c:out value="${resultString}" escapeXml="true"
/></pre></td></tr>
</table>
----------------------------------------------------------------
What is this doing?
/WEB-INF/trasnform/IdentityTransform.xsl is a XSLT stylesheet which just
copies the input source to the output result while changing the character
encoding from UTF-8 to Shifg_JIS (Japanese local charaset).
<x:transform xml="${pipeline_final_output_String}" xslt="${xslturl2}"
result="${outputResult}"/>
this fragment set the String format of the input XML
(${pipeline_final_output_String} EL variable stands for it) to a variable
${resultString}.
Then <c:out value="${resultString}" escapeXml="true" /> this tag prints the
String which contains lot of <s and >s , but it is just a String -:).
A cute portion of the above code might be that StringWriter class. This
scriptlet trick the XSLT processor to write the transformation result as a
plain String into the ${resultString}.
Would this help?
MATSUHASHI, kazuaki
Japan
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic