Set XML Data in JSP Page with JSTL : XML « JSTL « Java Tutorial






<%@taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>

<c:set var="xml">
  <paragraph>
     This document uses <bold>unusual</bold> markup,
     which we want to replace with <bold>HTML</bold>.
  </paragraph>
</c:set>

<c:set var="xsl">
  <?xml version="1.0"?>
  <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 

  <xsl:template match="paragraph">
    <P><xsl:apply-templates/></p>
  </xsl:template>

  <xsl:template match="bold">
    <b><xsl:value-of select="."/></b>
  </xsl:template>

  </xsl:stylesheet>
</c:set>

<x:transform xml="${xml}" xslt="${xsl}"/>
  Download:  JSTLSetXMLDataInJSPPage.zip( 938 k)








24.32.XML
24.32.1.Import XML Data using JSTL
24.32.2.Set XML Data in JSP Page with JSTL
24.32.3.Output with/without Encode
24.32.4.Use Table to Display XML Data by JSTL