rogalmic / vscode-xml-complete Goto Github PK
View Code? Open in Web Editor NEWXML editing helper (using XSD schemaLocation)
License: MIT License
XML editing helper (using XSD schemaLocation)
License: MIT License
This experiment is better suited for an XAML/AXAML-specific extension, but only one exists and it is specifically for NoesisGUI.
As it is, this extension's Avalonia schema is convenient, but comes with major drawbacks for both end-users and maintainers.
The current Avalonia completion source is outdated and partially incompatible with the latest major release of Avalonia: 11.0.0. This release included several breaking changes from the previous major release, 0.10.0. The AvaloniaUI organization provides a upgrade guide for API consumers.
Generating XSD from C# workspace symbols will require either communicating with ms-dotnettools.csharp
and/or ms-dotnettools.csdevkit
or a first-party solution for analyzing the project's dependency tree for Avalonia assemblies and third-party Avalonia add-ons (those that depend on Avalonia).
Currently, I use Avant Garde's ability to export Avalonia's schema, but it's currently generated from the Avalonia version targeted by Avant Garde rather than the version targeted by the project project. This may be changed later.
For better usability in various projects where schema is stored locally a relative address supoport is need. Please try to add support for one of the following:
xml-model href="../../xsd/project.xsd" schematypens="http://www.w3.org/2001/XMLSchema"
or
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/project.xsd">
Missing feature for enabling/disabling automatic same-line attributes on save format
I added a section to my settings.json
in which I wanted to map locally available schemas (on my Mac):
"xmlComplete.schemaMapping": [
{
"xmlns": "sap.ui.core",
"xsdUri": "file:///Users/.../Library/Application%20Support/UI5Experts/ui5-schemas/openui5/1.65.1/sap.ui.core.xsd",
"strict": true // shows errors instead of tips
}
]
However, IntelliSense does not pick it up.
Once I added the same URI via schemaLocation
to the xml file explicitly, everything works as expected.
When the XSD is not found (because none defined in the XML file, or because the one which is defined cannot be accessed (wrong path for example), then there is a warning/error displayed for each tag.
This is not pertinent, would rather have ONE warning/error stating that the XSD file cannot be located (or is not defined).
As when using the extension "Error Lens", this makes the XML file unreadable by having a warning/error on each line.
the extension already parses the xml, it would be good to also see the structure in the outline view
because of AvaloniaUI/avalonia-dotnet-templates#44 new avalonia templates uses axaml in place of xaml extenion.
if rename axaml to xaml then xmlcomplete recognize and format document but I wondering how to set vscode to allow xml complete to work either with axaml extenion file like xaml.
The catalog entries (replace one entry by another) via xmlComplete.schemaMapping
works fine and is quite simiar to eclipse's catalog entries:
{
"xmlns": "https://github.com/avaloniaui",
"xsdUri": "https://raw.githubusercontent.com/rogalmic/vscode-xml-complete/master/test/Avalonia/AvaloniaXamlSchema.xsd"
}
It would be very ood if we could have rewrite options, which is especially usefiul for local files. This feature is available with the standardized xml catalog. The eclipse IDE seems to just wrap this one in a nice editor.
For the setting, we can just add a new one or even better use the xml.catalogs
array, see
https://github.com/redhat-developer/vscode-xml/wiki/XMLValidation#xml-catalog-with-xsd.
I can see that you are working on the project so I want to let you know that I did completion on elements allowed only (also rewrote linter) supporting imports and multiple namespaces.
The thing is that it was a night-time pet project that evolved and its done in the web version (monaco) so not as an extension (a few minor differences) - so when (if) I'm done i better send you the whole thing for manual merge, extension tedt and validation etc.
What do you think?
Hello.
I see this project is using SAX to parse XML and then perform additional logic on the tags output stream.
Does SAX provide full parsing capabilities for the use case of building editor services?
The reason I am asking is because I've implemented a Parser building library in JS:
Which provides editor related infrastructure capabilities:
There is also an XML grammar example:
Feel free to contact me if this is of interest to you.
Cheers.
Shahar.
Hi @rogalmic,
Here my submit of the "massive change-set" that I hope you like like an merge in! :)
Again, I'm sorry that I did not do this a bunch of git commits and a pull request - but the my pet project kinda grew out of control and it was done on monaco (not vscode) where some types are different, loaders are bad etc.
On top of my head here is what I did/added:
I have only tested it on my setup - but thats a pwetty complicated scenario as its 2 XSDs - HTML5 and a XSLT'ish clone that circular references each other via import, elements and attributes. So the auto-complete on html element will show <div id=".." myNs:myAttr=".."
works with only showing allowed and lint triggers to if not allowed. I have also eliminated optimistic lookups for with/without name space to be more restrictive now that there are multiple XSD loaded at the same time with possible naming conflicts / bad matches - should also be faster like that now its possible.
I did a few renames like base
to baseAttributes
as i added baseElements
. All monaco
should be easily changed to vscode
and maybe IRange
to Range
etc. and just completely ignore the classes and main functions like provideCompletionItems
- they are very monaco styled and extending my base class stuff that is not here (and not needed). Besides that I think kept perfectly in line with your base (I hope) and kept most intact with not-to-many renames - but I did change types like string to classes if needed, added interfaces etc.
Btw. you can now enable "noImplicitAny": true,
in tsconfig.json - I strongly recommend that :)
Source is here: xml.zip
My schema is very simple (see schema.xsd and data.xml in attached zip file)
<Root>
element.<Root>
can contains (only) <RootChild_A>
and <RootChild_B>
<RootChild_A>
can contains (only) <AChild>
<RootChild_B>
can contains (only) <BChild>
Within the <Root>
element xml-complete suggests to insert all elements (Root, AChild and BChild shouldn't appear here) :
The Visual Studio XML editor only suggests valid elements :
Three suggested features (inspired by Visual Studio XML editor) :
I have different workspaces with same named xsd's (different versions) at the same place.
Currently the configuration entries seem to be hard-wired (full local path), it would be useful to be able to use ${workspaceRoot]
in this setting.
Example now:
{
"xmlns": "http://www.super.web/xsd/SpecialTypes.xsd",
"xsdUri": "file:////data/projects/project1/external/xsd-files/SpecialTypes.xsd",
"strict": false
},
Example with resolving workspaceRoot (there's a workspace folder "xsd" mapped to the path above):
{
"xmlns": "http://www.super.web/xsd/SpecialTypes.xsd",
"xsdUri": "file://${workspaceRoot:xsd}/SpecialTypes.xsd",
"strict": false
},
My schema contains two element definitions <Property>
. Each one is valid in a specific context and have not the same attribute set (see attached file).
<Property>
in <ElementA>
must have a Identifier
attribute.<Property>
in <ElementB>
must have a Name
attribute.Identifier
and Name
attributes are suggested by xml-complete for the <Property>
element in <ElementA>
.
Performance
vscode-xml-complete
0.2.5
Windows_NT x64 10.0.18362
1.41.1
C:\Users\siu\rogalmic.vscode-xml-complete-unresponsive.cpuprofile.txt
rogalmic.vscode-xml-complete-unresponsive.cpuprofile.txt
Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load
I was just starting out with Avalonia and while there is intellisense, it just seems to be for controls, and nothing relating to Application.
Take the default template (App.axaml) for example:
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="app.App">
<Application.Styles>
<FluentTheme Mode="Light" />
</Application.Styles>
</Application>
If I CTRL+SPACE in there (or even in the MainWindow.axaml), I get nothing but strings found in the list (eg. "blend").
If I type '<', then CTRL+SPACE, I get a full list for Avalonia controls, from AccessText to WrapPanel.
But there's nothing relating to "Application".
Two things that I think "could" relate to adding this feature "may" be found in:
~/.nuget/packages/avalonia/0.10.0/lib/netcoreapp2.0/Avalonia.Styling.xml
~/.nuget/packages/avalonia/0.10.0/lib/netcoreapp2.0/Avalonia.Themes.Fluent.xml
I don't know how your "test" xs for Avalonia is generated, but I saw "Avalonia.Controls.xml" in the nuget directory as well, making me think it was selectively picked, making me also think those others could be added as well.
While I'm here, looking at https://avaloniaui.net/docs/advanced-tutorial/create-a-modern-window where it talks of "TransparencyLevelHint" (which is part of intellisense), I see "AcrylicBlur" doesn't come up as an intellisense option (nothing does for quoted stuff in general).
That is something found in ~/.nuget/packages/avalonia/0.10.0/lib/netstandard2.0/Avalonia.Controls.xml.
Avalonia had to move to .axaml
files, because visual studio caused many bugs with .xaml
. Please, add support for .axaml
file extension, avalonia uses it by default now.
Thanks
See attached screenshot. It shows two errors although the xsd file exists at this location. Itfails to download the schema and autocomplete will not work.
I have also attached a zip file containing the xml file causing the error.
Using XML:
<AUTOSAR xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://autosar.org/schema/r4.0">
...
</AUTOSAR>
Setting:
"xmlComplete.schemaMapping":
[
{
"xmlns": "http://autosar.org/schema/r4.0",
"xsdUri": "file:///C:/Users/s-jiu/Desktop/AP-R19-03/MethodologyAndManifests/AUTOSAR_MMOD_XMLSchema/AUTOSAR_00047.xsd",
"strict": true // shows errors instead of tips
}
]
But the complete function didn't work.
About the error maybe cause by the xmlns
recognized as path not namespace, so search for the path "http://autosar.org/schema/r4.0"
.
So I want know to any setting like xml path/filename glob map to xsd scheme.
In the attached example (.XML file) XML Complete always complains that it cannot find the XSD file. I have triple checked that the file exists at the specified location, and in fact if i open the sa,e XML file in Visual Studio it find the schema and does all the completions according to the schema correctly.
I tried both these syntaxes
xsi:noNamespaceSchemaLocation="file:///c:/Program Files/Memento/Memento Security/build.xsd"
and
xsi:noNamespaceSchemaLocation="c:\Program Files\Memento\Memento Security\build.xsd"
Would be useful to support the xs:any and xs:anyAttribute element to allow elements/attributes not included in the schema to still be classed as valid.
IntelliSense does not pick up the attributes of an element specified like that
<xsd:complexType name="_ListItemType">
<xsd:complexContent>
<xsd:extension base="n0:_ItemType">
<xsd:attribute name="icon" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The icon belonging to this list item instance.
This can be a URI to an image or an icon font URI.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
I added the schema for your convenience (and test case production ;))
You may Try to add a core:ListItem
and complete its properties.
ZIP with schema and sample xml
Cheers,
Oliver
Does the current version support xsd version 1.1. For example, features like:
<xs:unique ref="previouslyDefined">
<xsd:assert test="minPrice le maxPrice"/>
If not, do you have this in the plan?
Thank you.
Getting this error when using this xsd file.
https://raw.githubusercontent.com/propelorm/Propel/master/generator/resources/xsd/database.xsd
Not sure what else you need to assist.
<database name="default" defaultIdMethod="native"
namespace="App\Database"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://raw.githubusercontent.com/propelorm/Propel/master/generator/resources/xsd/database.xsd"
>
</database>
VSCode details
Version: 1.36.0 (user setup)
Commit: 0f3794b38477eea13fb47fbe15a42798e6129338
Date: 2019-07-03T13:25:46.372Z
Electron: 4.2.5
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.17763
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.