我有一个 XSL / XML 解析器来生成 jsp / html 代码。
使用 MVC 模型我需要加入spring库才能执行 i18n 翻译。 因此,给定xml
<a>
...
<country>EN</country>
...
</a>
并使用<spring:message code="table_country_code.EN"/>
标签,根据浏览器语言选择,转换为英格兰,Inglaterra等...
但是,XSL不支持<spring:message>
标记。
我们的想法是使用类似这样的XSLT
<spring:message code="table_country_code.><xsl:value-of select="country"/>"/>`
获得最终代码<spring:message code="table_country_code.EN"/>
,并在基于i18n翻译的最终JSP / HTML中被识别。
当我进行解析以创建 XML 时,我还尝试在 Java 中创建spring标记,但我也有同样的错误。
The prefix "spring" for element "spring:message" is not bound.
[编辑]
我在这里看到了一些问题,比如使用bean:spring
,但仍有同样的问题。
任何指针?
答案 0 :(得分:2)
XSLT必须是格式良好的XML,因此您需要声明命名空间,并且不能在属性值中使用<
。
Spring 3 - Accessing messages.properties in jsp
建议名称空间应为
http://www.springframework.org/tags
所以大概你想要一个
的XSLT代码<spring:message
xmlns:spring="http://www.springframework.org/tags"
code="table_country_code.{country}"
/>
其中{}
是属性值模板,用于评估XPath country