次のようなカスタムタグの本体として、xmlドキュメントを純粋なjstl定義のJSPカスタムタグに渡すことができるかどうか疑問に思います。
<mt:mytag>
<people>
<person name="bob" age="23" />
<person name="sue" age="45" />
<person name="moe" age="35" />
</people>
<mt:mytag>
または、次のようなタグの属性として:
<mt:mytag message="http://link.to.document.xml" />
タグそのものです
<%@tag description="xml parser" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<%@attribute name="message"%> OR <jsp:doBody var="message" />
<x:parse var="a" doc="${message}" />
<x:forEach var="current" select="$a/people/person">
<ul>
<li>
Name <x:out select="$current/@name" /> age <x:out select="$current/@age" />
</li>
</ul>
</x:forEach>
jsp ページ内から jstl を使用して xml を処理することは可能です。基本的には forEach の後にコードをコピーし、jsp に貼り付けます。ページリクエストでxmlをPOST / GETパラメータとして取得し、ページで処理することもできます。
それ以外の場合、上記の例を実行すると、この種のさまざまなエラーが発生します。
PWC6197: An error occurred at line: 9 in the jsp file: /WEB-INF/tags/test2.tag
PWC6199: Generated servlet error:
cannot access javax.servlet.jsp.jstl.core.LoopTagSupport
class file for javax.servlet.jsp.jstl.core.LoopTagSupport not found
PWC6197: An error occurred at line: 9 in the jsp file: /WEB-INF/tags/test2.tag
PWC6199: Generated servlet error:
cannot find symbol
symbol: method setPageContext(javax.servlet.jsp.PageContext)
location: variable _jspx_th_x_forEach_0 of .......
JSTL+EL にそのような機能があるかどうか疑問に思っているだけですが、非純粋な JSTL (Java コードを使用) 内の本文コンテンツまたは属性リンクのいずれかを処理することは完全に可能であることに注意してください。
編集:解像度
Netbeans IDE には、デフォルトで JSTL ライブラリを追加しないというバグがあるようです。ライブラリ->ライブラリの追加->インポート->Jstl 1.1->ライブラリの追加で修正します