I have two XML files to render one page in XSLT. This is because I have to separate the language from the data for a multilingual website. I need to relationate data from one and other to print a value.
My index.xml:
<?xml version="1.0" encoding="utf-8"?>
<index>
<language>en</language>
<example>
<category id="1">
<href>/category/id/1</href>
</category>
<category id="2">
<href>/category/id/2</href>
</category>
</example>
</index>
Then I've a base.en.xml that looks like:
<?xml version="1.0" encoding="utf-8"?>
<language>
<category id="1">Category 1</category>
<category id="2">Category 2</category>
</language>
My incomplete index.xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="language" select="document('index.en.xml'))" />
<xsl:template match="/">
<html>
<head>
<title>Example</title>
</head>
<body>
<ul>
<xsl:apply-templates select="index/example/category" />
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="index/example/category">
<a href="{href}"></a>
</xsl:template>
</xsl:stylesheet>
Finally the desired output:
<html>
<head>
<title>Example</title>
</head>
<body>
<ul>
<li><a href="/category/id/1">Category 1</a></li>
<li><a href="/category/id/2">Category 2</a></li>
</ul>
</body>
</html>
Thanks in advance!