0
<td class="num">
                                        <xsl:if test="min(//vrednostDelnice)=trgovalniPodatki/vrednostDelnice">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//vrednostDelnice)=trgovalniPodatki/vrednostDelnice">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="format-number(trgovalniPodatki/vrednostDelnice, '#.###,00 €', 'euro')"/>
                                    </td>

但我明白了

This document had an invalid XSLT stylesheet. Error message from the XSLT engine:
Error: XPath expression compilation failed: min(//vrednostDelnice)=trgovalniPodatki/vrednostDelnice
Details: compilation error (characters 1-22, "min(//vrednostDelnice)"): unknown function called: 'min'

为什么 min 无法识别。Min 的有效函数:http ://www.xsltfunctions.com/xsl/fn_min.html

编辑:

XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:output method="xhtml" version="1.0" encoding="UTF-8" indent="yes"/>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="odlocitvenProblem.xsl"?>
<delnice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="odlocitvenProblem.xsd">

整个xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:output method="xhtml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
    <xsl:variable name="kolicnik" select="'1000'"/>
    <xsl:key name="id" match="delnica" use="@id"/>
    <xsl:template match="/">
        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                <title>Delnice - seznam alternativ</title>
                <style type="text/css">
                    body {font: normal 12px/1.6em Arial, Helvetica, sans-serif;color: #2a3845;margin: 0;padding-left: 5px;padding-right: 5px; background: #FFFFFF; width: 100%; }
                    table { margin: 0;padding  0; border: 1px solid #efece7; margin: 0 auto; font : normal 12px/1.6em Arial, Helvetica, sans-serif;color: #2a3845; width: 100%; border-collapse: collapse; }
                    td { border: 1px solid #efece7; padding: 2px; }
                    th { border: 1px solid #efece7; padding: 2px; }
                    td.num { text-align: right;}
                    td.green { text-align: right; color: green;}
                    td.red { text-align: right; color: red;}
                    h1 { color: #7a2e40;margin: 0px 0px 10px 0px;padding-bottom: 10px;font: normal 17px Georgia, serif;border-bottom: 1px solid #efece7;}
                    #wrapper {margin: 0 auto;border-left: 1px solid #f0e9eb;border-right: 1px solid #f0e9eb;}
                    #header {margin: 0 0px; background: #7a2e40;color: #f6dde3; height: 30px;}
                    #main-content { margin: 0 auto; float: left; padding-top: 30px; padding-right: 10px; padding-bottom: 30px; padding-left: 10px;}
                    #footer {background: #f7f7f7; border-top: 1px solid #f0e9eb; border-bottom: 1px solid #f0e9eb; clear: both; height: 30px; }
                    tr.footer { font-size: 10px; vertical-align: top;}
                </style>
            </head>
            <body>
                <div id="wrapper">
                    <div id="header">&#160;</div>
                    <div id="main-content">
                        <h1>Delnice - seznam alternativ</h1>
                        <br/>
                        <table cellspacing="0">
                            <tr>
                                <th rowspan="2"></th>
                                <th rowspan="2">Naziv</th>
                                <th rowspan="2">Kratica</th>
                                <th rowspan="2">Vrednost delnice<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='vrednostDelnice']/@utez"/>)
                                </th>
                                <th colspan="3">Sprememba tečaja</th>
                                <th rowspan="2">Vrednost dividende<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='vrednostDividende']/@utez"/>)
                                </th>
                                <th rowspan="2">Dividendni donos<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='dividendniDonos']/@utez"/>)
                                </th>
                                <th rowspan="2">Promet<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='promet']/@utez"/>)
                                </th>
                                <th rowspan="2">Tržna kapitalizacija<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='trznaKapitalizacija']/@utez"/>) *
                                </th>
                                <th rowspan="2">Število delnic</th>
                                <th rowspan="2">Čisti dobiček<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='cistiDobicek']/@utez"/>) *
                                </th>
                                <th rowspan="2">Finančna sredstva<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='financnaSredstva']/@utez"/>) *
                                </th>
                            </tr>
                            <tr>
                                <th>Letna<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='zadnjeLeto']/@utez"/>)
                                </th>
                                <th>Mesečna<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='zadnjiMesec']/@utez"/>)
                                </th>
                                <th>Dnevna<br/>
(<xsl:value-of select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='zadnjiDan']/@utez"/>)
                                </th>
                            </tr>
                            <xsl:for-each select="/delnice/*">
                                <xsl:sort select="nazivDruzbe"/>
                                <xsl:call-template name="alternative">
                                    <xsl:with-param name="node" select="."/>
                                </xsl:call-template>
                            </xsl:for-each>
                            <tr class="footer">
                                <td></td>
                                <td></td>
                                <td></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='vrednostDelnice']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='zadnjeLeto']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='zadnjiMesec']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='zadnjiDan']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='vrednostDividende']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='dividendniDonos']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='promet']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja" /> - <xsl:value-of select="zgMeja" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='trznaKapitalizacija']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja div number($kolicnik)" /> - <xsl:value-of select="zgMeja div 1000" />
                                    <br/>
                                </xsl:for-each></td>
                                <td></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='cistiDobicek']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja div number($kolicnik)" /> - <xsl:value-of select="zgMeja div 1000" />
                                    <br/>
                                </xsl:for-each></td>
                                <td><xsl:for-each select="document('uteziParametrov.xml')/uteziDelnic/parameter[@naziv='financnaSredstva']/zalogaVrednosti">
                                    <xsl:value-of select="@ocena"/>:&#160;<xsl:value-of select="spMeja div number($kolicnik)" /> - <xsl:value-of select="zgMeja div 1000" />
                                    <br/>
                                </xsl:for-each></td>
                            </tr>
                        </table>
                        <span style="font-size: 80%;">* v <xsl:value-of select="$kolicnik"/></span>
                    </div>
                    <div id="footer">&#160;</div>
                </div>
            </body>
        </html>
    </xsl:template>

    <xsl:template name="alternative">
        <xsl:param name="node"/>
            <tr>
                <td>
                    <xsl:number value="position()" format="1" />
                </td>
                <td>
                    <xsl:value-of select="$node/nazivDruzbe"/>
                </td>
                <td>
                    <xsl:value-of select="kratica"/>
                </td>
                                    <td class="num">
                                        <xsl:if test="fn:min(//vrednostDelnice)=trgovalniPodatki/vrednostDelnice">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//vrednostDelnice)=trgovalniPodatki/vrednostDelnice">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="format-number(trgovalniPodatki/vrednostDelnice, '#.###,00 €', 'euro')"/>
                                    </td>
                                    <td class="num">
                                        <xsl:if test="min(//zadnjeLeto)=trgovalniPodatki/spremembaTecaja/zadnjeLeto">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//zadnjeLeto)=trgovalniPodatki/spremembaTecaja/zadnjeLeto">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="trgovalniPodatki/spremembaTecaja/zadnjeLeto"/>%</td>
                                    <td class="num">
                                        <xsl:if test="min(//zadnjiMesec)=trgovalniPodatki/spremembaTecaja/zadnjiMesec">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//zadnjiMesec)=trgovalniPodatki/spremembaTecaja/zadnjiMesec">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="trgovalniPodatki/spremembaTecaja/zadnjiMesec"/>%</td>
                                    <td class="num">
                                        <xsl:if test="min(//zadnjiDan)=trgovalniPodatki/spremembaTecaja/zadnjiDan">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//zadnjiDan)=trgovalniPodatki/spremembaTecaja/zadnjiDan">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="trgovalniPodatki/spremembaTecaja/zadnjiDan"/>%</td>
                                    <td class="num">
                                        <xsl:if test="min(//vrednostDividende)=trgovalniPodatki/vrednostDividende">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//vrednostDividende)=trgovalniPodatki/vrednostDividende">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="trgovalniPodatki/vrednostDividende"/>
                                    </td>
                                    <td class="num">
                                        <xsl:if test="min(//dividendniDonos)=trgovalniPodatki/dividendniDonos">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//dividendniDonos)=trgovalniPodatki/dividendniDonos">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="trgovalniPodatki/dividendniDonos"/>%</td>
                                    <td class="num">
                                        <xsl:if test="min(//promet)=trgovalniPodatki/promet">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//promet)=trgovalniPodatki/promet">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="trgovalniPodatki/promet"/>
                                    </td>
                                    <td class="num">
                                        <xsl:if test="min(//trznaKapitalizacija)=trgovalniPodatki/trznaKapitalizacija">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//trznaKapitalizacija)=trgovalniPodatki/trznaKapitalizacija">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="format-number(trgovalniPodatki/trznaKapitalizacija div number($kolicnik), '###.###.###', 'euro')"/>
                                    </td>
                                    <td class="num">
                                        <xsl:value-of select="financniPodatki/steviloDelnic"/>
                                    </td>
                                    <td class="num">
                                        <xsl:if test="min(//cistiDobicek)=financniPodatki/cistiDobicek">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//cistiDobicek)=financniPodatki/cistiDobicek">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="financniPodatki/cistiDobicek div number($kolicnik)"/>
                                    </td>
                                    <td class="num">
                                        <xsl:if test="min(//financnaSredstva)=financniPodatki/financnaSredstva">
                                            <xsl:attribute name="class">red</xsl:attribute>
                                        </xsl:if>
                                        <xsl:if test="max(//financnaSredstva)=financniPodatki/financnaSredstva">
                                            <xsl:attribute name="class">green</xsl:attribute>
                                        </xsl:if>
                                        <xsl:value-of select="financniPodatki/financnaSredstva div number($kolicnik)"/>
            </td>
        </tr>
    </xsl:template>
</xsl:stylesheet>
4

2 回答 2

1

min函数是 XSLT 和 XPath 2.0 的一部分,并且这种方式受到 Saxon 9、AltovaXML 或 XmlPrime 等 XSLT 2.0 处理器的支持。除非您使用Saxon-CE,否则在浏览器内部不支持 XSLT 2.0 。因此,您得到的错误仅仅意味着您正在尝试使用 XSLT 1.0 处理器运行 XSLT 2.0 代码。

于 2012-07-27T09:03:24.517 回答
1

如果您调用的 XSLT 处理器只理解 XSLT 1.0,那么说您的样式表是 2.0 版样式表是没有用的。我不认识您收到的错误消息,并且您的帖子中没有其他线索说明您正在使用哪个 XSLT 处理器,但它似乎是 XSLT 1.0 处理器。告诉我们您是如何运行转换的,例如从命令行、浏览器或某种编程语言的应用程序。

于 2012-07-27T10:37:07.850 回答