Xspec unit testing
Post here questions and problems related to oXygen frameworks/document types.
Xspec unit testing
Does anyone know how to test this simple code using the XSpec in XSLT?
Using Xspec is simple for testing functions from a beginner point of view but for templates that select attributes is not.
Code: Select all
<xsl:template match="@NameTitle">
<NameTitle Value="{if(. = ('Sir', 'Lady', 'Hon', 'R Hon')) then 'Other' else .}"
Description="{if(. = ('Sir', 'Lady', 'Hon', 'R Hon')) then . else ''}"/>
</xsl:template>
<xsl:template match="BusinessChannel/Contact/ContactPerson">
<PersonName>
<xsl:apply-templates select="@NameTitle"/>
<FirstName>
<xsl:value-of select="@FirstName"/>
</FirstName>
<Surname>
<xsl:value-of select="@Surname"/>
</Surname>
</PersonName>
</xsl:template>
Re: Xspec unit testing
I've done this for solving the problem:
Code: Select all
<x:scenario label="Scenario for testing template with match '@NameTitle' When processing a NameTitle attribute">
<x:scenario label="NameTitle = 'Sir'">
<x:context href="Test60%20-%20CAL.xml" select="//@NameTitle[.='Sir']"/>
<x:expect label="Produce a NameTitle element with the Value='Other' and Description='Sir'">
<NameTitle Value="Other"
Description="Sir"/>
</x:expect>
</x:scenario>
<x:scenario label="NameTitle = 'Lady'">
<x:context href="Test60%20-%20CAL.xml" select="//@NameTitle[.='Lady']"/>
<x:expect label="Produce a NameTitle element with the Value='Other' and Description='Lady'">
<NameTitle Value="Other"
Description="Lady"/>
</x:expect>
</x:scenario>
<x:scenario label="NameTitle = 'Hon'">
<x:context href="Test60%20-%20CAL.xml" select="//@NameTitle[.='Hon']"/>
<x:expect label="Produce a NameTitle element with the Value='Other' and Description='Hon'">
<NameTitle Value="Other"
Description="Hon"/>
</x:expect>
</x:scenario>
<x:scenario label="NameTitle = 'R Hon'">
<x:context href="Test60%20-%20CAL.xml" select="//@NameTitle[.='R Hon']"/>
<x:expect label="Produce a NameTitle element with the Value='Other' and Description='R Hon'">
<NameTitle Value="Other"
Description="R Hon"/>
</x:expect>
</x:scenario>
<!--
<x:scenario label="NameTitle != ('Sir', 'Lady', 'Hon', 'R Hon')">
<x:context href="Test60%20-%20CAL.xml" select="//@NameTitle"/>
<x:expect label="Produce a NameTitle element with the Value !='Other'">
<NameTitle Value="..."
Description=""/>
</x:expect>
</x:scenario>-->
</x:scenario>
-
- Posts: 1007
- Joined: Wed Nov 16, 2005 11:11 am
Re: Xspec unit testing
Post by alex_jitianu »
Hi Daniel,
Thank you for posting the solution so others might benefit from it. A small tutorial on writing scenarios can be found in the XSpec Wiki. Also, a good place to get in touch with people that have experience with XSpec is on the XSpec discussion list.
Best regards,
Alex
Thank you for posting the solution so others might benefit from it. A small tutorial on writing scenarios can be found in the XSpec Wiki. Also, a good place to get in touch with people that have experience with XSpec is on the XSpec discussion list.
Best regards,
Alex
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service