Read properties file or a text file in xsl

2019-03-06 04:55发布

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.

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

标签: xslt
1条回答
爷的心禁止访问
2楼-- · 2019-03-06 05:39

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

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']"/>

where the file has a format like

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

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')"/>
查看更多
登录 后发表回答