2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018

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>


subscribe via RSS