<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ page contentType="text/html; charset=gb2312" language="java" %>

<html>
<head>
  <title>JSTL: XML Support －－综合实例</title>
</head>
<body bgcolor="#FFFFFF">
<h3>Parse / ForEach</h3>

<x:parse var="document">
  <GetAllBooks>
           <book id="1234">
				<name>JSP应用开发详解</name>
				<publisher>电子工业出版社</publisher>
				<price>xxx</price>
				<category>计算机</category>
				<description>JSP开发最新的书</description>
				<authors>
		           <author id="1">
		              <name>asiapower</name>
		              <address>address:xxxx1</address>
		            </author>
		            <author id="2">
		              <name>hellking</name>
		              <address>address:xxxx2</address>
		            </author>
		        </authors>
           </book>
     </GetAllBooks>        
</x:parse>

<x:forEach select="$document/GetAllBooks">
  -> <x:out select="."/>
  <br>
</x:forEach>

<hr/>

<x:forEach select="$document//book">
  -> 
  <x:if select=".//author">
   <x:out select=".//author/name"/>
  </x:if>
  <br/>
</x:forEach>
<hr>

<x:forEach select="$document//book">
  -> 
  <x:choose>
  <x:when select='$document//author[@id="2"]'>
   author id=2,<x:out select='$document//author[@id="2"]'/>
   </x:when>
   <x:otherwise>
   no author's id=2
   </x:otherwise>
  </x:choose>
  <br/>
</x:forEach>


</body>
</html>

