-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple usage documentation refers to nonexistent export #6
Comments
xmlParse, also. |
Seeing that the last commit on this project was more than 3 years ago and even xmldom-ts, which is maintained by the same guy, and is used as dependency on this project received the last update 2 years ago, I think this project is more or less dead or at least unmaintained further.
import { xmlParse } from 'xslt-ts/test/utils'; should do the trick here. The import of the However, depending on which library you've installed alongside This whole dependency chain looks extremely messy IMO. Granted, I'm not a regular JS/TS developer but I'm really wondering whether serious XML/XSLT processing is actually done in that stack. I.e. if I replace the xmldom-tsGiven dependency imports of
for a code excerpt that looks like this: import { DOMParserImpl, XMLSerializerImpl, DOMImplementationImpl } from 'xmldom-ts';
import { install, xsltProcess, getParser } from 'xslt-ts';
import { XSLTProcessorImpl } from 'xslt-ts/types/xslt-processor';
import { xmlParse } from 'xslt-ts/test/utils';
install(new DOMParserImpl(), new XMLSerializerImpl(), new DOMImplementationImpl());
...
const parser = getParser();
const xsltDoc = parser.parseFromString(xsltString, 'text/xml');
// or
const xsltDoc = xmlParse(xsltString);
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
// or
const xmlDoc = xmlParse(xmlString);
const outXmlString = xsltProcess(xmlDoc, xsltDoc);
console.log(`Out XML: {outXmlString}`);
const processor = new XSLTprocessorImpl();
processor.importStylesheet(xsltDoc); This will compile but when executed will produce the following errors: node_modules/xslt-ts/src/install.ts:1:11 - error TS2304: Cannot find name 'DOMImplementation'.
1 let _dom: DOMImplementation;
~~~~~~~~~~~~~~~~~
node_modules/xslt-ts/src/install.ts:2:14 - error TS2304: Cannot find name 'DOMParser'.
2 let _parser: DOMParser;
~~~~~~~~~
node_modules/xslt-ts/src/install.ts:3:18 - error TS2304: Cannot find name 'XMLSerializer'.
3 let _serializer: XMLSerializer;
~~~~~~~~~~~~~
node_modules/xslt-ts/src/install.ts:29:33 - error TS2304: Cannot find name 'DOMParser'.
29 export function install(parser: DOMParser, serializer: XMLSerializer, dom: DOMImplementation) {
~~~~~~~~~
node_modules/xslt-ts/src/install.ts:29:56 - error TS2304: Cannot find name 'XMLSerializer'.
29 export function install(parser: DOMParser, serializer: XMLSerializer, dom: DOMImplementation) {
~~~~~~~~~~~~~
node_modules/xslt-ts/src/install.ts:29:76 - error TS2304: Cannot find name 'DOMImplementation'.
29 export function install(parser: DOMParser, serializer: XMLSerializer, dom: DOMImplementation) {
~~~~~~~~~~~~~~~~~
Found 6 errors in the same file, starting at: node_modules/xslt-ts/src/install.ts:1 xmldomOn removing
and modifying th code to look like ...
import { DOMParser, XMLSerializer, DOMImplementation } from 'xmldom';
import { install, xsltProcess, getParser } from 'xslt-ts';
...
install(new DOMParser(), new XMLSerializer(), new DOMImplementation());
function runXSLT(): void {
...
try {
const parser = getParser();
const xsltDoc = parser.parseFromString(xsltString, 'text/xml');
console.log(xsltDoc);
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
console.log(xmlDoc);
const outXmlString = xsltProcess(xmlDoc, xsltDoc);
console.log(outXmlString);
} catch (err) {
console.error(err);
}
}
runXSLT(); the TS files compiles and at least runs the XSLT processor. Note however, that the import and usage of When trying to add import { ..., XSLTProcessor } from 'xslt-ts';
...
const processor = new XSLTProcessor();
processor.importStylesheet(xsltDoc);
const output = processor.transformToDocument(xmlDoc);
... back in compilation fails however due to node_modules/xslt-ts/src/xslt.ts:66:31 - error TS2345: Argument of type 'XPathResultImpl' is not assignable to parameter of type 'XPathResult'.
Types of property 'ANY_TYPE' are incompatible.
Type 'number' is not assignable to type '0'.
66 nodes = gatherNodes(input.eval(select));
~~~~~~~~~~~~~~~~~~
node_modules/xslt-ts/src/xslt.ts:148:29 - error TS2345: Argument of type 'XPathResultImpl' is not assignable to parameter of type 'XPathResult'.
Types of property 'ANY_TYPE' are incompatible.
Type 'number' is not assignable to type '0'.
148 if (isResultNodeSet(value)) {
~~~~~
node_modules/xslt-ts/src/xslt.ts:149:37 - error TS2345: Argument of type 'XPathResultImpl' is not assignable to parameter of type 'XPathResult'.
Types of property 'ANY_TYPE' are incompatible.
Type 'number' is not assignable to type '0'.
149 const nodes = gatherNodes(value);
~~~~~
node_modules/xslt-ts/src/xslt.ts:330:27 - error TS2345: Argument of type 'XPathResultImpl' is not assignable to parameter of type 'XPathResult'.
Types of property 'ANY_TYPE' are incompatible.
Type 'number' is not assignable to type '0'.
330 value = convertResult(input.eval(select));
~~~~~~~~~~~~~~~~~~
node_modules/xslt-ts/src/xslt.ts:364:29 - error TS2345: Argument of type 'XPathResultImpl' is not assignable to parameter of type 'XPathResult'.
Types of property 'ANY_TYPE' are incompatible.
Type 'number' is not assignable to type '0'.
364 const nodes = gatherNodes(input.eval(select));
~~~~~~~~~~~~~~~~~~
node_modules/xslt-ts/src/xslt.ts:582:32 - error TS2345: Argument of type 'XPathResultImpl' is not assignable to parameter of type 'XPathResult'.
Types of property 'ANY_TYPE' are incompatible.
Type 'number' is not assignable to type '0'.
582 const result = gatherNodes(cloned.eval(match));
~~~~~~~~~~~~~~~~~~
Found 6 errors in the same file, starting at: node_modules/xslt-ts/src/xslt.ts:66 While I'm not an expert on this matter, the issue seems to be within xpath-result-impl and assigning the constants to readonly fields which my lib.dom.ts privided in newer VSCode environments ship with defines. If I just change the This and |
The simple usage documentation specifies the following:
This results in the error:
This is a brand new project where I've done nothing but install
xslt-ts
andxmldom-ts
and try to run the example code on a string of XML.The text was updated successfully, but these errors were encountered: