- css Xml代码
- <?xml version ="1.0" encoding ="GB2312"?>
- <?xml-stylesheet type="text/css" href ="test.css"?>
- <book>
- <name>JS</name>
- </book>
- book{display:block; position:absolute; top:20px; 400 px; border:2px solid black; padding:5px; background-color;yellow; color:green; font-family:times, serif; font-style:italic;text-align:center; }
- name{display:block; position:relative; top:10 px; 300 px; height:60 px; font-weight:bold; font-size:50px; font-family:Arial,Helvetica,sans-serif; font-style:italic; color:red; }
- xsl Xml代码
- <?xml version ="1.0" encoding ="GB2312"?>
- <?xml-stylesheet type="text/xls" href ="b.xsl"?>
- <book>
- <name>JS</name>
- </book>
- <?xml version="1.0" encoding="GB2312"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
- <xsl:template match="/">
- <html>
- <head><title>XSL</title></head>
- <body>
- <xsl:apply-templates select="book" mode="1">
- </body>
- </html>
- </xsl:template>
- <xsl:template match="book" mode="1">
- <h2>
- <xsl:value-of select="name"/>
- </h2>
- </xsl:template>
- <xsl:template match="book" mode="2">
- <h3>
- <xsl:value-of select="name"/>
- </h3>
- </xsl:template>
- </xsl:stylesheet>
- xsl中的标签
- <xsl:text>xx</xsl:text>
- <xsl:for-each select = "book">
- ...
- </xsl:for-each>
- <xsl:value-of select="name"/>
- <xsl:for-each select = "book">
- ...
- </xsl:for-each>
- <xsl:if test=“表达式” >
- ...
- </xsl:if>
- <xsl:choose>
- <xsl:when test="表达式''
- …
- </xsl:when>
- <xsl:otherwise>
- …
- </xsl:otherwise>
- </xsl:choose>
- <xsl:for-each select = "book">
- <xsl:sort select = "@title"/>
- <b><xsl:value-of select = "title"/></b>
- <br/>
- <b><xsl:value-of select = "price"/></b>
- <br/>
- </xsl:for-each>
- <xsl:sort select=string-expression
- data-type={"text"|"number"}
- order={"ascending"|"descending"}
- case-order={"upper-first"|"lower-first"}/>
- <xsl:value-of select="nodeName/@attributeName"/>或者
- <xsl:for-each select="price">
- <h1>:<xsl:value-of select="@unit"/></h1>
- </xsl:for-each>
test.css
Css代码
Xml代码
在上面的例子中我们大概的可以看到一个xsl文件的框架,它有xsl:stylesheet包围,里面包括了三个匹配模式(其中一个主匹配模式,两个从匹配模式),还有一个执行模式xsl:apply-templates
xsl:text
Xml代码
xsl:for-each
Xml代码
xsl:value-of
Xml代码
xsl:for-each
Xml代码
xsl:if
Xml代码
疑问:xsl:if能否实现正值表达式。
xsl:choose, xsl:when和xsl:otherwise
Xml代码
xsl:sort
Xml代码
引:xsl:sort能否实现自定义排序。大案是是可以得
Xml代码
参数:data-type它的值常用的是text,number。text是指数据被当作字符串进行排序,number则是把数据转换为数字,按照数值进行排序。缺省的值是text
Order属性指定排序时是按照升序(ascending)还是降序(descending),缺省的情况是升序。
case-order属性是指按字母表顺序排时,大写在前还是小写在前
xsl读取某个节点的属性
Xml代码