实现一个xml用多个xsl来表现中遇到的问题,救命!

justleon 2002-12-02 10:28:19
我用的是cocoon2.0.3,j2sdk1.4.0,Apache Tomcat 4.0
我要实现的功能是:一个xml用多个xsl来表现。我的sitemap 相关管道配置为:
....
<map:match pattern="content/*.xml">
<map:generate src="content/{1}.xml"/>
<map:transform src="transforms/sel.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
....
sel.xsl可以接受参数,参数值为要用的xsl名称
sel.xsl内容如下:

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output media-type="text/html" method="html"/>
<xsl:param name="style"/>
<xsl:template match="/">
<xsl:choose>
<!-- when style is specified -->
<xsl:when test="$style">
<xsl:processing-instruction name="xml-stylesheet">href="../transforms/<xsl:value-of select="$style"/>" type="text/xsl"</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
</xsl:when>
<!-- Otherwise use default.xsl -->
<xsl:otherwise>
<xsl:processing-instruction name="xml-stylesheet">href="../transforms/zheng.xsl" type="text/xsl"</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</xsl:template>

<!-- copy all elements -->
<xsl:template match="@*|*|text">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>

我确认style参数值正确。 但是所调用的xml并没用这个参数值作为样式表显示,而是将该xml中的所有标签内容列在了屏幕上,然后打开原文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="../transforms/shang.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<article id="20021151230">
<content>
<column_no>5</column_no>
<column_name>外资企业</column_name>
<catalog>GA</catalog>
<title>测试xytest</title>
<subtitle> </subtitle>
<source>unknown</source>
<publish_time>2002-11-19 14:06:57</publish_time>
<article_body>大锅饭豆腐干法</article_body>
<article_related>
测试6
</article_related>
<url_id>../include/top.xhtml</url_id>
<shtmllink>shtml连接</shtmllink>
</content>
</article>

没有解析成html,我该如何配置修改。如果我把sitemap<map:serialize type="xml"/>改成<map:serialize type="html"/>,则显示的源文件的开头变为<?xml-stylesheet href="../transforms/shang.xsl" type="text/xsl">
<?cocoon-process type="xslt">,结尾没有?,也不对。
...全文
22 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧