You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Features/XMLReferencesFeatures.md
+39-15Lines changed: 39 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ XML References support provides the capability to reference a DOM node (attribut
4
4
5
5
*`foo/@attr` defines the `attr` attribute node of the `foo` element.
6
6
*`foo/text()` defines the text node of the `foo` element.
7
+
8
+
Once you have declared those reference, you will benefit with completion, definition, highlight, validation, rename, find references, and show references count with codelens:
9
+
10
+

7
11
8
12
## Attribute node references (foo/@attr)
9
13
@@ -49,9 +53,12 @@ After saving this setting, you will get completion, go to definition, and highli
49
53
50
54
The `xml.references` settings is an array of objects with the following properties:
51
55
52
-
*`pattern`: matches the files that reference declared with `expressions` applies to. See [glob syntax](https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob) for more information about the pattern syntax.
56
+
*`pattern`: matches the files that reference declared with `expressions` applies to. See [glob syntax](https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob) for more information about the pattern syntax.
57
+
*`prefix (optional)`: the prefix to use (ex : '#') for from for all the declared reference expressions.
58
+
*`multiple (optional)`: true if the from attribute, text can declare several from references and false otherwise for all the declared reference expressions.
53
59
*`expressions`: array of reference expression:
54
60
*`prefix (optional)`: the prefix to use (ex : '#') for from.
61
+
*`multiple (optional)`: true if the from attribute, text can declare several from references and false otherwise.
55
62
*`from`: the from reference DOM node (attribute, text) declared with XPath (ex: `foo/@attr`, `foo/text()`).
56
63
*`to`: the to reference DOM node (attribute, text) declared with XPath (ex: `foo/@attr`, `foo/text()`).
57
64
@@ -91,21 +98,50 @@ In this sample, `corresp` attribute in `<anchor corresp="#body-id"></anchor>` re
91
98
"xml.references": [
92
99
{
93
100
"pattern": "**/*.xml",
101
+
"prefix": "#",
94
102
"expressions": [
95
103
{
96
-
"prefix": "#",
97
104
"from": "@resp",
98
105
"to": "persName/@xml:id"
99
106
},
100
107
{
101
-
"prefix": "#",
102
108
"from": "@corresp",
103
109
"to": "@xml:id"
104
110
}
105
111
]
106
112
}
107
113
]
108
114
```
115
+
## Multiple target
116
+
117
+
If the `origin` attribute (which matches the `from` reference path) declares multiple targets (which matches the `to` reference path), you can use `multiple`
118
+
119
+
Given this XML file where `target` attribute defines several targets separated with whitespace (#body-id #p-id):
120
+
121
+
```xml
122
+
<bodyxml:id="body-id">
123
+
<pxml:id="p-id" >Some text here.</p>
124
+
<linktarget="#body-id #p-id"></link>
125
+
</body>
126
+
```
127
+
128
+
In this sample, `target` attribute in `<link target="#body-id #p-id"></link>` references the `body-id` and `p-id` (without `#`) declared in `<body xml:id="body-id">` and `<p xml:id="p-id" >`. It means that the `target` attribute value (with `#`) reference `@xml:id` attribute (without `#`). To support that, you can configure settings by using `multiple`:
129
+
130
+
```json
131
+
"xml.references": [
132
+
{
133
+
"pattern": "**/*.xml",
134
+
"prefix": "#",
135
+
"multiple": true,
136
+
"expressions": [
137
+
{
138
+
"from": "link/@target",
139
+
"to": "@xml:id"
140
+
}
141
+
]
142
+
}
143
+
]
144
+
```
109
145
110
146
## Text node references (foo/text())
111
147
@@ -150,17 +186,5 @@ In this sample, `servlet-mapping/servlet-name` text in `<servlet-name>comingsoon
150
186
XML references have some limitation:
151
187
152
188
**references works only for a given XML file*: it is not possible to reference some DOM nodes coming from another XML files. However if the file uses include (like xi:include) the reference will only work in the file which has the include statement, and not in the file being included.
153
-
**multiple target is not supported*: if the `origin` attribute (which matches the `from` reference path) declares multiple targets (which matches the `to` reference path), it will not work.
154
-
155
-
Given this XML file where `corresp` attribute defines several targets separated with whitespace (#body-id #p-id):
156
-
157
-
```xml
158
-
<bodyxml:id="body-id">
159
-
<pxml:id="p-id" >Some text here.</p>
160
-
<anchorcorresp="#body-id #p-id"></anchor>
161
-
</body>
162
-
```
163
-
164
-
This usecase is not supported today.
165
189
166
190
If you need those support, please [create an issue](https://github.com/redhat-developer/vscode-xml/issues)
Copy file name to clipboardExpand all lines: package.json
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -643,6 +643,14 @@
643
643
"type": "string",
644
644
"markdownDescription": "matches the files that reference declared with `expressions` applies to.\n\nMore information on the glob syntax: https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob"
645
645
},
646
+
"prefix": {
647
+
"type": "string",
648
+
"description": "The prefix to use (ex : '#') for from for all the declared reference expressions."
649
+
},
650
+
"multiple": {
651
+
"type": "boolean",
652
+
"description": "true if the from attribute, text can declare several from references and false otherwise for all the declared reference expressions."
653
+
},
646
654
"expressions": {
647
655
"type": "array",
648
656
"default": [],
@@ -653,6 +661,10 @@
653
661
"type": "string",
654
662
"description": "The prefix to use (ex : '#') for from."
655
663
},
664
+
"multiple": {
665
+
"type": "boolean",
666
+
"description": "true if the from attribute, text can declare several from references and false otherwise."
667
+
},
656
668
"from": {
657
669
"type": "string",
658
670
"description": "The from reference DOM node (attribute, text) declared with XPath (ex: foo/@attr, foo/text())."
0 commit comments