0

I have an XSLT template that transforms this:

<WGS__LAT>N20340000</WGS__LAT>

to this:

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

I wrote an XSpec scenario to test the XSLT template:

<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>

I am certain that my XSLT template works correctly, so why does the XSpec tool report FAILED? I thought it might have something to do with whitespace in <x:expect> so I removed all whitespace:

<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>

Unfortunately, I still get FAILED. What am I doing wrong?

Roger Costello
  • 3,007
  • 1
  • 22
  • 43
  • Can you show us a snipped of the test report HTML? There should be a pink area highlighting diff. See [Wiki](https://github.com/xspec/xspec/wiki/Understanding-Test-Results) for more details. – AirQuick Dec 02 '20 at 09:39

1 Answers1

1

Without having the full report, and especially what you actually get, it's difficult to answer. But : in that case, a going starting point is to wrap your context in another tag, and to set in the xspec which part of the result should match. Something like :

<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>

You may have a look at wiki for more precise use of expectations.

Then, actual result and expected result are compared with fn:deep-equals(...) method. And so, there is no output processing on result or on expect. Il you use an @href on x:context or on x:expect, then there is a space-normalization, but I'm not perfectly sure of that. You may have a look at this issue on indentation problems ; it's a quite long and still open thread.