switch between three xsl?

wxdqz

New Member
Hi all,
I've one xml file and three xsl files, how could I add three links to each xsl files so that I can switch between different xsl when viewing the xml?

xml.xml

<?xml version="1.0" encoding="Big5"?>
<?xml:stylesheet type="text/xsl" href=http://www.webdeveloper.com/forum/archive/index.php/"P.xsl"?>
<file>
<data pid="1">
<ename>fine</ename>
<cname></cname>
<pname>muito bem</pname>
</data>
</file>


E.xsl

<?xml version="1.0" encoding="big5"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<a>English</a>
<a href="#" onclick="javascript:document.write(titles.transformNode(detailXSL0.documentElement))"> Chinese</a>
<a href="#" onclick="javascript:document.write(titles.transformNode(detailXSL2.documentElement))"> Portuguese</a>
<XML ID="titles" SRC="xml.xml"></XML>
<XML ID="detailXSL0" SRC="C.xsl"></XML>
<XML ID="detailXSL2" SRC="P.xsl"></XML><br/>
<xsl:for-each select="file/data">
<xsl:apply-templates select="ename"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="ename">
<xsl:value-of select="."/><br/>
</xsl:template>
</xsl:stylesheet>



P.xsl

<?xml version="1.0" encoding="big5"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<a>Portuguese</a>
<a href="#" onclick="javascript:document.write(titles.transformNode(detailXSL0.documentElement))"> Chinese</a>
<a href="#" onclick="javascript:document.write(titles.transformNode(detailXSL2.documentElement))"> English</a>
<XML ID="titles" SRC="xml.xml"></XML>
<XML ID="detailXSL0" SRC="C.xsl"></XML>
<XML ID="detailXSL2" SRC="E.xsl"></XML><br/>
<xsl:for-each select="file/data">
<xsl:apply-templates select="pname"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="pname">
<xsl:value-of select="."/><br/>
</xsl:template>
</xsl:stylesheet>



C.xsl

<?xml version="1.0" encoding="big5"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<a>chinese</a>
<a href="#" onclick="javascript:document.write(titles.transformNode(detailXSL0.documentElement))"> English</a>
<a href="#" onclick="javascript:document.write(titles.transformNode(detailXSL2.documentElement))"> Portuguese</a>
<XML ID="titles" SRC="xml.xml"></XML>
<XML ID="detailXSL0" SRC="E.xsl"></XML>
<XML ID="detailXSL2" SRC="P.xsl"></XML><br/>
<xsl:for-each select="file/data">
<xsl:apply-templates select="cname"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="cname">
<xsl:value-of select="."/><br/>
</xsl:template>
</xsl:stylesheet>



The first click is ok, however, the second link will show duplicate contents, what's wrong? Thanks
 
Back
Top