Yuan Yijun (bbbush) wrote,
Yuan Yijun

又开始写 XSLT 了

    <xsl:template name="strings-next-string">
        <xsl:param name="strings"/>
        <xsl:param name="string"/>
        <xsl:variable name="pre" select="substring-before($strings, $string)"/>
        <xsl:variable name="splt" select="concat(substring('|', 1 div ($pre != '')), $string, substring('|', 1 div ($string != '')))"/>
        <xsl:variable name="post" select="substring-after($strings, $splt)"/>
        <xsl:value-of select="substring-before(concat($post, '|', $post), '|')"/>

开始在 xslt 里设计 unittext,不然每次调程序都保留不下来,改了代码就得从头调试。

就是加了一个 unittest.xsl 和一个 xxxx-test.xsl,然后调来调去。昨天只写了 unary test,今天发现只要能传一个参数就能传无数个,因为一个节点可以是很大的树。框架的功能就是遍历 test case,然后调用计算函数,再把结果与期望值比较,用 message 立即中止执行。其中调用计算函数的模版需要在 xxxx-test.xsl 中重载,所有的 test case 也都记在那里。

update: 发现自己这段代码写错了,呵呵。用 AAAA|AAA|AA|A 可以测出来。
Tags: 工作

  • 2020

    Last time I wrote a review was in 2018, about 2017. Or maybe I wrote something elsewhere, maybe on Twitter? It was hard to write something freely…

  • #thotcon badge?

    [root@m4700 ~]# esptool write_flash 0x00000 /home/yuan/tracking/thotcon0x9/tc0x9.bin esptool.py v2.3.1 Connecting.... Detecting chip type...…

  • Portfolio weighted averages

    Last week I got an assignment to make a small Java library for some often used portfolio calculations. A portfolio is a collection of holdings, each…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded