[MarkLogic Dev General] MarkLogic XQuery Tag Library and JSTL XMLTag Library

Alan Darnell alan.darnell at utoronto.ca
Wed Apr 4 13:11:47 PDT 2007


Fixed my problem by downloading versions of standard.jar and jstl.jar  
newer than the ones included in the ML Tag Library download.   The  
output of from the xq:query tag parses nicely with x:parse and I can  
use x:out to select nodes in the XML document.

Alan


On 3-Apr-07, at 11:05 PM, Michael Sokolov wrote:

> Did you try <c:out value="$art" /> in the foreach just to make sure  
> the
> articles being returned are what you expect?
>
> -----Original Message-----
> From: general-bounces at developer.marklogic.com
> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Alan  
> Darnell
> Sent: Tuesday, April 03, 2007 6:45 PM
> To: General Mark Logic Developer Discussion
> Subject: [MarkLogic Dev General] MarkLogic XQuery Tag Library and JSTL
> XMLTag Library
>
> I'd like to be able to use these two libraries so that I can grab XML
> data from Mark Logic and then parse it using the JSTL XML libraries.
>
> Here's what I've got so far.  Use xq:execute to populate "results"
> variable with documents.  Iterate over "results" and pass each result
> converted to a string to x:parse, storing the parsed result in
> variable "art"
>
> But then when I try to access any elements of "art" I get a
> SAXPathException.
>
> Not sure what's happening but I'm new to using both tag libraries
> so ....
>
> Thanks in advance ...
>
> Alan
>
>
>
> <%@ taglib uri="http://marklogic.com/jsp/taglib" prefix="xq" %>
> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
> <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
>
> <xq:setDataSource host="..." port="..." user="..." password="..." />
>
> <html><head><title>Test</title></head>
>
> <body>
>
> <c:choose>
> 	<c:when test="${param.query != null}">
>
> 	<form action="search.jsp" method="post">
> 	<input name="query" value="<c:out value="${param.query}" />" />
> 	</form>
>
> 	<xq:execute var="results">
> 		<xq:query>
> 			for $i in
> cts:search(doc()//article-title,"${param.query}") [1 to 15]
>                  	return $i/root()
> 	</xq:query>
> </xq:execute>
>
> <ol>
>
> <c:forEach var="item" items="${results.items}">
> 	<x:parse xml="${item.string}" var="art" scope="session" />
> 	<li>
> 		<x:out select="$art//journal-id" />
> 	</li>
> </c:forEach>
>
> </ol>
>
> </c:when>
>
> <c:otherwise>
>
> <form action="search.jsp" method="post">
> 	<input name="query" value="" />
> </form>
>
> </c:otherwise>
> </c:choose>
>
> </body>
> </html>
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general



More information about the General mailing list