In my web application, I display the search results using XSLT.
There are some hard coded text in XSLT file which I want to make language independent.
XSLT:
<xsl:if test="$IsEmpty">
<table cellpadding="5" cellspacing="0" border="1" style="width:100%;border-top-style:solid;border-bottom-style:solid;border-left-style:solid;border-right-style:solid;border-top-color:gray;border-bottom-color:gray;border-left-color:gray;border-right-color:gray;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;">
<tr>
<td style="text-align:center;">
There are no blog posts to display.
</td>
</tr>
</table>
</xsl:if>
Is it possible to pick the text "There are no blog posts to display." from a resource file?
I’m assuming that by “resource file” you mean a regular resx that is compiled into the assembly. In which case, not directly from xslt; however, you could add an extension object and use a key-base approach, i.e.
The “resx” alias would be mapped (
xmlns) to a uri that you use when creating your xslt wrapper in C#. For example, with thexmlns(in the xslt preamble):we can map that in C# via:
and attach this to the namespace:
We now have full control to inject managed code (as extensions) into our xslt.