redhat-developer / vscode-xml

Editing XML in Visual Studio Code made easy
Eclipse Public License 2.0
263 stars 82 forks source link

Element name 'mode' is invalid for XSLT 3 stylesheet. #908

Open garretwilson opened 1 year ago

garretwilson commented 1 year ago

I'm not 100% sure where this error is even coming from, but I have this plugin installed for XML support, so this is the most likely culprit.

I'm using the latest VS Code on Windows 10. I load an XSLT stylesheet that starts like this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>
  <xsl:mode on-no-match="fail"/>

In my editor xml:mode is underlined; the error says:

Element name 'mode' is invalid.

One of the following is expected:
 - declaration
 - variable
 - param
 - WC[##other:"http://www.w3.org/1999/XSL/Transform"]

Error indicated by:
 {http://www.w3.org/1999/XSL/Transform}
with code: xml(cvc-complex-type.2.4.a)

I'm pretty sure this is valid XSLT 3. Perhaps the plugin is using an outdated schema definition for XSLT 2.x? How can we get this updated? I would file a pull request, but I don't have the faintest idea where this would be defined.

angelozerr commented 1 year ago

I think it is the same issue than https://github.com/redhat-developer/vscode-xml/issues/253 and since Xerces doesn't support XSD 1.1 I fear we cannot fix this issue again.

garretwilson commented 1 year ago

I didn't look too deeply, but both issues talk about XSLT 3, yes.

But pushing this off to some underlying library is not the answer. If the underlying library doesn't use the latest standards, you need to switch libraries. That's like saying, "We have a Java plugin, but I'm sorry, our underlying library is stuck on Java 7, so you can't use our plugin to edit Java 11 source code, or if you do you'll get errors."

Doesn't Saxon support the latest XSD standards?

In any case, I don't want little red lines everywhere. And in fact I just installed the plugin for XML well-formedness, not for schema validation necessarily (although that would be nice—it if worked). How do I turn off schema validation so that I just simply have XML editing help and well-formedness checks?

angelozerr commented 1 year ago

But pushing this off to some underlying library is not the answer. If the underlying library doesn't use the latest standards, you need to switch libraries.

I give you this answer because we have already studied several solution like the non official XSD 1.1 xerces support, like Saxon where we cannot use only Saxon HE which have some limitation, Jing, etc.

Doesn't Saxon support the latest XSD standards?

Please note that we cannot just use Saxon HE which have some limitation.

That's like saying, "We have a Java plugin, but I'm sorry, our underlying library is stuck on Java 7, so you can't use our plugin to edit Java 11 source code, or if you do you'll get errors."

When we have implemented vscode-xml, our first goal was to have a robust support for pom.xml and for that we have used Xerces to support XSD schema. We have integrated RelaxNG in last version because we had more and more people who wanted to have this support.

Supporting XSD 1.1 is not our priority, but if you are interested any suggestion, POC, contribution are welcome!

How do I turn off schema validation so that I just simply have XML editing help and well-formedness checks?

See https://github.com/redhat-developer/vscode-xml/blob/main/docs/Validation.md#xmlvalidationschemaenabled