DeltaXML / vscode-xslt-tokenizer

VSCode extension for highlighting XSLT and XPath (upto 3.0/3.1)
MIT License
46 stars 4 forks source link

Add support for XSLT 3.0 xsl:package #21

Open sergey-s-betke opened 4 years ago

sergey-s-betke commented 4 years ago

Example:

    <xsl:use-package name="http://github.com/test-st-petersburg/DocTemplates/tools/xslt/formatter/OO.xslt" package-version="1.5">
        <xsl:accept component="mode" names="f:outline f:inline" visibility="private"/>
    </xsl:use-package>

but using <xsl:apply-templates mode="f:outline" ... /> generate error: "templates for mode not found".

sergey-s-betke commented 4 years ago

How I can set local path to package for linter? May be, in comment?

pgfearo commented 4 years ago

I believe this error message is coming from the Saxon Processor invoked from an XSLT task, not the linter. The Saxon documentation explains how package names are resolved using a configuration file ‘xsltpackages’ element here.

The location of this Saxon configuration file can be specified in an XSLT task using the ‘configFilename’ property.

pgfearo commented 4 years ago

Looking at the details more closely I realise that it is the linter causing the error message for f:outline. I need to read up on the xsl:use-package instruction more fully to see what is the best way to remedy this issue.

sergey-s-betke commented 4 years ago

xsl:use-package used @name - is not uri. For Saxon I must previously compile my packages, load, and then compile my xslt.

I think, we need set in config for this extension (in .vscode/settings.json) packages names and file paths.

pgfearo commented 4 years ago

I will add what you suggest as a first option. Longer term I think I may need to add an extension setting that identifies the Saxon configuration file that I believe is used by Saxon to resolve the package names.

pgfearo commented 4 years ago

There is now a VSCode extension setting XSLT.resources.xsltPackages for this purpose.

sergey-s-betke commented 3 years ago

I try to add XSLT.resources.xsltPackages to my settings: https://github.com/test-st-petersburg/DocTemplates/blob/c2231445733ca7e3cf79dddf8873fc21c48b4d54/.vscode/settings.json#L25-L76

But "Go to definition" does not work in XSLT: https://github.com/test-st-petersburg/DocTemplates/blob/c2231445733ca7e3cf79dddf8873fc21c48b4d54/tools/xslt/Build-OOMacroLib.xslt#L8-L10

sergey-s-betke commented 3 years ago

And one more suggestion: please add one new setting for specifying directories, where your package will automatically search for XSLT packages, determine their names and versions by root node attributes

pgfearo commented 2 years ago

Apologies, I had missed the last two comments! I will reopen this issue.

pgfearo commented 2 years ago

But "Go to definition" does not work in XSLT:

Initially, the main goal was to prevent the linter reporting 'undefined' errors for functions, variables etc. defined in another package.

I will look to add 'Goto Definition' (and possibly 'Rename Symbol') support for symbols referenced in the names attribute of 'xsl:acceptandxsl:expose`.

The xsl:override instruction is most likely not fully supported by the VS Code linter so I will need to investigate that also.