示例地址如下:
http://files.cnblogs.com/mady55/jQuery+XML+XSL相册.rar
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="myworks.xsl"?>
<works>
<web>
<pic small="images/2s.jpg" big="images/2b.jpg">Jobeller</pic>
<pic small="images/2s.jpg" big="images/2b.jpg">1 Enyo</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">2</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">3</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">4</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">5</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">6</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">7</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">8</pic>
<pic small="images/2s.jpg" big="images/1b.jpg">8</pic>
</web>
</works>
下面是xsl 文件
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<link rel="Stylesheet" href="css/style.css" type="text/css"/>
<script type="text/javascript" src="js/unitpngfix.js"></script>
<script type="text/javascript" src="js/jquery-1.2.6.js"></script>
<script type="text/javascript">
var imgSrc = "";
jQuery(document).ready(function(){
jQuery(".weblist img").click(weblist_Img_Click);
jQuery("#imgBack,#bigback").click(showbigpicHide);
jQuery(".showbigpic").animate({
left:"-=746px",
opacity:"toggle"
},1);
jQuery("#bigback").load(Img_Load);
});
function Img_Load(){
jQuery("#imgLoading").hide();
jQuery("#bigback").show();
}
function weblist_Img_Click(e)
{
imgSrc = jQuery(e.target).parent().attr("href");
if(jQuery(".showbigpic").is(":visible"))
{
showbigpicHide();
}
else
{
jQuery("#imgLoading").show();
jQuery("#bigback").hide();
jQuery("#bigback").attr("src",jQuery(e.target).parent().attr("href"));
}
showbigpicShow();
return false;
}
function showbigpicShow()
{
jQuery(".showbigpic").animate({
left:'+=746px',
opacity:"toggle"
},500);
}
function showbigpicHide()
{
jQuery(".showbigpic").animate({
left:"-=746px",
opacity:"toggle"
},500,"",function(){
jQuery("#imgLoading").show();
jQuery("#bigback").hide();
jQuery("#bigback").attr("src",imgSrc);
});
}
</script>
</head>
<body>
<div id="world">
<div id="header">
</div>
<div class="showbigpic">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" class="showbigtop"></td>
</tr>
<tr>
<td bgcolor="#ffffff" class="showbigcon">
<img id="imgLoading" src="images/loading.gif" />
<img src="images/2b.jpg" id="bigback" />
</td>
<td width="38" bgcolor="#ffffff">
<a href="javascript:void(0)">
<img src="images/back.gif" id="imgBack" alt="返回" />
</a>
</td>
<td width="22" class="showbigrig"></td>
</tr>
<tr>
<td colspan="3" class="showbigbtm"></td>
</tr>
</table>
</div>
<p class="sort">
<img src="images/webtitle.gif" alt="Web Design"/>
</p>
<ul class="weblist">
<xsl:for-each select="works/web/pic">
<li>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@big" />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="@small" />
</xsl:attribute>
</xsl:element>
</xsl:element>
</li>
</xsl:for-each>
</ul>
<p class="clear"></p>
<p class="sort">
<img src="images/logotitle.gif" alt="Web Design"/>
</p>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>