How to setup JSP page to use XML and XSL for Googl

2019-09-06 13:58发布

I want to make an App Engine app that will display xml content that is transformed by an xsl file. I'm using the GAE Eclipse plugin for development.

I want to put the xml content in a jsp page so that I can collect form data based on the displayed xml. I am new to App Engine and jsp, and things are not as straight-forward as I'd hoped. I've copied snippets of my xml and xsl files below. I've also posted two different jsp attempts that I've made and their accompanying errors. I suspect my problem might have to do with the jars I'm using, so I've also included a list of the jars that are included in my project.

I've waded through a ton of documentation, but I can't figure this out. Any suggestions would be much appreciated!

XML (10013.xml):

 <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="evex_display.xsl"?>
    <queryresponse>
        <queryinfo>
            <rowStart>0</rowStart>
            <family>entrez</family>
            ...
        </queryinfo>
    <queryresults>
    <events>
    <event id="38597010" averageConfidence="-0.115586">
    ...

XSL (evex_display.xsl):

 <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="evex_style.css" />
    <script type="text/javascript" src="utils.js"></script> 
    </head>

    <body>
    <div class="container">
        ...
        <xsl:for-each select="queryresponse/queryresults/events/event">
        <div class="event"> 
    ...

JSP attempt #1 (based on example at https://stackoverflow.com/a/10563605/1590763):

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

<c:import url="10013.xml" var="xmldocument"/>
<c:import url="evex_display.xsl" var="xslt"/>
<x:transform xml="${xmldocument}" xslt="${xslt}"/>

Error response:

HTTP ERROR 500 Problem accessing /test3.jsp. Reason: /test3.jsp(6,0) According to TLD or attribute directive in tag file, attribute xml does not accept any expressions

JSP attempt #2 (based on example at http://www.uriit.ru/japan/Our_Resources/Doc_iAS/jsp.106/devguide/xml.htm#7.1):

<%@ taglib uri="oracle.jsp.parse.OpenJspRegisterLib" prefix="jml" %>
<jml:transform href="evex_display.xsl"> 
    <%@ include file="10013.xml" %>
</jml:transform>

Error response:

HTTP ERROR 500 Problem accessing /test2.jsp. Reason: File "/oracle.jsp.parse.OpenJspRegisterLib" not found

JARS (in war/WEB-INF/lib and also added to the project's build path):

  • appengine-api-1.0-sdk-1.8.5.jar
  • appengine-api-labs.jar
  • appengine-endpoints.jar
  • appengine-jsr107cache-1.8.5.jar
  • asm-4.0.jar
  • datanucleus-api-jdo-3.1.3.jar
  • datanucleus-api-jpa-3.1.3.jar
  • datanucleus-appengine-2.1.2.jar
  • datanucleus-core-3.1.3.jar
  • dom4j-1.6.1.jar
  • geronimo-jpa_2.0_spec-1.0.jar
  • jdo-api-3.0.1.jar
  • jsoup-1.7.2.jar
  • jsr107cache-1.1.jar
  • jstl-1.2.jar
  • jta-1.1.jar
  • poi-3.9-20121203.jar
  • poi-ooxml-3.9-20121203.jar
  • poi-ooxml-schemas-3.9-20121203.jar
  • stax-api-1.0.1.jar
  • taglibs-xsl.jar
  • taglibs.jar
  • xmlbeans-2.3.0.jar

1条回答
Root(大扎)
2楼-- · 2019-09-06 14:30

Attempt #1 was fixed by changing the taglib uri's as follows:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
查看更多
登录 后发表回答