100分,求最大值问题,不甚感激
eisp3.xml
<?xml version= "1.0 " encoding= "gb2312 "?>
<?xml-stylesheet type= "text/xsl " href= "./eisp3.xslt "?>
<ROOT>
<STRUCTS>
<DESCRIBE> tableName </DESCRIBE>
<HORIZONTAL> field </HORIZONTAL>
<STRUCT>
<COLUMN_NAME> AAAA </COLUMN_NAME>
<COLUMN_DESC> fie1d1 </COLUMN_DESC>
</STRUCT>
<STRUCT>
<COLUMN_NAME> BBBB </COLUMN_NAME>
<COLUMN_DESC> field2 </COLUMN_DESC>
</STRUCT>
<STRUCT>
<COLUMN_NAME> CCCC </COLUMN_NAME>
<COLUMN_DESC> field3 </COLUMN_DESC>
</STRUCT>
</STRUCTS>
<DATA_ROOT>
<DATA_ROW>
<AAAA> 100 </AAAA> <!--此处的AAAA为节点COLUMN_NAME的值-->
<BBBB> 12 </BBBB>
<CCCC> 222 </CCCC>
</DATA_ROW>
<DATA_ROW>
<AAAA> 55 </AAAA>
<BBBB> 83 </BBBB>
<CCCC> 12 </CCCC>
</DATA_ROW>
<DATA_ROW>
<AAAA> 111 </AAAA>
<BBBB> 99 </BBBB>
<CCCC> 65 </CCCC>
</DATA_ROW>
</DATA_ROOT>
</ROOT>
eisp3.xslt
<?xml version= "1.0 " encoding= "gb2312 "?> <!-- DWXMLSource= "eisp1.xml " -->
<xsl:stylesheet version= "1.0 "
xmlns:xsl= "http://www.w3.org/1999/XSL/Transform "
xmlns:msxsl= "urn:schemas-microsoft-com:xslt "
xmlns:user= "http://mycompany.com/mynamespace ">
<msxsl:script implements-prefix= 'user ' language= 'javascript '>
<![CDATA[
function getNode(parentNode,name){
var tempNode = name.nextNode().firstChild.nodeValue;
var getNodes = parentNode.nextNode().selectSingleNode( "./ " + tempNode);
if(getNodes != null){
return getNodes;
}else{
return " ";
}
}
]]>
</msxsl:script>
<xsl:template match= "/ ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 "/>
<title> EISP </title>
</head>
<body>
<xsl:for-each select= "./ROOT/DATA_ROOT/DATA_ROW ">
<xsl:variable name= "currentNode " select= "current() "/>
<xsl:for-each select= "/ROOT/STRUCTS/STRUCT ">
<xsl:variable name= "cn ">
<xsl:value-of select= "./COLUMN_NAME "/>
</xsl:variable>
<xsl:value-of select= "user:getNode($currentNode,$cn) "/>
</xsl:for-each>
</xsl:for-each>
<br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
在eisp3.xml中,节点 <DATA_ROW> 下的节点全是根据 <STRUCT> 节点下 <COLUMN_NAME> 的内容而来。现在我要解决的问题就是:要求出 <DATA_ROW> 下所有节点中的最大值。按照我的这个XML文件,最大值应该就是222。
[解决办法]
为什么是222?
[解决办法]
<xsl:for-each select= "./ROOT/DATA_ROOT/DATA_ROW ">
这里是否可以用xsl内部函数max呢?记得有这样函数的。
</xsl:for-each>