X-Pippes
X-Pippes

Reputation: 1170

Use spring tag in XSLT

I have a XSL/XML parser to produce jsp/html code.

Using MVC model I need to accees spring library in order to perform i18n translation. Thus, given the xml

<a>
  ...
  <country>EN</country>
  ...
</a>

and using <spring:message code="table_country_code.EN"/> tag, choose based on the browser language, the transalation into England, Inglaterra, etc... However, the XSL do not support <spring:message> tag. The idea is to have a XSLT with something like this

<spring:message code="table_country_code.><xsl:value-of select="country"/>"/>`

to have the final code <spring:message code="table_country_code.EN"/> and be recognized in the final JSP/HTML based on i18n translation.

I also tried to create the spring tag in Java when I make a parse to create the XML but I sill have the same error.

The prefix "spring" for element "spring:message" is not bound.

[EDIT]

I saw some questions here, like using bean:spring but still have the same problem. any pointers?

Upvotes: 1

Views: 1171

Answers (1)

David Carlisle
David Carlisle

Reputation: 5652

XSLT has to be namespace well formed XML, so you need to declare the namespace and you can not use < in attribute values.

Spring 3 - Accessing messages.properties in jsp

suggests the namespace should be

http://www.springframework.org/tags

so presumably you want an XSLT code of

<spring:message 
  xmlns:spring="http://www.springframework.org/tags"
  code="table_country_code.{country}"
/>

where {} is an attribute value template that evaluates the XPath country

Upvotes: 2

Related Questions