JSP List of data in the XML document : XML « JSP « Java






JSP List of data in the XML document

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="people">
    <h1>List of people in the XML document</h1>
    <table border="1">
      <th>Name</th><th>Age</th>
      <xsl:apply-templates />
    </table>
  </xsl:template>

  <xsl:template match="person">
    <tr>
      <td><xsl:value-of select="name/text()" /></td>
      <td><xsl:value-of select="age/text()"  /></td>
    </tr>    
  </xsl:template>

</xsl:transform>

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

<html>
  <head>
    <title>Transforming a Subset</title>
  </head>

  <body>
    <c:import url="http://localhost:8080/chapter12/Multi-Template/people.xml"
              var="inputDoc" />

    <c:import url="http://localhost:8080/chapter12/Multi-Template/transform.xsl"
              var="stylesheet" />

    <x:parse  xml = "${inputDoc}"
              var = "parsedDoc" />

    <x:set    select = "$parsedDoc/people/person/name[../age > 50]"
              var    = "subset" />
     
    <x:transform xml  = "${subset}"
                 xslt = "${stylesheet}" />


  </body>
</html>



           
       








Related examples in the same category

1.Using the Core XML tags
2.XML transformation
3.Performing XSL Transformations
4.JSP in pure XML generating conforming XHTML
5.XSLT In JSP
6.XSLT in JSP 2
7.JSP Parsing using the DOM
8.JSP Parsing using JDOM
9.JSP Parsing using the DOM and JSTL
10.JSP and SAX
11.JSP Displaying a Subset in XML
12.JSP XML and XSLT transform
13.Deal With XML In JSP