diff --git a/README.md b/README.md index a0fe8896..5e11f0e4 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ This VS Code extension provides support for creating and editing XML documents, | enabled by default | requires additional configuration to enable | - * [XML References features](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLReferencesFeatures.md#xml-references-features) (since v0.24.0) +- * [XML Colors features](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLColorsFeatures.md#xml-colors-features) (since v0.24.0) * [RelaxNG (experimental) support](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/RelaxNGFeatures.md#relaxng-features) (since v0.22.0) * [Surround with Tags, Comments, CDATA](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Refactor.md#refactor) (since v0.23.0) * Syntax error reporting diff --git a/docs/Features.md b/docs/Features.md index e1781e22..a6721c1d 100644 --- a/docs/Features.md +++ b/docs/Features.md @@ -8,4 +8,5 @@ - [RelaxNG features](Features/RelaxNGFeatures.md#relaxng-features) - [XInclude features](Features/XIncludeFeatures.md#xinclude-features) - [XML Catalog features](Features/XMLCatalogFeatures.md#xml-catalog-features) -- [XML References features](Features/XMLReferencesFeatures.md#xml-references-features) \ No newline at end of file +- [XML References features](Features/XMLReferencesFeatures.md#xml-references-features) +- [XML Colors features](Features/XMLReferencesFeatures.md#xml-colors-features) \ No newline at end of file diff --git a/docs/Features/XMLColorsFeatures.md b/docs/Features/XMLColorsFeatures.md new file mode 100644 index 00000000..6b20fef3 --- /dev/null +++ b/docs/Features/XMLColorsFeatures.md @@ -0,0 +1,66 @@ +# XML Colors Features + +XML colors support provides the capability to mark a DOM node (attribute or text) as color with the `xml.colors` settings by using XPath expression : + + * `color/text()` defines the text node of the `color` element. + * `item/@color` defines the `color` attribute node of the `item` element. + +## Text node color (color/text()) + +Given this [android color](https://developer.android.com/guide/topics/resources/more-resources#Color) XML file sample: + +```xml + + + #f00 + rgb(222,82,0.82) + +``` + +In this sample, text of `color` tag element `#f00` declare a color with hexadecimal. [vscode-xml](https://github.com/redhat-developer/vscode-xml) provides a color support with the `xml.colors` settings. For [android color](https://developer.android.com/guide/topics/resources/more-resources#Color) case, you can declare this settings: + +```json +"xml.colors": [ + { + "pattern": "**/res/values/colors.xml", + "expressions": [ + { + "xpath": "resources/color/text()" + } + ] + } +] +``` + +After saving this setting, you will get color support for text noe of `color` in the colors.xml file: + +![XML Colors](../images/Features/XMLColorsFeatures.png) + +## Attribute node color (item/@color) + +It is possible too to mark attribute as color, by using the proper XPath. + +Given this `colors.xml` XML file: + +```xml + + + + + +``` + +You can declare this settings: + +```json +"xml.colors": [ + { + "pattern": "**/colors.xml", + "expressions": [ + { + "xpath": "item/@color" + } + ] + } +] +``` \ No newline at end of file diff --git a/docs/Features/XMLReferencesFeatures.md b/docs/Features/XMLReferencesFeatures.md index 74ca4ddf..373b3429 100644 --- a/docs/Features/XMLReferencesFeatures.md +++ b/docs/Features/XMLReferencesFeatures.md @@ -1,6 +1,6 @@ # XML References Features -XML References support provides the capability to reference a DOM node (attribute or text) to an another DOM node (attribute or text) with a the `xml.references` settings by using XPath expression : +XML References support provides the capability to reference a DOM node (attribute or text) to an another DOM node (attribute or text) with the `xml.references` settings by using XPath expression : * `foo/@attr` defines the `attr` attribute node of the `foo` element. * `foo/text()` defines the text node of the `foo` element. diff --git a/docs/images/Features/XMLColorsFeatures.png b/docs/images/Features/XMLColorsFeatures.png new file mode 100644 index 00000000..c537ed3a Binary files /dev/null and b/docs/images/Features/XMLColorsFeatures.png differ diff --git a/package.json b/package.json index 757bcc37..a0e4ee71 100644 --- a/package.json +++ b/package.json @@ -674,7 +674,42 @@ "expressions" ] }, - "markdownDescription": "Allows XML schemas/ DTD to be associated to file name patterns. Please refer to [XML file association with XSD](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22xml-file-association-with-xsd%22%7D%5D) or [XML file association with DTD](command:xml.open.docs?%5B%7B%22page%22%3A%22Validation%22%2C%22section%22%3A%22xml-file-association-with-dtd%22%7D%5D) for more information. \n\nExample:\n```json\n[{\n \"pattern\": \"file1.xml\",\n \"systemId\": \"path/to/file.xsd\"\n},\n{\n \"pattern\": \"**/*.xsd\",\n \"systemId\": \"http://www.w3.org/2001/XMLSchema.xsd\"\n}]\n```", + "markdownDescription": "Allows references for the given file name patterns.", + "scope": "window" + }, + "xml.colors": { + "type": "array", + "default": [], + "items": { + "type": "object", + "properties": { + "pattern": { + "type": "string", + "markdownDescription": "matches the files that colors declared with `expressions` applies to.\n\nMore information on the glob syntax: https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob" + }, + "expressions": { + "type": "array", + "default": [], + "items": { + "type": "object", + "properties": { + "xpath": { + "type": "string", + "description": "The color DOM node (attribute, text) declared with XPath (ex: foo/@color, foo/text())" + } + } + }, + "required": [ + "xpath" + ] + } + }, + "required": [ + "pattern", + "expressions" + ] + }, + "markdownDescription": "Allows colors for the given file name patterns.", "scope": "window" }, "xml.extension.jars": {