在 xsl 中读取属性文件或文本文件 [英] Read properties file or a text file in xsl

查看:24
本文介绍了在 xsl 中读取属性文件或文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 xsl 文件,其中包含一些用于显示的内容.这些内容经常更改.所以每次都要修改xsl文件.

i have a xsl file which is containing some contents for displaying.This contents gets changed often. so each time have to modify the xsl file.

所以想到将内容移动到文本属性文件中,这样只需更改它就可以了.

So thought of moving the content to a text ot properties file so that just changing this will be fine.

谁能告诉我如何仅将内容移动到文本文件并使用 xsl 文件访问它.提前致谢.

can anybody tell me how to move just the contents to a text file and access it using xsl file. Thanks in advance.

推荐答案

为什么要使用文本文件?XML 肯定会更好吗?

Why use a text file? Surely XML would be better?

XSLT 样式表可以使用 document('strings.xml') 读取第二个输入文档.然后你可以访问字符串,例如

An XSLT stylesheet can read a second input document using document('strings.xml'). Then you can access strings as for example

<xsl:value-of select="document('strings.xml')//string[@id='msg012']"/>

其中文件的格式类似于

<strings>
  <string id='msg012'>This is one of the strings to include</string>
</strings>

在 XSLT 2.0 中,您可以将访问逻辑包装到一个函数中,这样调用就变成了

In XSLT 2.0 you can wrap the access logic into a function so the call just becomes

<xsl:value-of select="my:string('msg012')"/>

这篇关于在 xsl 中读取属性文件或文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆