forked from redhat-developer/vscode-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See eclipse/lemminx#1464 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
e08f378
commit 5c91603
Showing
5 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# XML File Paths Features | ||
|
||
XML file path support provides the capability to mark a DOM node (attribute or text) as file path with the `xml.filePathSupport` settings by using XPath expression : | ||
|
||
* `path/text()` defines the text node of the `path` element. | ||
* `item/@path` defines the `path` attribute node of the `item` element. | ||
|
||
Once the DOM node is marked as file path, you will benefit with: | ||
|
||
* Files completion. | ||
|
||
## Define File path in Text Content with `path/text()` | ||
|
||
Given this XML file `items.xml` sample: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<items> | ||
<path>path/to/file.xml</path> | ||
</items> | ||
``` | ||
|
||
In this sample: | ||
|
||
* text of `path` tag element `<path>/path/to/file.xml</path>` declare a file path. [vscode-xml](https:/redhat-developer/vscode-xml) provides a file path support with the `xml.filePathSupport` settings. You can declare this settings: | ||
|
||
```json | ||
"xml.filePathSupport": [ | ||
{ | ||
"pattern": "**/items.xml", | ||
"expressions": [ | ||
{ | ||
"xpath": "items/path/text()" | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
After saving this setting, you will get file path completion support for the text node of `path` tag element: | ||
|
||
![XML File Paths in Text](../images/Features/XMLFilePathsInTextFeatures.png) | ||
|
||
## Define File path in Attribute with `item/@path` | ||
|
||
Attribute values may also be marked as file path by using the proper XPath. | ||
|
||
Given this `items.xml` XML file: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<items> | ||
<item path="path/to/file.xml" ></item> | ||
</items> | ||
|
||
``` | ||
|
||
You can declare this settings: | ||
|
||
```json | ||
"xml.filePathSupport": [ | ||
{ | ||
"pattern": "**/items.xml", | ||
"expressions": [ | ||
{ | ||
"xpath": "item/@path" | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
After saving this setting, you will get file path completion support for the text node of `path` attribute: | ||
|
||
![XML File Paths in Attr](../images/Features/XMLFilePathsInAttrFeatures.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters