10/22/2003: Reading XML Files Using XSLT
I'm learning how to represent non-English data in XML and ran into an article titled "Well-structured XML Goes Cosmopolitan" written by Ilari Aarnio and hosted by DevX.com. Buried in the article was an interesting technique that showed how to read XML documents from within XSLT.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:param name="currLang">en</xsl:param>
<xsl:output method="xml" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
<xsl:template match="/">
<xsl:variable name="cvData">
<xsl:text>cv-</xsl:text>
<xsl:value-of select="$currLang"/>
<xsl:text>.xml</xsl:text>
</xsl:variable>
<xsl:apply-templates select="document($cvData)"/>
</xsl:template>
<!-- add normal XSLT processing here -->
</xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:param name="currLang">en</xsl:param>
<xsl:output method="xml" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
<xsl:template match="/">
<xsl:variable name="cvData">
<xsl:text>cv-</xsl:text>
<xsl:value-of select="$currLang"/>
<xsl:text>.xml</xsl:text>
</xsl:variable>
<xsl:apply-templates select="document($cvData)"/>
</xsl:template>
<!-- add normal XSLT processing here -->
</xsl:stylesheet>
subscribe via RSS