Created
July 27, 2022 10:38
-
-
Save dmj/703daeda74340ba816f6a858c4132996 to your computer and use it in GitHub Desktop.
XSpec using throw/catch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:transform version="3.0" expand-text="yes" | |
xmlns:atop="http://www.tei-c.org/ns/atop" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:mode on-no-match="shallow-copy"/> | |
<xsl:template match="no-error-code"> | |
<xsl:message terminate="yes"/> | |
</xsl:template> | |
<xsl:template match="error-code"> | |
<xsl:message terminate="yes" error-code="atop:error"/> | |
</xsl:template> | |
</xsl:transform> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xspec:description stylesheet="example.xsl" | |
xmlns:map="http://www.w3.org/2005/xpath-functions/map" | |
xmlns:atop="http://www.tei-c.org/ns/atop" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xspec="http://www.jenitennison.com/xslt/xspec"> | |
<xspec:scenario label="Terminating w/o error code" catch="yes"> | |
<xspec:context> | |
<no-error-code/> | |
</xspec:context> | |
<!-- When terminated with an error, $xspec:resuls is a map(*) | |
rather than a node(). --> | |
<xspec:expect test="map:contains($xspec:result, 'err')"/> | |
</xspec:scenario> | |
<xspec:scenario label="Terminating with error code" catch="yes"> | |
<xspec:context> | |
<error-code/> | |
</xspec:context> | |
<xspec:expect test="$xspec:result?err?code eq QName('http://www.tei-c.org/ns/atop', 'error')"/> | |
</xspec:scenario> | |
</xspec:description> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment