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

Alan Darnell alan.darnell at utoronto.ca
Tue Apr 3 15:45:29 PDT 2007


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>



More information about the General mailing list