0

我有一个 XSLT 模板可以转换它:

<WGS__LAT>N20340000</WGS__LAT>

对此:

<latitude>
    <deg>20</deg>
    <min>34</min>
    <sec>00</sec>
    <hSec>00</hSec>
    <northSouth>North</northSouth>
</latitude>

我写了一个 XSpec 场景来测试 XSLT 模板:

<x:scenario label="location/latitude: Check that the XSLT assigns latitude the split-up value of WGS__LAT">
    <x:context>
        <WGS__LAT>N20340000</WGS__LAT>
    </x:context>
    
    <x:expect label="Expect: deg=20, min=34, sec=00, hSec=00, northSouth=North">
        <latitude>
            <deg>20</deg>
            <min>34</min>
            <sec>00</sec>
            <hSec>00</hSec>
            <northSouth>North</northSouth>
        </latitude>
    </x:expect>
</x:scenario>

我确定我的 XSLT 模板可以正常工作,那么为什么 XSpec 工具会报告 FAILED?我认为这可能与 <x:expect> 中的空格有关,所以我删除了所有空格:

<x:expect label="Expect: deg=20, min=34, sec=00, hSec=00, northSouth=North">
    <latitude><deg>20</deg><min>34</min><sec>00</sec><hSec>00</hSec><northSouth>North</northSouth></latitude>
</x:expect>

不幸的是,我仍然失败了。我究竟做错了什么?

4

1 回答 1

1

如果没有完整的报告,尤其是你实际得到的,很难回答。但是:在这种情况下,一个出发点是将您的上下文包装在另一个标签中,并在 xspec 中设置结果的哪一部分应该匹配。就像是 :

<x:context>
  <foo>
    <WGS__LAT>N20340000</WGS__LAT>
  </foo>
</x:context>
<x:expect label="..." test="/foo/*" as="element(latitude)">
  <latitude>
    <deg>20</deg>
    <min>34</min>
    <sec>00</sec>
    <hSec>00</hSec>
    <northSouth>North</northSouth>
  </latitude>
</x:expect>

您可以查看wiki以更精确地使用期望。

然后,将实际结果和预期结果与fn:deep-equals(...)方法进行比较。因此,没有对结果或预期的输出处理。如果您使用@hrefonx:context或 on x:expect,则存在空间标准化,但我对此并不完全确定。你可以看看这个关于缩进问题的问题;这是一个相当长且仍然开放的线程。

于 2020-11-30T19:25:45.290 回答