xsl---xml 网页引用头文件

54321790 2007-11-19 03:54:07
小弟我用一个软件,自动生成网页,是xml的,通过更改其xsl文件,想引用一个头文件,试了几个方法都不行。该如何做那?小弟初学,多谢,多谢。
...全文
78 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaojing7 2007-11-29
  • 打赏
  • 举报
回复
给你个例子
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<div>
<xsl:for-each select="link_root/link">
<xsl:if test="@to='text'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="url"></xsl:value-of></xsl:attribute>

<xsl:attribute name="alt">
<xsl:value-of select="title"/>
</xsl:attribute>

<xsl:attribute name="target">
<xsl:value-of select="target"/>
</xsl:attribute>

<xsl:value-of select="text"/>
</a>
<xsl:text>|</xsl:text>
</xsl:if>
</xsl:for-each>
</div>
<div>
<xsl:for-each select="link_root/link">
<xsl:if test="@to='image'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="url"></xsl:value-of>
</xsl:attribute>

<xsl:attribute name="target">
<xsl:value-of select="target"/>
</xsl:attribute>

<img border="0" width="120" height="60">
<xsl:attribute name="src">
<xsl:value-of select="text"/>
</xsl:attribute>

<xsl:attribute name="alt">
<xsl:value-of select="title"/>
</xsl:attribute>
</img>
</a>
</xsl:if>
</xsl:for-each>
</div>


</xsl:template>

</xsl:stylesheet>

hejunbin 2007-11-22
  • 打赏
  • 举报
回复
如果是引用文件的话可以用类似如下

<xsl:param name="pageRecords">
<xsl:value-of select="document('../xml/blog_Settings.xml')" />
</xsl:param>

关键是document('XXX')
cds27 2007-11-20
  • 打赏
  • 举报
回复
不怎么明白LZ的意思
fcuandy 2007-11-19
  • 打赏
  • 举报
回复
xml文件头部声明里不能采用变量,只能写死.

你可以采用服务器将xsl格式化xml后再输出.或者动态加载xml再输出一段声明信息再输出xml文档..

8,906

社区成员

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

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