XSLT的處理模型(1)
HelloWorld程序
1.helloworld.xml文件
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="text/xsl" href="hellowold.xslt"?>
<root>
<name>zhangqs008</name>
<name>清山</name>
</root>
注意:如果有中文編碼,請指定為encoding="gb2312" 方式。
2.被關聯的樣式表:helloworld.sxlt
<?xml version="1.0" encoding="gb2312" ?> <xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform"> <xsl:template match="/root"> <html> <title>this is my first xslt programm</title> <body> <xsl:for-each select="name"> <xsl:text>Hello world,This is </xsl:text> <xsl:value-of select="." /> <xsl:text> Speaking</xsl:text> <br /> <br /> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
3.在應用了上述的XSLT文檔以後,原來的XML文檔轉換為如下的HTML代碼:
<html> <title>this is my first xslt programm</title> <body>Hello world,This is zhangqs008 Speaking<br><br>Hello world,This is 清山Speaking<br><br></body> </html>
最後更新:2017-04-02 06:51:22