xslt-processor 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/test-without-jest.js +2 -2
- package/test-without-jest.js.map +1 -1
- package/umd/xpath/expr-context.d.ts +6 -1
- package/umd/xpath/expressions/location-expr.d.ts +3 -3
- package/umd/xpath/functions/index.d.ts +2 -0
- package/umd/xpath/functions/xslt-specific.d.ts +3 -0
- package/umd/xpath/values/node-set-value.d.ts +1 -1
- package/umd/xslt/xslt.d.ts +60 -7
- package/umd/xslt-processor.js +1 -1
- package/umd/xslt-processor.js.map +1 -1
- package/xpath/expr-context.d.ts +6 -1
- package/xpath/expr-context.js +2 -1
- package/xpath/expr-context.js.map +1 -1
- package/xpath/expressions/function-call-expr.js +1 -0
- package/xpath/expressions/function-call-expr.js.map +1 -1
- package/xpath/expressions/location-expr.d.ts +3 -3
- package/xpath/expressions/location-expr.js.map +1 -1
- package/xpath/functions/index.d.ts +2 -0
- package/xpath/functions/index.js +2 -0
- package/xpath/functions/index.js.map +1 -1
- package/xpath/functions/xslt-specific.d.ts +3 -0
- package/xpath/functions/xslt-specific.js +14 -0
- package/xpath/functions/xslt-specific.js.map +1 -0
- package/xpath/values/node-set-value.d.ts +1 -1
- package/xpath/values/node-set-value.js.map +1 -1
- package/xslt/xslt.d.ts +60 -7
- package/xslt/xslt.js +376 -221
- package/xslt/xslt.js.map +1 -1
package/package.json
CHANGED
package/test-without-jest.js
CHANGED
|
@@ -44,8 +44,8 @@ function test() {
|
|
|
44
44
|
return __generator(this, function (_a) {
|
|
45
45
|
switch (_a.label) {
|
|
46
46
|
case 0:
|
|
47
|
-
xml = "<
|
|
48
|
-
xslt = "
|
|
47
|
+
xml = "<root>\n <test name=\"test1\" />\n <test name=\"test2\" />\n <test name=\"test3\" />\n <test name=\"test4\" />\n </root>";
|
|
48
|
+
xslt = "<?xml version=\"1.0\"?>\n <xsl:stylesheet version=\"1.0\">\n <xsl:template match=\"test\">\n <span><xsl:value-of select=\"@name\" /></span>\n </xsl:template>\n <xsl:template match=\"test[@name='test1']\">\n <span>another name</span>\n </xsl:template>\n <xsl:template match=\"/\">\n <div>\n <xsl:apply-templates select=\"//test\" />\n </div>\n </xsl:template>\n </xsl:stylesheet>";
|
|
49
49
|
xsltClass = new xslt_1.Xslt();
|
|
50
50
|
xmlParser = new dom_1.XmlParser();
|
|
51
51
|
parsedXml = xmlParser.xmlParse(xml);
|
package/test-without-jest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-without-jest.js","sourceRoot":"","sources":["../src/test-without-jest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAkC;AAClC,+BAA8B;AAE9B,SAAe,IAAI;;;;;;
|
|
1
|
+
{"version":3,"file":"test-without-jest.js","sourceRoot":"","sources":["../src/test-without-jest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAkC;AAClC,+BAA8B;AAE9B,SAAe,IAAI;;;;;;oBAMT,GAAG,GAAG,qKAKA,CAAC;oBA0BP,IAAI,GAAG,yfAaS,CAAC;oBAEjB,SAAS,GAAG,IAAI,WAAI,EAAE,CAAC;oBACvB,SAAS,GAAG,IAAI,eAAS,EAAE,CAAC;oBAC5B,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;oBACpC,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC/B,qBAAM,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,EAAA;;oBAAzD,IAAI,GAAG,SAAkD;oBAC/D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;;;;;CACrB;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -45,6 +45,11 @@ export declare class ExprContext {
|
|
|
45
45
|
variables: {
|
|
46
46
|
[name: string]: NodeValue;
|
|
47
47
|
};
|
|
48
|
+
keys: {
|
|
49
|
+
[name: string]: {
|
|
50
|
+
[key: string]: NodeValue;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
48
53
|
knownNamespaces: {
|
|
49
54
|
[alias: string]: string;
|
|
50
55
|
};
|
|
@@ -96,7 +101,7 @@ export declare class ExprContext {
|
|
|
96
101
|
*/
|
|
97
102
|
clone(opt_nodeList?: XNode[], opt_outputNodeList?: XNode[], opt_position?: number, opt_outputPosition?: number): ExprContext;
|
|
98
103
|
cloneByOutput(opt_outputNodeList?: XNode[], opt_outputPosition?: number, opt_outputDepth?: number): ExprContext;
|
|
99
|
-
setVariable(name?:
|
|
104
|
+
setVariable(name?: string, value?: NodeValue | string): void;
|
|
100
105
|
getVariable(name: string): NodeValue;
|
|
101
106
|
setNode(position: number): void;
|
|
102
107
|
contextSize(): number;
|
|
@@ -8,8 +8,8 @@ export declare class LocationExpr extends Expression {
|
|
|
8
8
|
steps: StepExpr[];
|
|
9
9
|
xPath: XPath;
|
|
10
10
|
constructor(xPath: XPath);
|
|
11
|
-
appendStep(s:
|
|
12
|
-
prependStep(s:
|
|
13
|
-
_combineSteps
|
|
11
|
+
appendStep(s: StepExpr): void;
|
|
12
|
+
prependStep(s: StepExpr): void;
|
|
13
|
+
private _combineSteps;
|
|
14
14
|
evaluate(context: ExprContext): NodeSetValue;
|
|
15
15
|
}
|
|
@@ -3,7 +3,7 @@ import { NodeValue } from "./node-value";
|
|
|
3
3
|
export declare class NodeSetValue implements NodeValue {
|
|
4
4
|
value: XNode[];
|
|
5
5
|
type: string;
|
|
6
|
-
constructor(value:
|
|
6
|
+
constructor(value: XNode[]);
|
|
7
7
|
stringValue(): string;
|
|
8
8
|
booleanValue(): boolean;
|
|
9
9
|
numberValue(): number;
|
package/umd/xslt/xslt.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { MatchResolver } from '../xpath/match-resolver';
|
|
|
16
16
|
* <http://www.ecma-international.org/publications/standards/Ecma-262.htm>.
|
|
17
17
|
*
|
|
18
18
|
* The XSL processor API has one entry point, the function
|
|
19
|
-
*
|
|
19
|
+
* `xsltProcess()`. It receives as arguments the starting point in the
|
|
20
20
|
* input document as an XPath expression context, the DOM root node of
|
|
21
21
|
* the XSL-T stylesheet, and a DOM node that receives the output.
|
|
22
22
|
*
|
|
@@ -68,6 +68,13 @@ export declare class Xslt {
|
|
|
68
68
|
* @protected
|
|
69
69
|
*/
|
|
70
70
|
protected xsltAttribute(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Implements `xsl:call-template`.
|
|
73
|
+
* @param context The Expression Context.
|
|
74
|
+
* @param template The template.
|
|
75
|
+
* @param output The output, used when a fragment is passed by a previous step.
|
|
76
|
+
*/
|
|
77
|
+
protected xsltCallTemplate(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
71
78
|
/**
|
|
72
79
|
* Implements `xsl:choose`, its child nodes `xsl:when`, and
|
|
73
80
|
* `xsl:otherwise`.
|
|
@@ -83,6 +90,13 @@ export declare class Xslt {
|
|
|
83
90
|
* @returns {XNode|null} If an element node was created, the element node. Otherwise, null.
|
|
84
91
|
*/
|
|
85
92
|
protected xsltCopy(destination: XNode, source: XNode): XNode;
|
|
93
|
+
/**
|
|
94
|
+
* Implements `xsl:comment`.
|
|
95
|
+
* @param context The Expression Context.
|
|
96
|
+
* @param template The template.
|
|
97
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
98
|
+
*/
|
|
99
|
+
protected xsltComment(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
86
100
|
/**
|
|
87
101
|
* Implements `xsl:copy-of` for node-set values of the select
|
|
88
102
|
* expression. Recurses down the source node tree, which is part of
|
|
@@ -91,20 +105,46 @@ export declare class Xslt {
|
|
|
91
105
|
* @param {XNode} source the node being copied, part in input document.
|
|
92
106
|
*/
|
|
93
107
|
protected xsltCopyOf(destination: XNode, source: XNode): void;
|
|
108
|
+
/**
|
|
109
|
+
* Implements `xsl:decimal-format`, registering the settings in this instance
|
|
110
|
+
* and the current context.
|
|
111
|
+
* @param context The Expression Context.
|
|
112
|
+
* @param template The template.
|
|
113
|
+
*/
|
|
114
|
+
protected xsltDecimalFormat(context: ExprContext, template: XNode): void;
|
|
115
|
+
/**
|
|
116
|
+
* Implements `xsl:element`.
|
|
117
|
+
* @param context The Expression Context.
|
|
118
|
+
* @param template The template.
|
|
119
|
+
*/
|
|
120
|
+
protected xsltElement(context: ExprContext, template: XNode): Promise<void>;
|
|
94
121
|
/**
|
|
95
122
|
* Implements `xsl:for-each`.
|
|
96
123
|
* @param context The Expression Context.
|
|
97
124
|
* @param template The template.
|
|
98
125
|
* @param output The output.
|
|
99
126
|
*/
|
|
100
|
-
protected xsltForEach(context: ExprContext, template: XNode, output
|
|
127
|
+
protected xsltForEach(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Implements `xsl:if`.
|
|
130
|
+
* @param context The Expression Context.
|
|
131
|
+
* @param template The template.
|
|
132
|
+
* @param output The output.
|
|
133
|
+
*/
|
|
134
|
+
protected xsltIf(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
101
135
|
/**
|
|
102
136
|
* Implements `xsl:include`.
|
|
103
137
|
* @param context The Expression Context.
|
|
104
138
|
* @param template The template.
|
|
105
139
|
* @param output The output.
|
|
106
140
|
*/
|
|
107
|
-
protected xsltInclude(context: ExprContext, template: XNode, output
|
|
141
|
+
protected xsltInclude(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Implements `xsl:key`.
|
|
144
|
+
* @param context The Expression Context.
|
|
145
|
+
* @param template The template.
|
|
146
|
+
*/
|
|
147
|
+
protected xsltKey(context: ExprContext, template: XNode): void;
|
|
108
148
|
/**
|
|
109
149
|
* Orders the current node list in the input context according to the
|
|
110
150
|
* sort order specified by xsl:sort child nodes of the current
|
|
@@ -115,14 +155,25 @@ export declare class Xslt {
|
|
|
115
155
|
* @todo case-order is not implemented.
|
|
116
156
|
*/
|
|
117
157
|
protected xsltSort(context: ExprContext, template: XNode): void;
|
|
158
|
+
/**
|
|
159
|
+
* Implements `xsl:template`.
|
|
160
|
+
* @param context The Expression Context.
|
|
161
|
+
* @param template The `<xsl:template>` node.
|
|
162
|
+
* @param output The output. In general, a fragment that will be used by
|
|
163
|
+
* the caller.
|
|
164
|
+
*/
|
|
165
|
+
protected xsltTemplate(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
166
|
+
protected xsltText(context: ExprContext, template: XNode, output?: XNode): void;
|
|
118
167
|
/**
|
|
119
168
|
* Implements `<xsl:stylesheet>` and `<xsl:transform>`, and its corresponding
|
|
120
169
|
* validations.
|
|
121
|
-
* @param template The `<xsl:stylesheet>` or `<xsl:transform>` node.
|
|
122
170
|
* @param context The Expression Context.
|
|
123
|
-
* @param
|
|
171
|
+
* @param template The `<xsl:stylesheet>` or `<xsl:transform>` node.
|
|
172
|
+
* @param output The output. In general, a fragment that will be used by
|
|
173
|
+
* the caller.
|
|
124
174
|
*/
|
|
125
|
-
protected xsltTransformOrStylesheet(
|
|
175
|
+
protected xsltTransformOrStylesheet(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
176
|
+
protected xsltValueOf(context: ExprContext, template: XNode, output?: XNode): void;
|
|
126
177
|
/**
|
|
127
178
|
* Evaluates a variable or parameter and set it in the current input
|
|
128
179
|
* context. Implements `xsl:variable`, `xsl:param`, and `xsl:with-param`.
|
|
@@ -148,6 +199,8 @@ export declare class Xslt {
|
|
|
148
199
|
* This logic is used in two different places:
|
|
149
200
|
* - `xsltPassThrough`, if the template asks this library to write a text node;
|
|
150
201
|
* - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
|
|
202
|
+
*
|
|
203
|
+
* Text nodes always require a parent, and they never have children.
|
|
151
204
|
* @param context The Expression Context.
|
|
152
205
|
* @param template The template, that contains the node value to be written.
|
|
153
206
|
* @param output The output.
|
|
@@ -203,5 +256,5 @@ export declare class Xslt {
|
|
|
203
256
|
* @param template The template node.
|
|
204
257
|
*/
|
|
205
258
|
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
206
|
-
protected isXsltElement(element:
|
|
259
|
+
protected isXsltElement(element: XNode, opt_wantedName?: string): boolean;
|
|
207
260
|
}
|