Skip to content

Commit 3916d7e

Browse files
Throwing errors for xsl:when and xsl:otherwise used outside xsl:choose.
1 parent 3369ca3 commit 3916d7e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/xslt/xslt.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// Copyright 2005 Google Inc.
44
// All Rights Reserved
55
//
6-
// TODO(mesch): add jsdoc comments. Use more coherent naming. Finish
7-
// remaining XSLT features.
8-
//
96
// Original author: Steffen Meschkat <mesch@google.com>
107

118
import fetch, { Headers, Request, Response } from 'node-fetch';
@@ -59,7 +56,7 @@ import { MatchResolver } from '../xpath/match-resolver';
5956
* <http://www.ecma-international.org/publications/standards/Ecma-262.htm>.
6057
*
6158
* The XSL processor API has one entry point, the function
62-
* xsltProcessContext(). It receives as arguments the starting point in the
59+
* `xsltProcess()`. It receives as arguments the starting point in the
6360
* input document as an XPath expression context, the DOM root node of
6461
* the XSL-T stylesheet, and a DOM node that receives the output.
6562
*
@@ -292,7 +289,7 @@ export class Xslt {
292289
case 'number':
293290
throw new Error(`not implemented: ${template.localName}`);
294291
case 'otherwise':
295-
throw `error if here: ${template.localName}`;
292+
throw new Error(`xsl:otherwise can't be used outside of xsl:choose.`);
296293
case 'output':
297294
this.outputMethod = xmlGetAttribute(template, 'method') as 'xml' | 'html' | 'text' | 'name';
298295
this.outputOmitXmlDeclaration = xmlGetAttribute(template, 'omit-xml-declaration');
@@ -366,7 +363,7 @@ export class Xslt {
366363
await this.xsltVariable(context, template, true);
367364
break;
368365
case 'when':
369-
throw new Error(`error if here: ${template.localName}`);
366+
throw new Error(`xsl:when can't be used outside of xsl:choose.`);
370367
case 'with-param':
371368
throw new Error(`error if here: ${template.localName}`);
372369
default:

0 commit comments

Comments
 (0)