{"action":"created","issue":{"url":"https://api.github.com/repos/xspec/xspec/issues/227","repository_url":"https://api.github.com/repos/xspec/xspec","labels_url":"https://api.github.com/repos/xspec/xspec/issues/227/labels{/name}","comments_url":"https://api.github.com/repos/xspec/xspec/issues/227/comments","events_url":"https://api.github.com/repos/xspec/xspec/issues/227/events","html_url":"https://github.com/xspec/xspec/issues/227","id":343984712,"node_id":"MDU6SXNzdWUzNDM5ODQ3MTI=","number":227,"title":"Cannot compare whole documents","user":{"login":"tofi86","id":365118,"node_id":"MDQ6VXNlcjM2NTExOA==","avatar_url":"https://avatars2.githubusercontent.com/u/365118?v=4","gravatar_id":"","url":"https://api.github.com/users/tofi86","html_url":"https://github.com/tofi86","followers_url":"https://api.github.com/users/tofi86/followers","following_url":"https://api.github.com/users/tofi86/following{/other_user}","gists_url":"https://api.github.com/users/tofi86/gists{/gist_id}","starred_url":"https://api.github.com/users/tofi86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tofi86/subscriptions","organizations_url":"https://api.github.com/users/tofi86/orgs","repos_url":"https://api.github.com/users/tofi86/repos","events_url":"https://api.github.com/users/tofi86/events{/privacy}","received_events_url":"https://api.github.com/users/tofi86/received_events","type":"User","site_admin":false},"labels":[{"id":265638291,"node_id":"MDU6TGFiZWwyNjU2MzgyOTE=","url":"https://api.github.com/repos/xspec/xspec/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-07-24T10:51:58Z","updated_at":"2018-07-26T13:48:48Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI tried to use XSpec to compare a whole document with an expected result but have multiple issues.\r\nThis is my setup:\r\n\r\n<details>\r\n <summary>article.xml</summary>\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<?xml-model href=\"http://docbook.org/xml/5.0/rng/docbook.rng\" schematypens=\"http://relaxng.org/ns/structure/1.0\"?>\r\n<?xml-model href=\"http://docbook.org/xml/5.0/rng/docbook.rng\" type=\"application/xml\" schematypens=\"http://purl.oclc.org/dsdl/schematron\"?>\r\n<article xmlns=\"http://docbook.org/ns/docbook\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"5.0\">\r\n\t<info>\r\n\t\t<title>A Short Introduction To XSpec</title>\r\n\t</info>\r\n\t<sect1>\r\n\t\t<title>A short introduction to the XSpec Unit Testing Framework</title>\r\n\t\t<para>XSpec is a unit test and <link xlink:href=\"http://en.wikipedia.org/wiki/Behavior_Driven_Development\">behaviour driven development</link> (BDD) framework for XSLT, XQuery and Schematron. It is based on the Spec framework of <link xlink:href=\"http://rspec.info/\">RSpec</link>, which is a BDD framework for Ruby.</para>\r\n\t\t<para>XSpec consists of a syntax for describing the behaviour of XSLT or XQuery code and some code that enables to test the code against those descriptions.</para>\r\n\t\t<sect2>\r\n\t\t\t<title>Getting Started</title>\r\n\t\t\t<para>To get started, check out the installation instructions for <link xlink:href=\"https://github.com/xspec/xspec/wiki/Installation-on-Mac-and-Linux\">MacOS/Linux</link> and <link xlink:href=\"https://github.com/xspec/xspec/wiki/Installation-on-Windows\">Windows</link> and how to <link xlink:href=\"https://github.com/xspec/xspec/wiki/Getting-Started\">write your first XSpec test</link>.</para>\r\n\t\t</sect2>\r\n\t\t<sect2>\r\n\t\t\t<title>Support</title>\r\n\t\t\t<para></para>\r\n\t\t</sect2>\r\n\t</sect1>\r\n</article>\r\n```\r\n</details>\r\n\r\n\r\n<details>\r\n <summary>article-to-html.xsl</summary>\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<xsl:stylesheet xmlns=\"http://www.w3.org/1999/xhtml\"\r\n\txmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\r\n\txmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n\txmlns:math=\"http://www.w3.org/2005/xpath-functions/math\"\r\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\n\txmlns:pa=\"https://www.pagina.gmbh\"\r\n\texclude-result-prefixes=\"xs math xlink pa\"\r\n\txpath-default-namespace=\"http://docbook.org/ns/docbook\"\r\n\tversion=\"3.0\">\r\n\t\r\n\t<xsl:output method=\"xhtml\" encoding=\"UTF-8\" indent=\"yes\" html-version=\"5.0\"/>\r\n\t\r\n\t\r\n\t<xsl:template match=\"/\">\r\n\t\t<xsl:apply-templates/>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"article\">\r\n\t\t<html>\r\n\t\t\t<head>\r\n\t\t\t\t<xsl:apply-templates select=\"info\"/>\r\n\t\t\t</head>\r\n\t\t\t<body>\r\n\t\t\t\t<xsl:apply-templates select=\"* except info\"/>\r\n\t\t\t</body>\r\n\t\t</html>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"info/title\">\r\n\t\t<title>\r\n\t\t\t<xsl:apply-templates/>\r\n\t\t</title>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"info/author\"/>\r\n\t\r\n\t<xsl:template match=\"sect1 | sect2\">\r\n\t\t<section>\r\n\t\t\t<xsl:apply-templates/>\r\n\t\t</section>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"sect1/title\">\r\n\t\t<h1>\r\n\t\t\t<xsl:apply-templates/>\r\n\t\t</h1>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"sect2/title\">\r\n\t\t<h2>\r\n\t\t\t<xsl:apply-templates/>\r\n\t\t</h2>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"para\">\r\n\t\t<p>\r\n\t\t\t<xsl:apply-templates/>\r\n\t\t</p>\r\n\t</xsl:template>\r\n\t\r\n\t<xsl:template match=\"link\">\r\n\t\t<a href=\"{@xlink:href}\">\r\n\t\t\t<xsl:apply-templates/>\r\n\t\t</a>\r\n\t</xsl:template>\r\n\t\r\n</xsl:stylesheet>\r\n```\r\n</details>\r\n\r\n\r\nThis is what oXygen 20 (Saxon 9.8.0_8) produces as output:\r\n\r\n<details>\r\n <summary>article_expected.html</summary>\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n   <head>\r\n      <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\r\n      \t\t\r\n      <title>A Short Introduction To XSpec</title>\r\n      \t\t\r\n      \t\r\n   </head>\r\n   <body>\r\n      <section>\r\n         \t\t\r\n         <h1>A short introduction to the XSpec Unit Testing Framework</h1>\r\n         \t\t\r\n         <p>XSpec is a unit test and <a href=\"http://en.wikipedia.org/wiki/Behavior_Driven_Development\">behaviour driven development</a> (BDD) framework for XSLT, XQuery and Schematron. It is based on the Spec framework\r\n            of <a href=\"http://rspec.info/\">RSpec</a>, which is a BDD framework for Ruby.\r\n         </p>\r\n         \t\t\r\n         <p>XSpec consists of a syntax for describing the behaviour of XSLT or XQuery code and\r\n            some code that enables to test the code against those descriptions.\r\n         </p>\r\n         \t\t\r\n         <section>\r\n            \t\t\t\r\n            <h2>Getting Started</h2>\r\n            \t\t\t\r\n            <p>To get started, check out the installation instructions for <a href=\"https://github.com/xspec/xspec/wiki/Installation-on-Mac-and-Linux\">MacOS/Linux [SECURE LINK]</a> and <a href=\"https://github.com/xspec/xspec/wiki/Installation-on-Windows\">Windows [SECURE LINK]</a> and how to <a href=\"https://github.com/xspec/xspec/wiki/Getting-Started\">write your first XSpec test [SECURE LINK]</a>.\r\n            </p>\r\n            \t\t\r\n         </section>\r\n         \t\t\r\n         <section>\r\n            \t\t\t\r\n            <h2>Support</h2>\r\n            \t\t\t\r\n            <p></p>\r\n            \t\t\r\n         </section>\r\n         \t\r\n      </section>\r\n   </body>\r\n</html>\r\n```\r\n</details>\r\n\r\nThen I wrote an XSpec scenario to compare actual transformation result with expected result from oXygen:\r\n\r\n<details>\r\n <summary>article-to-html.xspec</summary>\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<x:description xmlns:x=\"http://www.jenitennison.com/xslt/xspec\"\r\n\tstylesheet=\"article-to-html.xsl\">\r\n\t\r\n\t<x:scenario label=\"The integration test output\">\r\n\t\t<x:context href=\"article.xml\"/>\r\n\t\t<x:expect label=\"should match the expected result.\" href=\"article.html\"/>\r\n\t</x:scenario>\r\n\t\r\n</x:description>\r\n```\r\n</details>\r\n\r\nFirst of all: the results do not match:\r\n\r\n![bildschirmfoto 2018-07-24 um 12 41 58](https://user-images.githubusercontent.com/365118/43133427-01eebf88-8f3f-11e8-8677-12426dc1ab65.png)\r\n\r\nObviously it's because of the indentation which is different when the XSpec framework transforms the data.\r\n\r\nHowever, if I remove the `indent=\"yes\"` or change to \"no\", it doesn't get any better.\r\n\r\nSecond: The `method=\"xhtml\"` produces a `<meta>` element in oXygen which is totally missing in the XSpec result, as you can see on the screenshot.\r\n\r\nThird: If I change the output declaration to `<xsl:output encoding=\"UTF-8\" indent=\"no\" method=\"xml\"/>` the XSpec result seems to match the expected result from oXygen, all highlights in the HTML report are green, but the test fails anyway:\r\n\r\n![bildschirmfoto 2018-07-24 um 12 47 28](https://user-images.githubusercontent.com/365118/43133715-e7d77e54-8f3f-11e8-84ac-5f6dc4bb29fc.png)\r\n\r\nThis seems like a bug to me.\r\n\r\nFourth: When looking at the XML report, there are lots of empty `<test:ws xmlns:pkg=\"http://expath.org/ns/pkg\">` elements which seem to be irrelevant and should be removed, right?\r\n\r\n\r\n----\r\n\r\nHow can both of these issues be resolved?\r\n\r\nHow can I compare whole documents as kind of an \"integration test\"?\r\n\r\nThanks,\r\nTobias"},"comment":{"url":"https://api.github.com/repos/xspec/xspec/issues/comments/408103629","html_url":"https://github.com/xspec/xspec/issues/227#issuecomment-408103629","issue_url":"https://api.github.com/repos/xspec/xspec/issues/227","id":408103629,"node_id":"MDEyOklzc3VlQ29tbWVudDQwODEwMzYyOQ==","user":{"login":"tofi86","id":365118,"node_id":"MDQ6VXNlcjM2NTExOA==","avatar_url":"https://avatars2.githubusercontent.com/u/365118?v=4","gravatar_id":"","url":"https://api.github.com/users/tofi86","html_url":"https://github.com/tofi86","followers_url":"https://api.github.com/users/tofi86/followers","following_url":"https://api.github.com/users/tofi86/following{/other_user}","gists_url":"https://api.github.com/users/tofi86/gists{/gist_id}","starred_url":"https://api.github.com/users/tofi86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tofi86/subscriptions","organizations_url":"https://api.github.com/users/tofi86/orgs","repos_url":"https://api.github.com/users/tofi86/repos","events_url":"https://api.github.com/users/tofi86/events{/privacy}","received_events_url":"https://api.github.com/users/tofi86/received_events","type":"User","site_admin":false},"created_at":"2018-07-26T13:48:48Z","updated_at":"2018-07-26T13:48:48Z","author_association":"NONE","body":"Regarding b) I was able to come up with the following solution to only compary partial trees of result and expected:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<x:description xmlns:x=\"http://www.jenitennison.com/xslt/xspec\"\r\n  xmlns:html=\"http://www.w3.org/1999/xhtml\"\r\n  stylesheet=\"../xslt/docbook-to-html-serialized.xsl\" xslt-version=\"3.0\">\r\n  \r\n  <x:scenario label=\"The integration test\">\r\n    <x:context href=\"demo2/article.xml\"/>\r\n    <x:expect label=\"should match the expected result.\" href=\"demo2/article.html\" select=\"/html:html/html:body\"\r\n      \r\n      test=\"\r\n      /html:html/html:body\r\n      => serialize(\r\n        map {\r\n          'method': 'xhtml',\r\n          'indent': true(),\r\n          'html-version': 5.0\r\n        }\r\n      )\r\n      => parse-xml()\"/>\r\n  </x:scenario>\r\n  \r\n</x:description>\r\n```\r\n\r\nBut it only works partially.\r\n\r\n<img width=\"1244\" alt=\"bildschirmfoto 2018-07-26 um 15 46 55\" src=\"https://user-images.githubusercontent.com/365118/43266244-2e7ae95c-90eb-11e8-925f-137dde1fe905.png\">\r\n\r\nThe expected result (via `select=\"\"` attribute) is treated as document node despite selecting an element, and the result is treated as element() although the `parse-xml()` function should return a document node. I got stuck here. Any idea?"}}
{"actor":{"display_login":"tofi86"}}