xsl-list
[Top] [All Lists]

[xsl] xspec: testing template matching document root

2017-03-08 03:15:58
hi group,

I have tried to post this question on the google Xspec list, but the messages didn't arrive. I hope the post is not misplaced here...

I use xspec often to test bug fixes on my company's style sheets. They helped me a lot, especially when it comes to old features: some 'fixes' appear to break them. And this is revealed by the old xspec tests. A real life saver.

One of the last bug fixes was in the template with match='/'.
It looks that this template is never executed by xspec and there is no way to activate it. Is this true? I have written a small test to show the problem:

stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    version="2.0">

  <xsl:template match="/">
    <document>
      <xsl:apply-templates/>
    </document>
  </xsl:template>

  <xsl:template match="phrases">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="phrase">
    <phrase><xsl:apply-templates/></phrase>
  </xsl:template>
</xsl:stylesheet>

xspec test:

<?xml version="1.0" encoding="UTF-8"?>

<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec";
        stylesheet="d.xslt">
  <x:scenario label="When processing a list of phrases">
    <x:context>
      <phrases>
        <phrase>Hello!</phrase>
      </phrases>
    </x:context>
    <!-- check the result -->
    <x:expect label="document element should be added">
      <document>
        <phrase status="same">Hello!</phrase>
      </document>
    </x:expect>
  </x:scenario>
</x:description>


What I try to test here is the code in the match='/' template. So the addding of node 'document'. But this test fails, because the template is not executed by xspec.
In the HTML report, xspec reports result

<phrase>Hello!</phrase>

I expect it is simply not possible what I want. My next question is: is there a way to change the stylesheet so that xspec can test the underlying code just the same?
What do you do to test the whole stylesheet with xspec?

thanks for your insights, Ruud
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] xspec: testing template matching document root, Ruud Grosmann r(_dot_)grosmann(_at_)sdu(_dot_)nl <=