@tradik/xslt-processor 1.0.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/LICENSE +29 -0
- package/LICENSE.md +28 -0
- package/README.md +634 -0
- package/bin/xslt.js +208 -0
- package/dist/xslt-processor.browser.js +3302 -0
- package/dist/xslt-processor.browser.js.map +7 -0
- package/dist/xslt-processor.browser.min.js +6 -0
- package/dist/xslt-processor.browser.min.js.map +7 -0
- package/dist/xslt-processor.cjs +3311 -0
- package/dist/xslt-processor.cjs.map +7 -0
- package/dist/xslt-processor.d.ts +211 -0
- package/dist/xslt-processor.js +3271 -0
- package/dist/xslt-processor.js.map +7 -0
- package/package.json +68 -0
- package/src/XSLTProcessor.js +368 -0
- package/src/XSLTProcessor.test.js +930 -0
- package/src/index.js +66 -0
- package/src/xpath/evaluator.js +1012 -0
- package/src/xpath/evaluator.test.js +1852 -0
- package/src/xpath/index.js +67 -0
- package/src/xpath/parser.js +595 -0
- package/src/xpath/tokenizer.js +383 -0
- package/src/xpath/tokenizer.test.js +224 -0
- package/src/xslt/engine.js +1812 -0
- package/src/xslt/engine.test.js +3130 -0
- package/src/xslt/index.js +6 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cv-xslt/xslt-processor - TypeScript Declarations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* XSLTProcessor - Applies XSLT stylesheet transformations to XML documents.
|
|
7
|
+
*/
|
|
8
|
+
export class XSLTProcessor {
|
|
9
|
+
constructor();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Imports the XSLT stylesheet.
|
|
13
|
+
* @param style - The XSLT stylesheet to import (Document or Element)
|
|
14
|
+
*/
|
|
15
|
+
importStylesheet(style: Node): void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transforms the node source and returns a document fragment.
|
|
19
|
+
* @param source - The XML document to transform
|
|
20
|
+
* @param output - The document that will own the generated fragment
|
|
21
|
+
* @returns The transformed result as a DocumentFragment
|
|
22
|
+
*/
|
|
23
|
+
transformToFragment(source: Node, output: Document): DocumentFragment | null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Transforms the node source and returns a full XML document.
|
|
27
|
+
* @param source - The XML document to transform
|
|
28
|
+
* @returns The transformed result as an XMLDocument
|
|
29
|
+
*/
|
|
30
|
+
transformToDocument(source: Node): XMLDocument | null;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Sets a parameter in the XSLT stylesheet.
|
|
34
|
+
* @param namespaceURI - The namespace URI (use null for no namespace)
|
|
35
|
+
* @param localName - The local name of the parameter
|
|
36
|
+
* @param value - The value to set
|
|
37
|
+
*/
|
|
38
|
+
setParameter(namespaceURI: string | null, localName: string, value: unknown): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets the value of a parameter from the XSLT stylesheet.
|
|
42
|
+
* @param namespaceURI - The namespace URI
|
|
43
|
+
* @param localName - The local name of the parameter
|
|
44
|
+
* @returns The parameter value, or empty string if not set
|
|
45
|
+
*/
|
|
46
|
+
getParameter(namespaceURI: string | null, localName: string): unknown;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Removes a parameter from the XSLT processor.
|
|
50
|
+
* @param namespaceURI - The namespace URI
|
|
51
|
+
* @param localName - The local name of the parameter
|
|
52
|
+
*/
|
|
53
|
+
removeParameter(namespaceURI: string | null, localName: string): void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Removes all set parameters from the XSLTProcessor.
|
|
57
|
+
*/
|
|
58
|
+
clearParameters(): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Removes all parameters and stylesheets from the XSLTProcessor.
|
|
62
|
+
*/
|
|
63
|
+
reset(): void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if native XSLTProcessor is available and functional.
|
|
68
|
+
*/
|
|
69
|
+
export function isNativeXSLTSupported(): boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Install as global XSLTProcessor replacement if native is not functional.
|
|
73
|
+
* @param force - Force installation even if native is available
|
|
74
|
+
* @returns True if installed as global
|
|
75
|
+
*/
|
|
76
|
+
export function installGlobal(force?: boolean): boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* XPath evaluation result types.
|
|
80
|
+
*/
|
|
81
|
+
export const XPathResultType: {
|
|
82
|
+
ANY_TYPE: 0;
|
|
83
|
+
NUMBER_TYPE: 1;
|
|
84
|
+
STRING_TYPE: 2;
|
|
85
|
+
BOOLEAN_TYPE: 3;
|
|
86
|
+
UNORDERED_NODE_ITERATOR_TYPE: 4;
|
|
87
|
+
ORDERED_NODE_ITERATOR_TYPE: 5;
|
|
88
|
+
UNORDERED_NODE_SNAPSHOT_TYPE: 6;
|
|
89
|
+
ORDERED_NODE_SNAPSHOT_TYPE: 7;
|
|
90
|
+
ANY_UNORDERED_NODE_TYPE: 8;
|
|
91
|
+
FIRST_ORDERED_NODE_TYPE: 9;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* XPath evaluation context.
|
|
96
|
+
*/
|
|
97
|
+
export class XPathContext {
|
|
98
|
+
constructor(
|
|
99
|
+
node: Node,
|
|
100
|
+
position?: number,
|
|
101
|
+
size?: number,
|
|
102
|
+
variables?: Record<string, unknown>,
|
|
103
|
+
namespaces?: Record<string, string>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
node: Node;
|
|
107
|
+
position: number;
|
|
108
|
+
size: number;
|
|
109
|
+
variables: Record<string, unknown>;
|
|
110
|
+
namespaces: Record<string, string>;
|
|
111
|
+
|
|
112
|
+
clone(overrides?: Partial<XPathContext>): XPathContext;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* XPath evaluator.
|
|
117
|
+
*/
|
|
118
|
+
export class XPathEvaluator {
|
|
119
|
+
constructor();
|
|
120
|
+
|
|
121
|
+
evaluate(ast: unknown, context: XPathContext): unknown;
|
|
122
|
+
toBoolean(value: unknown): boolean;
|
|
123
|
+
toNumber(value: unknown): number;
|
|
124
|
+
toString(value: unknown): string;
|
|
125
|
+
getStringValue(node: Node): string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Evaluate an XPath expression against a node.
|
|
130
|
+
*/
|
|
131
|
+
export function evaluateXPath(
|
|
132
|
+
expression: string,
|
|
133
|
+
contextNode: Node,
|
|
134
|
+
options?: { variables?: Record<string, unknown>; namespaces?: Record<string, string> }
|
|
135
|
+
): unknown;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Select nodes matching an XPath expression.
|
|
139
|
+
*/
|
|
140
|
+
export function selectXPath(
|
|
141
|
+
expression: string,
|
|
142
|
+
contextNode: Node,
|
|
143
|
+
options?: { variables?: Record<string, unknown>; namespaces?: Record<string, string> }
|
|
144
|
+
): Node[];
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Select first node matching an XPath expression.
|
|
148
|
+
*/
|
|
149
|
+
export function selectFirstXPath(
|
|
150
|
+
expression: string,
|
|
151
|
+
contextNode: Node,
|
|
152
|
+
options?: { variables?: Record<string, unknown>; namespaces?: Record<string, string> }
|
|
153
|
+
): Node | null;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Parse an XPath expression into an AST.
|
|
157
|
+
*/
|
|
158
|
+
export function parseXPath(expression: string): unknown;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* XSLT processing context.
|
|
162
|
+
*/
|
|
163
|
+
export class XsltContext {
|
|
164
|
+
constructor(options?: {
|
|
165
|
+
currentNode?: Node;
|
|
166
|
+
currentNodeList?: Node[];
|
|
167
|
+
position?: number;
|
|
168
|
+
variables?: Record<string, unknown>;
|
|
169
|
+
parameters?: Record<string, unknown>;
|
|
170
|
+
outputDocument?: Document;
|
|
171
|
+
stylesheet?: Document;
|
|
172
|
+
namespaces?: Record<string, string>;
|
|
173
|
+
templates?: unknown[];
|
|
174
|
+
keys?: Record<string, unknown>;
|
|
175
|
+
decimalFormats?: Record<string, unknown>;
|
|
176
|
+
outputMethod?: string;
|
|
177
|
+
xpathEvaluator?: XPathEvaluator;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
clone(overrides?: Partial<XsltContext>): XsltContext;
|
|
181
|
+
getVariable(name: string): unknown;
|
|
182
|
+
setVariable(name: string, value: unknown): void;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* XSLT processing engine.
|
|
187
|
+
*/
|
|
188
|
+
export class XsltEngine {
|
|
189
|
+
constructor();
|
|
190
|
+
|
|
191
|
+
importStylesheet(stylesheetNode: Node): void;
|
|
192
|
+
transform(sourceNode: Node, ownerDocument: Document): DocumentFragment;
|
|
193
|
+
transformToDocument(sourceNode: Node): Document;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Version information.
|
|
198
|
+
*/
|
|
199
|
+
export const VERSION: string;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Check if running in a browser environment.
|
|
203
|
+
*/
|
|
204
|
+
export const isBrowser: boolean;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Check if running in Node.js.
|
|
208
|
+
*/
|
|
209
|
+
export const isNode: boolean;
|
|
210
|
+
|
|
211
|
+
export default XSLTProcessor;
|