Skip to content

Commit 776c1e6

Browse files
Namespaces (#69)
* Setting up unit test. * Refactoring `xPathLog`, `xPathMatchRule` and `XPathTokenRule`. * - Assigning a few types to variables; - Still no good to refactor `prec` property. * Another round of refactoring. * Typing node values and node tests with interfaces. * - Version validation on `<xsl:stylesheet>`/`<xsl:transform>`; - Version now is required in XSLT input stylesheet. * Matching nodes when namespace prefix is set. * If node has a `namespaceUri` set, `<xslt:copy>` adds as an attribute for output. * When testing name with namespace prefix, consider only the local name.
1 parent a136d81 commit 776c1e6

35 files changed

+678
-489
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"runtimeArgs": [
1212
"--inspect-brk",
1313
"${workspaceRoot}/node_modules/jest/bin/jest.js",
14-
// "xslt.test",
14+
// "local-name.test",
1515
"--runInBand"
1616
],
1717
"skipFiles": ["<node_internals>/**", "node_modules/**"],

src/dom/functions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ const XML11_TAGNAME_REGEXP = new RegExp(`^(${XML11_NAME})`);
3030
const XML11_ATTRIBUTE_REGEXP = new RegExp(XML11_ATTRIBUTE, 'g');
3131

3232
// Wrapper around DOM methods so we can condense their invocations.
33-
export function domGetAttributeValue(node: any, name: any) {
33+
export function domGetAttributeValue(node: any, name: string) {
3434
return node.getAttributeValue(name);
3535
}
3636

37-
export function domSetAttribute(node: XNode, name: any, value: any) {
37+
export function domSetAttribute(node: XNode, name: string, value: any) {
3838
return node.setAttribute(name, value);
3939
}
4040

41-
export function domSetTransformedAttribute(node: XNode, name: any, value: any) {
41+
export function domSetTransformedAttribute(node: XNode, name: string, value: any) {
4242
return node.setTransformedAttribute(name, value);
4343
}
4444

src/dom/util.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export function mapExpr(array, func) {
2626
return ret;
2727
}
2828

29-
// Reverses the given array in place.
29+
/**
30+
* Reverses the given array in place.
31+
* @param array The array to be reversed.
32+
*/
3033
export function reverseInPlace(array: any[]) {
3134
for (let i = 0; i < array.length / 2; ++i) {
3235
const h = array[i];

src/xpath/expressions/location-expr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ExprContext } from "../../xslt/expr-context";
22
import { NodeSetValue } from "../values/node-set-value";
3-
import { NodeTestAny } from "../node-test-any";
3+
import { NodeTestAny } from "../node-tests/node-test-any";
44
import { xPathAxis } from "../tokens";
55
import { Expression } from "./expression";
66
import { XPath } from "../xpath";

src/xpath/expressions/step-expr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DOM_ATTRIBUTE_NODE } from '../../constants';
22
import { XNode } from '../../dom';
33
import { ExprContext } from '../../xslt/expr-context';
44
import { NodeSetValue } from '../values/node-set-value';
5-
import { NodeTestAny } from '../node-test-any';
5+
import { NodeTestAny } from '../node-tests/node-test-any';
66
import { xPathAxis } from '../tokens';
77
import { Expression } from './expression';
88
import { XPath } from '../xpath';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { XPathTokenRule } from "./xpath-token-rule";
2+
3+
export type GrammarRuleCandidate = {
4+
tag: XPathTokenRule,
5+
rule?: any,
6+
match: any,
7+
prec?: number,
8+
expr?: any
9+
};

src/xpath/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
export * from '../xslt/expr-context';
2-
export * from './node-test-any';
3-
export * from './node-test-comment';
4-
export * from './node-test-element-or-attribute';
5-
export * from './node-test-name';
6-
export * from './node-test-nc';
7-
export * from './node-test-pi';
8-
export * from './node-test-text';
92
export * from './xpath';
3+
export * from './xpath-token-rule';

src/xpath/node-test-any.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/xpath/node-test-comment.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/xpath/node-test-element-or-attribute.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)