TestXML.xml

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<body>
    
<xsl:for-each select="PERSONNEL/PERSON">
    
<xsl:value-of select="NAME"/>
        
<xsl:choose>
        
<xsl:when test="./FG = 'boy'">
        
<input type="text">
        
<xsl:attribute name="value">
        
<xsl:value-of select="NAME"/>
        
</xsl:attribute>
        
</input>
        
<br/>
        
</xsl:when>
        
<xsl:when test="./FG = 'girl'">
        
<font color="red"><li><xsl:value-of select="NAME"/></li></font>
        
<br/>
        
</xsl:when>
        
<xsl:otherwise>
        
<font color="blue"><xsl:value-of select="NAME"/></font>
        
</xsl:otherwise>
        
</xsl:choose>
    
    
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

TestXML.xsl

<PERSONNEL>
<PERSON>
<NAME>MALE</NAME>
<FG>boy</FG>
</PERSON>
<PERSON>
<NAME>FEMALE</NAME>
<FG>girl</FG>
</PERSON>
<PERSON>
<NAME>DO NOT KNOW</NAME>
<FG>donot know</FG>
</PERSON>
</PERSONNEL>

TestXML.asp

<%
Set xml=Server.CreateObject("Microsoft.XMLDOM")
xml.async 
= false
xml.load server.mappath(
"TestXML.xml")
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async 
= false
xsl.load(server.mappath(
"testXML.xsl"))
xml.transformNodeToObject xsl, Response 
'Response.Write xml.transformNode(xsl)
%>
posted on 2007-05-08 11:00  Caviare  阅读(221)  评论(0编辑  收藏  举报