茂爷的博客
:: 向左走向右走::

在相遇的城市迷失之前
寻找一张似曾相识的脸
握在手中的风筝
断了线
是因为我寂寞
你才出现
还是你的存在让我自怜
缘分走过我身边
变成答录机遥远的留言
甜蜜在梦幻的一瞬间
留下了真实的思念
一段情就能连接两个人的天
一条路就能让两个人霎那之间
命运都改变
只要愿意相信就能相见
一滴泪就能挡住两个人的天
模糊我的视线
呼唤着你名字
从起点回到原点
两条平行线总有交汇的一天
是命运在转变
你才出现
还是你的出现让我改变
一个巧合的意外
变成一场最执着的迷恋
甜蜜在梦幻的一瞬间
留下了真实的思念

在xsl中使用导入另外一个xsl,使用的方式是<xsl:import> ,import 一个style sheet 和include一个style sheet一致,
没有太大的区别
<xsl:import> 允许添加其他的顶级标签
它的子标签允许加说有在<xsl:stylesheet>标签允许下的标签

使用原来通过<xsl:import href="arith.xsl"/> 方式引入的文件中template 来处理当前节点。
如下<xsl:apply-imports/>的当前节点就是op
在它所在文件(ops.xsl)中引入了arith.xsl文件找到它对应的template.来处理。

Xml
<?xml version="1.0"?>
            <?xml-stylesheet type="text/xsl" href="ops.xsl"?>
            <ops>
            <desc>Some binary operations</desc>
            <op name="add" symbol="+">
            <operand>1</operand>
            <operand>2</operand>
            </op>
            <op name="sub" symbol="-">
            <operand>1</operand>
            <operand>2</operand>
            </op>
            <op name="mul" symbol="*">
            <operand>1</operand>
            <operand>2</operand>
            </op>
            </ops>
            

Main XSLT File (ops.xsl)

Xml
<?xml version="1.0"?>
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            version="1.0">
            <xsl:import href="arith.xsl"/>
            <xsl:template match="op">
            <xsl:value-of select="operand[1]"/>
            <xsl:value-of select="@symbol"/>
            <xsl:value-of select="operand[2]"/>
            = <xsl:apply-imports/>
            <br/>
            </xsl:template>
            </xsl:stylesheet>
            
Imported XSLT File (arith.xsl)
<?xml version="1.0"?>
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            version="1.0">
            <xsl:template match="op[@symbol='+']">
            <xsl:value-of select="sum(operand)"/> (from arith.xsl)
            </xsl:template>
            <xsl:template match="op[@symbol='-']">
            <xsl:value-of select="number(operand[1])-number(operand[2])"/>
            (from arith.xsl)
            </xsl:template>
            <xsl:template match="op[@symbol='*']">
            <xsl:value-of select="number(operand[1])*number(operand[2])"/>
            (from arith.xsl)
            </xsl:template>
            </xsl:stylesheet>

Imported XSLT File (str.xsl)

Xml
<?xml version="1.0"?>
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            version="1.0">
            <xsl:template match="desc">
            <DIV><xsl:value-of select="."/></DIV>
            </xsl:template>
            <xsl:template match="op[@name='add']">
            <xsl:value-of select="operand[1]"/>
            <xsl:value-of select="operand[2]"/> (from str.xsl)
            </xsl:template>
            <xsl:template match="op[@name='mul']">
            <xsl:value-of select="operand[2]"/>
            <xsl:value-of select="operand[1]"/> (from str.xsl)
            </xsl:template>
            </xsl:stylesheet>
output:
Some binary operations
1+2 = 12 (from arith.xsl)
1-2 = -1 (from arith.xsl)
1*2 = 21 (from arith.xsl)


注意


ops.xsl文件加红色背景的部分如果在
<xsl:import href="arith.xsl"/> 后加上
<xsl:import href="str.xsl"/>
那么显示就变成了

Some binary operations
1+2 = 12 (from str.xsl)
1-2 = -1 (from arith.xsl)
1*2 = 21 (from str.xsl)


原因
后面覆盖前面。



ok
今天就说这个节点了。
后续加上
 
 
 
微软的
posted on 2006-06-19 15:58  茂爷的blog  阅读(516)  评论(2)    收藏  举报