Prefixes in results in Xspec HTML report

Post here questions and problems related to oXygen frameworks/document types.
Alekso
Posts: 6

Prefixes in results in Xspec HTML report

Sat Aug 06, 2016 1:44 pm

Hi all,

Does anybody know how to hide prefixes in HTML report? Please check attached picture https://photos.google.com/share/AF1QipM ... ppWkkyTkpn

As you can see there I want to compare value in one segment but instead of I have also all prefixes there.
How to use @href @select and @test correctly, if I want to see only comparable segments and their values without any prefixes?

Please share with me if you know.
Thank you in advance!

Alekso
radu_pisoi
Posts: 305
Location: Craiova

Re: Prefixes in results in Xspec HTML report

Wed Aug 10, 2016 12:50 pm

Hi,

Unfortunately I don't know any option that can be used to hide prefixes in HTML report generated by XSpec.

Could you address this question to the XSpec project? I guess the guys that manage this project might have a solution for this problem.
https://github.com/expath/xspec
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Alekso
Posts: 6

Re: Prefixes in results in Xspec HTML report

Wed Aug 10, 2016 1:05 pm

radu_pisoi wrote:Hi,

Unfortunately I don't know any option that can be used to hide prefixes in HTML report generated by XSpec.

Could you address this question to the XSpec project? I guess the guys that manage this project might have a solution for this problem.
https://github.com/expath/xspec



Hi,

Thanks for your reply I will ask them then.

Br,
Alekso
cirulls
Posts: 4

Re: Prefixes in results in Xspec HTML report

Sun Aug 21, 2016 3:25 pm

Hi,

I can't see a way to hide prefixes in XSpec but you can use @select and nested scenarios to achieve something similar. Say you have this XML as starting point:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Segment_Identifier xmlns:pkg="http://expath.org/ns/pkg" xmlns:impl="urn:x-xspec:compile:xslt:impl" xmlns:tllaa="tllaa">R000</Segment_Identifier>


and you want to apply this simple identity transform in your XSLT:

Code: Select all

<?xml version="1.0" ?>
<xsl:stylesheet version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <!-- IdentityTransform -->
   <xsl:template match="/ | @* | node()">
         <xsl:copy>
               <xsl:apply-templates select="@* | node()" />
         </xsl:copy>
   </xsl:template>

</xsl:stylesheet>


you can run this XSpec test with @select in the contexts and a nested scenario:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="prefix.xsl">

  <x:scenario label="When processing &lt;Segment_Identifier&gt;">
    <x:context href="prefix.xml" select="Segment_Identifier"/>

    <x:scenario label="and extracting its text node">
      <x:context select="node()/text()"/>

      <x:expect label="the value should match">R001</x:expect>
    </x:scenario>

  </x:scenario>
</x:description>


which will give you this HTML report:

https://gist.githubusercontent.com/cirulls/eba7c941676ccef829f37a608f256061/raw/8c410650d0baf9873bbf70d01bea12cf66a3d5c4/prefix.png

The first context selects only the element Segment_Identifier, this allows you to show in the report which element is tested. The nested scenario inherits the context from the first scenario and select its text node which is finally compared in the expect part.

Note that with this workaround you have to write a test for each element you want to test in order to identify in the HTML report which element has the wrong value. Alternatively, you can replace in the first context Segment_Identifier with the more general node(). This will allow you to test every node with a single test but you won't know in the HTML report which element has the wrong value, you'll just see there is a wrong value in one of the elements.

Hope it helps...

Sandro
Alekso
Posts: 6

Re: Prefixes in results in Xspec HTML report

Mon Aug 22, 2016 7:27 pm

cirulls wrote:Hi,

I can't see a way to hide prefixes in XSpec but you can use @select and nested scenarios to achieve something similar. Say you have this XML as starting point:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Segment_Identifier xmlns:pkg="http://expath.org/ns/pkg" xmlns:impl="urn:x-xspec:compile:xslt:impl" xmlns:tllaa="tllaa">R000</Segment_Identifier>


and you want to apply this simple identity transform in your XSLT:

Code: Select all

<?xml version="1.0" ?>
<xsl:stylesheet version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <!-- IdentityTransform -->
   <xsl:template match="/ | @* | node()">
         <xsl:copy>
               <xsl:apply-templates select="@* | node()" />
         </xsl:copy>
   </xsl:template>

</xsl:stylesheet>


you can run this XSpec test with @select in the contexts and a nested scenario:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="prefix.xsl">

  <x:scenario label="When processing &lt;Segment_Identifier&gt;">
    <x:context href="prefix.xml" select="Segment_Identifier"/>

    <x:scenario label="and extracting its text node">
      <x:context select="node()/text()"/>

      <x:expect label="the value should match">R001</x:expect>
    </x:scenario>

  </x:scenario>
</x:description>


which will give you this HTML report:

https://gist.githubusercontent.com/cirulls/eba7c941676ccef829f37a608f256061/raw/8c410650d0baf9873bbf70d01bea12cf66a3d5c4/prefix.png

The first context selects only the element Segment_Identifier, this allows you to show in the report which element is tested. The nested scenario inherits the context from the first scenario and select its text node which is finally compared in the expect part.

Note that with this workaround you have to write a test for each element you want to test in order to identify in the HTML report which element has the wrong value. Alternatively, you can replace in the first context Segment_Identifier with the more general node(). This will allow you to test every node with a single test but you won't know in the HTML report which element has the wrong value, you'll just see there is a wrong value in one of the elements.

Hope it helps...

Sandro



Hi Sandro!

You're right, currently I will use this approach when I want to compare results in some segments. Of course it is better than nothing.
Thanks for your help!

Alekso

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 2 guests