Trouble with expectations and test attribute

71 views
Skip to first unread message

Tom

unread,
Dec 23, 2011, 9:10:45 AM12/23/11
to XSpec
Hi,

I've run into a problem when trying to test for expectations with a
test attribute.
<x:expect label="structure test" test="/div">

I always get the following error:

Error on line 163 of test-transform.xsl:
XPDY0050: The root of the tree containing the context item is not a
document node
Transformation failed: Run-time errors were reported

This happens whenever I use the test attribute and fill its value with
anything other than xpath axes. When I remove the test attribute,
everything works as expected.

Could anyone please put me in the right direction, as I do not
understand my error here. I've tried to follow the WritingScenarios
tutorial page (http://code.google.com/p/xspec/wiki/
WritingScenarios#Expectations), where in my eyes the same thing is
attempted.

I've pasted the contents of the files I used below.

Thank you in advance for any help,
Tom

---
My xspec-file:
<?xml version="1.0" encoding="UTF-8"?>

<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
stylesheet="../transformation.xsl">

<x:scenario label="test transformation.xsl">
<x:context href="../source/input.xml" />

<x:expect label="only one div element" test="count(/div)=1" />
<x:expect label="zero or more span elements" test="count(/div/
span)>=0" />
<x:expect label="structure test" test="/div">
<span>...</span>
<span>...</span>
</x:expect>
</x:scenario>
</x:description>

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

<xsl:output method="html" />

<xsl:template match="/divider">
<div>
<xsl:for-each select="*">
<span><xsl:apply-templates/></span>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>

And my input.xml:
<?xml version="1.0" encoding="UTF-8"?>

<divider>
<section>This is section A.</section>
<section>This is section B.</section>
</divider>

Tom

unread,
Dec 23, 2011, 10:02:47 AM12/23/11
to XSpec
Sorry, I forgot to mention the software I'm using:
-xspec-0.4.0rc1
-saxon 9.4.0.1 (HE)
Reply all
Reply to author
Forward
0 new messages