|
-
Jul 27th, 2004, 04:33 AM
#1
Thread Starter
Addicted Member
switch between three xsl?
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
Code:
<?xml version="1.0" encoding="Big5"?>
<?xml:stylesheet type="text/xsl" href="P.xsl"?>
<file>
<data pid="1">
<ename>fine</ename>
<cname>¦n</cname>
<pname>muito bem</pname>
</data>
</file>
E.xsl
Code:
<?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
Code:
<?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
Code:
<?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
-
Jul 27th, 2004, 04:58 AM
#2
First, it's
<?xml-stylesheet
Second, in Mozilla this might work:
<?xml-stylesheet type="text/xsl" href="P.xsl" title="P" ?>
<?xml-stylesheet type="text/xsl" href="E.xsl" title="E" alternate="yes" ?>
<?xml-stylesheet type="text/xsl" href="C.xsl" title="C" alternate="yes" ?>
In IE, that won't work.
Server-side scripts might work, though.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 27th, 2004, 08:44 PM
#3
Thread Starter
Addicted Member
Thanks for reply!
Should I add this code in the xml.xml?
What about in xsl?
It seems not work!!
-
Jul 28th, 2004, 04:00 AM
#4
I said it might. Apparently, since it doesn't, there's no way to achieve what you want.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|