[
  {
    "path": ".github/ISSUE_TEMPLATE/bug-report.md",
    "content": "---\nname: Bug Report\nabout: Something (aside from the formatter) isn't working right!\n---\n\n**Description**\nWhat seems to be the problem?\n\n**Screenshots**\nIf applicable, add screenshots to help explain your problem.\n\n**Extension Version**\nWhat version of the XML Tools extension are you using?\n\n**VS Code Version**\nWhat version of VS Code are you using?\n\n**Operating System**\nWhat OS (and version) are you using?\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature-request.md",
    "content": "---\nname: Feature Request\nabout: Suggest a New Feature\n\n---\n\n**Description**\nWhat would you like to see added to XML Tools?\n\n**Current Workarounds**\nAre you using a workaround in the meantime?\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/xml-formatter.md",
    "content": "---\nname: XML Formatter Bug\nabout: Report an issue with the XML formatter.\n---\n\n#### Description\nWhat seems to be the problem?\n\n#### Formatter Implementation\nWhich XML Formatter implementation are you using (the value of your `xmlTools.xmlFormatterImplementation` setting).\n\n#### XML Tools Version\nWhat version of XML Tools are you using?\n\n#### VS Code Version\nWhat version of VS Code are you using?\n\n#### Operating System\nWhat OS (and version) are you using?\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: \"Release to Marketplace\"\n\non:\n  push:\n    tags:\n      - \"v*\"\n\njobs:\n  release:\n    runs-on: \"ubuntu-latest\"\n    steps:\n    - name: \"Checkout\"\n      uses: \"actions/checkout@v2\"\n    \n    - name: \"Setup NodeJS\"\n      uses: \"actions/setup-node@v2.1.0\"\n      \n    - name: \"Install Dependencies\"\n      run: \"npm install\"\n\n    - name: \"Run Tests\"\n      run: \"npm run test\"\n\n    - name: \"Publish to Marketplace\"\n      uses: \"sigma/vsce-publish-action@v0.0.2\"\n      with:\n        vsce_token: ${{ secrets.VSCE_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: \"Run Tests\"\n\non:\n  pull_request:\n    branches:\n      - \"master\"\n\njobs:\n  test:\n    runs-on: \"ubuntu-latest\"\n    steps:\n    - name: \"Checkout\"\n      uses: \"actions/checkout@v2\"\n    \n    - name: \"Setup NodeJS\"\n      uses: \"actions/setup-node@v2.1.0\"\n      \n    - name: \"Install Dependencies\"\n      run: \"npm install\"\n\n    - name: \"Run Tests\"\n      run: \"npm run test\"\n"
  },
  {
    "path": ".gitignore",
    "content": "out\nnode_modules\n.vscode-test/\n/*.vsix\n"
  },
  {
    "path": ".vscode/launch.json",
    "content": "// A launch configuration that compiles the extension and then opens it inside a new window\n{\n    \"version\": \"0.1.0\",\n    \"configurations\": [\n        {\n            \"name\": \"Extension\",\n            \"type\": \"extensionHost\",\n            \"request\": \"launch\",\n            \"runtimeExecutable\": \"${execPath}\",\n            \"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\" ],\n            \"stopOnEntry\": false,\n            \"sourceMaps\": true,\n            \"outFiles\": [ \"${workspaceRoot}/out/**/*.js\" ],\n            \"preLaunchTask\": \"npm: watch\"\n        },\n        {\n            \"name\": \"Extension Tests\",\n            \"type\": \"extensionHost\",\n            \"request\": \"launch\",\n            \"runtimeExecutable\": \"${execPath}\",\n            \"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\", \"--extensionTestsPath=${workspaceRoot}/out/test\" ],\n            \"stopOnEntry\": false,\n            \"sourceMaps\": true,\n            \"outFiles\": [ \"${workspaceRoot}/out/test/**/*.js\" ],\n            \"preLaunchTask\": \"npm: watch\"\n        }\n    ]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "// Place your settings in this file to overwrite default and user settings.\n{\n    \"files.exclude\": {\n        \"out\": false // set this to true to hide the \"out\" folder with the compiled JS files\n    },\n    \"search.exclude\": {\n        \"out\": true // set this to false to include \"out\" folder in search results\n    }\n}"
  },
  {
    "path": ".vscode/tasks.json",
    "content": "// See https://go.microsoft.com/fwlink/?LinkId=733558\n// for the documentation about the tasks.json format\n{\n    \"version\": \"2.0.0\",\n    \"tasks\": [\n        {\n            \"type\": \"npm\",\n            \"script\": \"watch\",\n            \"problemMatcher\": \"$tsc-watch\",\n            \"isBackground\": true,\n            \"presentation\": {\n                \"reveal\": \"never\"\n            },\n            \"group\": {\n                \"kind\": \"build\",\n                \"isDefault\": true\n            }\n        }\n    ]\n}"
  },
  {
    "path": ".vscodeignore",
    "content": ".vscode/**\n.vscode-test/**\nout/test/**\nout/**/*.map\nsrc/**\n.gitignore\ntsconfig.json\nvsc-extension-quickstart.md\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "Detailed release notes are available [here](https://github.com/DotJoshJohnson/vscode-xml/releases)."
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to XML Tools\nWelcome and thank you for contributing to **XML Tools for Visual Studio Code**! This document aims to provide an overview of standards and expectations for those interested in contributing to the project.\n\n## Asking Questions\nIf you have any questions, please ask on Gitter or Twitter instead of submitting an issue.\n\n## Reporting Issues\nBefore submitting a new issue, please be sure to check for an existing issue that matches yours first. Issues that are waiting for information for more than 30 days will be closed, so please be sure to follow your issues!\n\n## Writing Code\nIf you would like to contribute code to the project, please follow these conventions:\n\n* Use spaces over tabs (4 spaces per tab is preferred).\n* Use double quotes whenever possible instead of single quotes.\n* Use **snake-case** for file names.\n* Use **PascalCase** for class and interface names.\n* Use **camelCase** for all other identifiers unless otherwise specified.\n* Prefix private members with an underscore.\n* Implement and maintain barrels (`index.ts` files) when creating new folders or files.\n* Use constants when referencing a static value more than once in your code.\n* Place `else` and `else if` on their own lines.\n* Never put opening braces (`{`) on their own line.\n* Always use semicolons.\n* Always prefer `const` whenever possible and fall back to `let` only if absolutely necessary.\n\n### Branches and Pull Requests\nAlways develop on a new feature branch in your fork and submit pull requests from that branch to our master branch. Don't worry about changing any version numbers - that happens in its own PR before a release.\n\n### Formatter Changes\nFor small bug fixes or feature additions, always add a new test case to accompany your change. If you are making large sweeping changes to how the formatter works or leveraging an external dependency for formatting XML, please create a new XmlFormatter implementation.\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Josh Johnson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# XML Tools for Visual Studio Code\n[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/v/DotJoshJohnson.xml.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml)\n[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/r/DotJoshJohnson.xml.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml)  \n\n[![](https://img.shields.io/badge/TWITTER-%40DotJohnson-blue.svg?logo=twitter&style=for-the-badge)](https://twitter.com/DotJoshJohnson)\n[![](https://img.shields.io/badge/gitter-join_chat-1dce73.svg?style=for-the-badge&logo=gitter-white)](https://gitter.im/vscode-xml/vscode-xml)\n[![Beerpay](https://img.shields.io/beerpay/DotJoshJohnson/vscode-xml.svg?style=for-the-badge)](https://beerpay.io/DotJoshJohnson/vscode-xml)\n\n## Features\n* [XML Formatting](https://github.com/DotJoshJohnson/vscode-xml/wiki/xml-formatting)\n* [XML Tree View](https://github.com/DotJoshJohnson/vscode-xml/wiki/xml-tree-view)\n* [XPath Evaluation](https://github.com/DotJoshJohnson/vscode-xml/wiki/xpath-evaluation)\n* [XQuery Linting](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-linting)\n* [XQuery Execution](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-script-execution)\n* [XQuery Code Completion](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-code-completion)\n\n## Requirements\n* VS Code `1.22.2` or higher\n\n## Extension Settings\n* **`xmlTools.enableXmlTreeView`:** Enables the XML Tree View for XML documents.\n* **`xmlTools.enableXmlTreeViewMetadata`:** Enables attribute and child element counts in the XML Document view.\n* **`xmlTools.enableXmlTreeViewCursorSync`:** Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.\n* **`xmlTools.enforcePrettySelfClosingTagOnFormat`:** Ensures a space is added before the forward slash at the end of a self-closing tag.\n* **`xmlTools.ignoreDefaultNamespace`:** Ignore default xmlns attributes when evaluating XPath.\n* **`xmlTools.persistXPathQuery`:** Remember the last XPath query used.\n* **`xmlTools.removeCommentsOnMinify`:** Remove XML comments during minification.\n* **`xmlTools.splitAttributesOnFormat`:** Put each attribute on a new line when formatting XML. Overrides `xmlTools.splitXmlnsOnFormat` if set to `true`. (V2 Formatter Only)\n* **`xmlTools.splitXmlnsOnFormat`:** Put each xmlns attribute on a new line when formatting XML.\n* **`xmlTools.xmlFormatterImplementation`:** Supported XML Formatters: `classic`, `v2`.\n* **`xmlTools.xqueryExecutionArguments`:** Arguments to be passed to the XQuery execution engine.\n* **`xmlTools.xqueryExecutionEngine`:** The full path to the executable to run when executing XQuery scripts.\n\n## Release Notes\nDetailed release notes are available [here](https://github.com/DotJoshJohnson/vscode-xml/releases).\n\n## Issues\nRun into a bug? Report it [here](https://github.com/DotJoshJohnson/vscode-xml/issues).\n\n## Icon Credits\nIcons used in the XML Tree View are used under the Creative Commons 3.0 BY license.\n* \"Code\" icon by Dave Gandy from www.flaticon.com\n* \"At\" icon by FreePik from www.flaticon.com\n"
  },
  {
    "path": "azure-pipelines.yml",
    "content": "name: \"$(Build.SourceBranchName)-$(Build.SourceVersion)$(Rev:.r)\"\npr:\n  - master\n  \ntrigger:\n  - \"refs/tags/*\"\n\npool:\n  vmImage: \"windows-2019\"\n\nsteps:\n- task: NodeTool@0\n  inputs:\n    versionSpec: \"10.x\"\n  displayName: \"Install NodeJS\"\n\n- script: |\n    npm install -g vsce\n  displayName: \"Install VSCE\"\n\n- script: |\n    npm install\n  displayName: \"NPM Install\"\n\n- script: |\n    vsce package --out \"$(Build.ArtifactStagingDirectory)/xml-$(Build.SourceBranchName)-$(Build.SourceVersion).vsix\"\n  displayName: \"VSCE Package\"\n\n- task: PublishBuildArtifacts@1\n  inputs:\n    pathtoPublish: $(Build.ArtifactStagingDirectory)\n    artifactName: drop\n"
  },
  {
    "path": "languages/xquery/xquery.json",
    "content": "{\n    \"comments\": {\n        \"lineComment\": [\"(:\", \":)\"],\n        \"blockComment\": [ \"(:~\", \"~:)\"]\n    },\n    \"brackets\": [\n        [\n            \"{\",\n            \"}\"\n        ],\n        [\n            \"[\",\n            \"]\"\n        ],\n        [\n            \"(\",\n            \")\"\n        ]\n    ]\n}\n"
  },
  {
    "path": "languages/xquery/xquery.tmLanguage",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>fileTypes</key>\n\t<array>\n\t\t<string>xq</string>\n\t\t<string>xql</string>\n\t\t<string>xqm</string>\n\t\t<string>xqy</string>\n\t\t<string>xquery</string>\n\t</array>\n\t<key>firstLineMatch</key>\n\t<string>^\\bxquery version\\b.*</string>\n\t<key>foldingStartMarker</key>\n\t<string>^\\s*(&lt;[^!?%/](?!.+?(/&gt;|&lt;/.+?&gt;))|&lt;[!%]--(?!.+?--%?&gt;)|&lt;%[!]?(?!.+?%&gt;))|(declare|.*\\{\\s*(//.*)?$)</string>\n\t<key>foldingStopMarker</key>\n\t<string>^\\s*(&lt;/[^&gt;]+&gt;|[/%]&gt;|--&gt;)\\s*$|(.*\\}\\s*;?\\s*|.*;)</string>\n\t<key>keyEquivalent</key>\n\t<string>^~X</string>\n\t<key>name</key>\n\t<string>XQuery</string>\n\t<key>patterns</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>include</key>\n\t\t\t<string>#Xml</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>include</key>\n\t\t\t<string>#entity</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>include</key>\n\t\t\t<string>#bare-ampersand</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(&lt;\\?)\\s*([-_a-zA-Z0-9]+)</string>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>2</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>entity.name.tag.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>(\\?&gt;)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>meta.tag.preprocessor.xml</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>match</key>\n\t\t\t\t\t<string> ([a-zA-Z-]+)</string>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>entity.other.attribute-name.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#doublequotedString</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#singlequotedString</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>^xquery version .*;$</string>\n\t\t\t<key>name</key>\n\t\t\t<string>keyword.control.import.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>\\b(?i:(\\d+\\.\\d*(e[\\-\\+]?\\d+)?))(?=[^a-zA-Z_])</string>\n\t\t\t<key>name</key>\n\t\t\t<string>constant.numeric.float.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;=[^0-9a-zA-Z_])(?i:(\\.\\d+(e[\\-\\+]?\\d+)?))</string>\n\t\t\t<key>name</key>\n\t\t\t<string>constant.numeric.float.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>\\b(?i:(\\d+e[\\-\\+]?\\d+))</string>\n\t\t\t<key>name</key>\n\t\t\t<string>constant.numeric.float.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>\\b([1-9]+[0-9]*|0)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>constant.numeric.integer.decimal.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>\\b(import|module|schema)\\b</string>\n\t\t\t<key>name</key>\n\t\t\t<string>keyword.control.import.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>\\(:</string>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.comment.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>:\\)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>comment.block.xquery</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#block_comment</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>comment</key>\n\t\t\t<string>http://www.w3.org/TR/xpath-datamodel/#types</string>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])((xs:)(string|boolean|decimal|float|double|duration|dateTime|time|date|gYearMonth|gYear|gMonthDay|gDay|gMonth|hexBinary|base64Binary|anyURI|QName|NOTATION|anyAtomicType|anyType|anySimpleType|untypedAtomic|dayTimeDuration|yearMonthDuration|integer|nonPositiveInteger|negativeInteger|long|int|short|byte|nonNegativeInteger|unsignedLong|unsignedInt|unsignedShort|unsignedByte|positiveInteger|ENTITY|ID|NMTOKEN|language|NCName|Name|token|normalizedString))(?![:\\-_a-zA-Z0-9])</string>\n\t\t\t<key>name</key>\n\t\t\t<string>support.type.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.variable.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t<string>((\\$)(?:([\\-_a-zA-Z0-9]+)((:)))?([\\-_a-zA-Z0-9]+))</string>\n\t\t\t<key>name</key>\n\t\t\t<string>variable.other.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>/(child|descendant|attribute|self|descendant-or-self|following-sibling|following|parent|ancestor|preceding-sibling|preceding|ancestor-or-self)::</string>\n\t\t\t<key>name</key>\n\t\t\t<string>support.constant.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>meta.function.xquery</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>storage.type.function.xquery</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>2</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.function.xquery</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>match</key>\n\t\t\t\t\t<string>(function)\\s+((?:([\\-_a-zA-Z0-9]+):)?([\\-_a-zA-Z0-9]+))\\s*\\(</string>\n\t\t\t\t\t<key>patterns</key>\n\t\t\t\t\t<array>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#function_parameters</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>$self</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</array>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t\t<string>\\s*(function)\\s+(?!namespace)</string>\n\t\t\t\t\t<key>beginCaptures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>storage.type.function.xquery</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>\\(</string>\n\t\t\t\t\t<key>patterns</key>\n\t\t\t\t\t<array>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t\t\t<string>entity.name.function.xquery</string>\n\t\t\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t\t<key>match</key>\n\t\t\t\t\t\t\t<string>((?:([\\-_a-zA-Z0-9]+):)?([\\-_a-zA-Z0-9]+))</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#function_parameters</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>$self</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</array>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>keyword.other.xquery</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>2</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>storage.type.variable.xquery</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>3</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>entity.name.function.variable.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(declare)\\s+(variable)\\s+(\\$(?:[\\-_a-zA-Z0-9]+:)?[\\-_a-zA-Z0-9]+)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>meta.variable.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(declare)\\s+(variable)\\s*</string>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>keyword.other.xquery</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>2</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>storage.type.variable.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>(\\$(?:[\\-_a-zA-Z0-9]+:)?[\\-_a-zA-Z0-9]+)</string>\n\t\t\t<key>endCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>entity.name.function.variable.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>name</key>\n\t\t\t<string>meta.variable.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t\t<string>\\b(base-uri|boundary-space|collation|construction|copy-namespaces|declare|default|element|empty(?![-])|function|greatest|import|inherit|instance|least|module|namespace|no-inherit|no-preserve|option|order|ordered|ordering|preserve|strip|unordered|variable|xdmp:mapping|xdmp:transaction-mode)\\b</string>\n\t\t\t<key>name</key>\n\t\t\t<string>keyword.other.prolog.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(of|as|by|in|at|or|and)(?![:\\-_a-zA-Z0-9])</string>\n\t\t\t<key>name</key>\n\t\t\t<string>keyword.operator.logical.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>keyword.control.flow.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(for|let|return|where|if|then|else|order by|satisfies|every)(?![:\\-_a-zA-Z0-9])</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>support.type.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(element|attribute|document|document-node\\(\\)|empty-sequence\\(\\)|schema-element|schema-attribute|processing-instruction|comment|text|node)(?![:\\-_a-zA-Z0-9])</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>:=</string>\n\t\t\t<key>name</key>\n\t\t\t<string>keyword.operator.assignment.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(\\+|-|&lt;=?|&gt;=?|eq|ne|lt|le|ge|gt|\\*|div|idiv|mod)(?![:\\-_a-zA-Z0-9])</string>\n\t\t\t<key>name</key>\n\t\t\t<string>keyword.operator.arithmetic.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])((fn:)?(abs|adjust-date-to-timezone|adjust-dateTime-to-timezone|adjust-time-to-timezone|analyze-string|avg|base-uri|boolean|ceiling|codepoint-equal|codepoints-to-string|collection|compare|concat|contains|count|current-date|current-dateTime|current-time|data|dateTime|day-from-date|day-from-dateTime|days-from-duration|deep-equal|default-collation|distinct-values|doc|doc-available|document|document-uri|empty|encode-for-uri|ends-with|error|escape-html-uri|escape-uri|exactly-one|exists|false|filter|floor|fold-left|fold-right|format-date|format-dateTime|format-number|format-time|function-arity|function-available|function-lookup|function-name|generate-id|head|hours-from-dateTime|hours-from-duration|hours-from-time|id|idref|implicit-timezone|in-scope-prefixes|index-of|insert-before|iri-to-uri|lang|last|local-name|local-name-from-QName|lower-case|map|map-pairs|matches|max|min|minutes-from-dateTime|minutes-from-duration|minutes-from-time|month-from-date|month-from-dateTime|months-from-duration|name|namespace-uri|namespace-uri-for-prefix|namespace-uri-from-QName|nilled|node-name|normalize-space|normalize-unicode|not|number|one-or-more|position|prefix-from-QName|QName|remove|replace|resolve-QName|resolve-uri|reverse|root|round|round-half-to-even|seconds-from-dateTime|seconds-from-duration|seconds-from-time|starts-with|static-base-uri|string|string-join|string-length|string-to-codepoints|subsequence|substring|substring-after|substring-before|sum|tail|timezone-from-date|timezone-from-dateTime|timezone-from-time|tokenize|trace|translate|true|type-available|unordered|unparsed-text|unparsed-text-available|upper-case|year-from-date|year-from-dateTime|years-from-duration|zero-or-one))(?=\\s*\\()</string>\n\t\t\t<key>name</key>\n\t\t\t<string>support.function.builtin.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(xdmp:(access|add-response-header|add64|address-bindable|amp|amp-roles|and64|annotation|apply|architecture|atomizable|audit|aws-url-encode|base64-decode|base64-encode|binary-decode|binary-is-external|binary-is-large|binary-is-small|binary-join|binary-key|binary-offset|binary-original-length|binary-size|cache-status|can-grant-roles|castable-as|cluster|cluster-name|collation-canonical-uri|collection-delete|collection-locks|collection-properties|commit|compressed-tree-cache-clear|compressed-tree-cache-partitions|compressed-tree-cache-size|configuration-timestamp|content-type|crypt|crypt2|customized-binary|data-directory|database|database-backup|database-backup-cancel|database-backup-purge|database-backup-status|database-backup-validate|database-forests|database-fragment-counts|database-global-nonblocking-timestamp|database-is-replica|database-maintain-last-modified|database-name|database-nonblocking-timestamp|database-partition-forests|database-path-namespaces|database-restore|database-restore-cancel|database-restore-status|database-restore-validate|databases|dayname-from-date|debug-print|decode-from-NCName|default-collections|default-in-memory-limit|default-in-memory-list-size|default-in-memory-range-index-size|default-in-memory-reverse-index-size|default-in-memory-tree-size|default-in-memory-triple-index-size|default-journal-count|default-journal-size|default-license-key|default-licensee|default-permissions|default-preallocate-journals|default-s3-domain|default-zone|delete-cluster-config-file|delete-host-config-file|describe|diacritic-less|directory|directory-create|directory-delete|directory-locks|directory-properties|disable-event|document-add-collections|document-add-permissions|document-add-properties|document-assign|document-delete|document-filter|document-forest|document-get|document-get-collections|document-get-events|document-get-permissions|document-get-properties|document-get-quality|document-insert|document-load|document-locks|document-properties|document-remove-collections|document-remove-permissions|document-remove-properties|document-set-collections|document-set-permissions|document-set-properties|document-set-property|document-set-quality|document-timestamp|dsa-generate|dump-paths|dump-xsd|duplicates|eager|ec2-host|ec2-product-code|elapsed-time|element-content-type|email|email-address|enable-event|encode-for-NCName|encoding-language-detect|estimate|eval|eval-in|excel-convert|exists|expanded-tree-cache-clear|expanded-tree-cache-partitions|expanded-tree-cache-size|external-binary|external-binary-path|external-security|filesystem-directory|filesystem-directory-create|filesystem-directory-delete|filesystem-file|filesystem-file-delete|filesystem-file-exists|filesystem-file-length|filesystem-file-rename|filesystem-filepath|foreign-cluster-status|foreign-clusters|forest|forest-backup|forest-clear|forest-combine|forest-compare|forest-copy|forest-counts|forest-databases|forest-delete|forest-directory-delete|forest-directory-exists|forest-docinfos|forest-get-readonly|forest-host|forest-name|forest-online|forest-open-replica|forest-rename|forest-restart|forest-restore|forest-rollback|forest-set-readonly|forest-status|forest-updates-allowed|forests|format-number|from-json|function|function-module|function-name|function-parameter-name|function-parameter-type|function-return-type|function-signature|functions|get|get-current-roles|get-current-user|get-current-userid|get-external-variable|get-hot-updates|get-invoked-path|get-ip|get-original-url|get-orphaned-binaries|get-request-body|get-request-client-address|get-request-client-certificate|get-request-field|get-request-field-content-type|get-request-field-filename|get-request-field-names|get-request-header|get-request-header-names|get-request-method|get-request-part-body|get-request-part-headers|get-request-path|get-request-port|get-request-protocol|get-request-url|get-request-user|get-request-username|get-response-code|get-response-encoding|get-server-field|get-server-field-names|get-session-field|get-session-field-names|get-transaction-by-xid|get-transaction-mode|get-url-rewriter-path|getenv|group|group-hosts|group-name|group-servers|groups|gss-server-negotiate|gunzip|gzip|has-privilege|hash32|hash64|hex-to-integer|hmac-md5|hmac-sha1|hmac-sha256|hmac-sha512|host|host-cores|host-cpus|host-forests|host-get-ssl-fips-enabled|host-name|host-size|host-status|hostname|hosts|http-delete|http-get|http-head|http-options|http-post|http-put|initcap|install-directory|integer-to-hex|integer-to-octal|invoke|invoke-function|invoke-in|jobject|key-from-QName|language-stemmer-normalization|language-tokenizer-normalization|lazy|ldap-lookup|ldap-search|license-key|license-key-agreement|license-key-cores|license-key-cpus|license-key-decode|license-key-encode|license-key-expires|license-key-options|license-key-size|license-key-valid|license-key-version|licensee|list-cache-clear|list-cache-partitions|list-cache-size|load|lock-acquire|lock-for-update|lock-release|log|log-level|login|logout|lshift64|match-priority|md5|merge|merge-cancel|merging|missing-directories|modules-database|modules-root|month-name-from-date|mul64|multipart-decode|multipart-encode|n3|n3-get|node-database|node-delete|node-insert-after|node-insert-before|node-insert-child|node-kind|node-output-definition|node-replace|node-uri|not64|nquad|nquad-get|octal-to-integer|or64|original-binary|parse-dateTime|parse-yymmdd|path|pdf-convert|permission|plan|plannable|platform|position|powerpoint-convert|pre-release-expires|pretty-print|privilege|privilege-roles|product-edition|product-environment|product-initials|product-name|QName-from-key|quality|quarter-from-date|query-forests|query-meters|query-trace|quote|random|read-cluster-config-file|read-host-config-file|redirect-response|remove-orphaned-binary|request|request-cancel|request-key|request-status|request-timestamp|resolve-uri|restart|rethrow|role|role-roles|rollback|rsa-generate|rshift64|save|schema-database|score|security-assert|security-database|security-version|server|server-backup|server-name|server-restore|server-status|servers|set|set-current-transaction|set-hot-updates|set-request-time-limit|set-response-code|set-response-content-type|set-response-encoding|set-server-field|set-server-field-privilege|set-session-field|set-transaction-mode|set-transaction-name|set-transaction-time-limit|sha1|sha256|sha384|sha512|shutdown|sleep|smtp-relay|spawn|spawn-function|spawn-in|sql|start-journal-archiving|step64|stop-journal-archiving|strftime|subbinary|test-future|test-lazy|test-skiplist|tidy|timestamp-to-wallclock|to-json|trace|transaction|transaction-commit|transaction-create|transaction-rollback|triggers-database|triple-cache-partitions|triple-cache-size|triple-value-cache-partitions|triple-value-cache-size|turtle|turtle-get|type|unpath|unquote|update|uri-content-type|uri-format|uri-is-file|url-decode|url-encode|user|user-external-security|user-last-login|user-roles|username|validate|value|version|wallclock-to-timestamp|week-from-date|weekday-from-date|word-convert|write-cluster-config-file|write-host-config-file|x509-certificate-extract|x509-certificate-generate|x509-crl-der2pem|x509-crl-extract|x509-crl-generate|x509-request-extract|x509-request-generate|xa-complete|xa-complete-xid|xa-complete1|xa-forget|xa-forget-xid|xa-prepare|xor64|xquery-version|xslt-eval|xslt-invoke|yearday-from-date|zip-create|zip-get|zip-manifest))(?=\\s*\\()</string>\n\t\t\t<key>name</key>\n\t\t\t<string>support.function.marklogic.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(cts:(aggregate|and-not-query|and-not-query-negative-query|and-not-query-positive-query|and-query|and-query-options|and-query-queries|approx-center|arc-intersection|avg|avg-aggregate|bearing|boost-query|boost-query-boosting-query|boost-query-matching-query|bounding-boxes|box|box-east|box-intersects|box-north|box-south|box-west|circle|circle-center|circle-intersects|circle-radius|classify|cluster|codepoint-tokenizer-class|collection-match|collection-query|collection-query-uris|collection-reference|collections|complex-polygon|complex-polygon-contains|complex-polygon-inner|complex-polygon-intersects|complex-polygon-outer|confidence|contains|correlation|count|count-aggregate|covariance|covariance-p|deregister|destination|directory-query|directory-query-depth|directory-query-uris|distance|distinctive-terms|document-fragment-query|document-fragment-query-query|document-query|document-query-uris|element-attribute-pair-geospatial-boxes|element-attribute-pair-geospatial-query|element-attribute-pair-geospatial-query-element-name|element-attribute-pair-geospatial-query-latitude-name|element-attribute-pair-geospatial-query-longitude-name|element-attribute-pair-geospatial-query-options|element-attribute-pair-geospatial-query-region|element-attribute-pair-geospatial-query-weight|element-attribute-pair-geospatial-value-match|element-attribute-pair-geospatial-values|element-attribute-range-query|element-attribute-range-query-attribute-name|element-attribute-range-query-element-name|element-attribute-range-query-operator|element-attribute-range-query-options|element-attribute-range-query-value|element-attribute-range-query-weight|element-attribute-reference|element-attribute-value-co-occurrences|element-attribute-value-geospatial-co-occurrences|element-attribute-value-match|element-attribute-value-query|element-attribute-value-query-attribute-name|element-attribute-value-query-element-name|element-attribute-value-query-options|element-attribute-value-query-text|element-attribute-value-query-weight|element-attribute-value-ranges|element-attribute-values|element-attribute-word-match|element-attribute-word-query|element-attribute-word-query-attribute-name|element-attribute-word-query-element-name|element-attribute-word-query-options|element-attribute-word-query-text|element-attribute-word-query-weight|element-attribute-words|element-child-geospatial-boxes|element-child-geospatial-query|element-child-geospatial-query-child-name|element-child-geospatial-query-element-name|element-child-geospatial-query-options|element-child-geospatial-query-region|element-child-geospatial-query-weight|element-child-geospatial-value-match|element-child-geospatial-values|element-geospatial-boxes|element-geospatial-query|element-geospatial-query-element-name|element-geospatial-query-options|element-geospatial-query-region|element-geospatial-query-weight|element-geospatial-value-match|element-geospatial-values|element-pair-geospatial-boxes|element-pair-geospatial-query|element-pair-geospatial-query-element-name|element-pair-geospatial-query-latitude-name|element-pair-geospatial-query-longitude-name|element-pair-geospatial-query-options|element-pair-geospatial-query-region|element-pair-geospatial-query-weight|element-pair-geospatial-value-match|element-pair-geospatial-values|element-query|element-query-element-name|element-query-query|element-range-query|element-range-query-element-name|element-range-query-operator|element-range-query-options|element-range-query-value|element-range-query-weight|element-reference|element-value-co-occurrences|element-value-geospatial-co-occurrences|element-value-match|element-value-query|element-value-query-element-name|element-value-query-options|element-value-query-text|element-value-query-weight|element-value-ranges|element-values|element-word-match|element-word-query|element-word-query-element-name|element-word-query-options|element-word-query-text|element-word-query-weight|element-words|field-range-query|field-range-query-field-name|field-range-query-operator|field-range-query-options|field-range-query-value|field-range-query-weight|field-reference|field-value-co-occurrences|field-value-match|field-value-query|field-value-query-field-name|field-value-query-options|field-value-query-text|field-value-query-weight|field-value-ranges|field-values|field-word-match|field-word-query|field-word-query-field-name|field-word-query-options|field-word-query-text|field-word-query-weight|field-words|fitness|frequency|geospatial-attribute-pair-reference|geospatial-co-occurrences|geospatial-element-attribute-pair-reference|geospatial-element-child-reference|geospatial-element-pair-reference|geospatial-element-reference|geospatial-path-reference|hash-terms|index-path-key|index-path-keys|index-path-ns-prefixes|linear-model|linestring|linestring-vertices|locks-query|locks-query-query|long-lat-point|matches|max|median|min|near-query|near-query-distance|near-query-options|near-query-queries|near-query-weight|not-in-query|not-in-query-negative-query|not-in-query-positive-query|not-query|not-query-query|not-query-weight|or-query|or-query-queries|parse|parse-wkt|path-geospatial-query|path-geospatial-query-options|path-geospatial-query-path-expression|path-geospatial-query-region|path-geospatial-query-weight|path-range-query|path-range-query-operator|path-range-query-options|path-range-query-path-name|path-range-query-value|path-range-query-weight|path-reference|percent-rank|percentile|point|point-latitude|point-longitude|polygon|polygon-contains|polygon-intersects|polygon-vertices|properties-query|properties-query-query|punctuation|quality|query|rank|reference|reference-parse|region|region-contains|region-intersects|register|registered-query|registered-query-ids|registered-query-options|registered-query-weight|relevance-info|remainder|reverse-query|reverse-query-nodes|reverse-query-weight|score|search|shortest-distance|show-get-query|similar-query|similar-query-nodes|similar-query-weight|space|special|stddev|stddev-p|stem|sum|sum-aggregate|term-query|term-query-term|term-query-weight|thresholds|time-series|timestamp-query|to-wkt|token|tokenize|train|triple-range-query|triple-range-query-object|triple-range-query-operator|triple-range-query-options|triple-range-query-predicate|triple-range-query-subject|triple-range-query-weight|triples|uri-match|uri-reference|uris|valid-index-path|value-co-occurrences|value-match|value-ranges|value-tuples|values|variance|variance-p|word|word-match|word-query|word-query-options|word-query-text|word-query-weight|words))(?=\\s*\\()</string>\n\t\t\t<key>name</key>\n\t\t\t<string>support.function.cts.xquery</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(xdmp:([\\-_a-zA-Z0-9][\\-\\._a-zA-Z0-9]*:)?([\\-_a-zA-Z0-9][\\-\\._a-zA-Z0-9]*))\\s*\\(</string>\n\t\t\t<key>name</key>\n\t\t\t<string>invalid.illegal.function.xdmp</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(?&lt;![:\\-_a-zA-Z0-9])(cts:([\\-_a-zA-Z0-9][\\-\\._a-zA-Z0-9]*:)?([\\-_a-zA-Z0-9][\\-\\._a-zA-Z0-9]*))\\s*\\(</string>\n\t\t\t<key>name</key>\n\t\t\t<string>invalid.illegal.function.cts</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>include</key>\n\t\t\t<string>#string</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(\\()</string>\n\t\t\t<key>beginCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.begin.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>(\\))</string>\n\t\t\t<key>endCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.end.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>name</key>\n\t\t\t<string>meta</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>$self</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>include</key>\n\t\t\t<string>#function_call</string>\n\t\t</dict>\n\t</array>\n\t<key>repository</key>\n\t<dict>\n\t\t<key>EntityDecl</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(&lt;!)(ENTITY)\\s+(%\\s+)?([:a-zA-Z_][:a-zA-Z0-9_.-]*)(\\s+(?:SYSTEM|PUBLIC)\\s+)?</string>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>2</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>keyword.entity.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>3</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.entity.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>4</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>variable.entity.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>5</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>keyword.entitytype.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>(&gt;)</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#doublequotedStringXml</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#singlequotedStringXml</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>Xml</key>\n\t\t<dict>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>(&lt;\\?)\\s*([-_a-zA-Z0-9]+)</string>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>2</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>(\\?&gt;)</string>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>meta.tag.preprocessor.xml</string>\n\t\t\t\t\t<key>patterns</key>\n\t\t\t\t\t<array>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>match</key>\n\t\t\t\t\t\t\t<string> ([a-zA-Z-]+)</string>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.other.attribute-name.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#doublequotedString</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#singlequotedString</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</array>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>(&lt;!)(DOCTYPE)\\s+([:a-zA-Z_][:a-zA-Z0-9_.-]*)</string>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>2</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>keyword.doctype.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>3</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>variable.documentroot.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>\\s*(&gt;)</string>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>meta.tag.sgml.doctype.xml</string>\n\t\t\t\t\t<key>patterns</key>\n\t\t\t\t\t<array>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#internalSubset</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</array>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>&lt;[!%]--</string>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>0</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.comment.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>--%?&gt;</string>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>comment.block.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>&lt;\\?</string>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>0</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.processing-instruction.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>\\?&gt;</string>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>comment.processing-instruction.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>(&lt;)((?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]+))(?=(\\s[^&gt;]*)?&gt;&lt;/\\2&gt;)</string>\n\t\t\t\t\t<key>beginCaptures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>3</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>4</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>5</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.separator.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>6</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.localname.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>(&gt;)(&lt;)(/)(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]+)(&gt;)</string>\n\t\t\t\t\t<key>endCaptures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.end.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>2</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.begin.xml meta.scope.between-tag-pair.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>3</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>4</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>5</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>6</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.separator.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>7</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.localname.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>8</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.end.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>meta.tag.no-content.xml</string>\n\t\t\t\t\t<key>patterns</key>\n\t\t\t\t\t<array>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#tagStuff</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</array>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>(&lt;/?)(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]+)</string>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.begin.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>2</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>3</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>4</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.separator.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>5</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.name.tag.localname.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>(/?&gt;)</string>\n\t\t\t\t\t<key>endCaptures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.tag.end.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>meta.tag.xml</string>\n\t\t\t\t\t<key>patterns</key>\n\t\t\t\t\t<array>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>include</key>\n\t\t\t\t\t\t\t<string>#tagStuff</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</array>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#entity</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#bare-ampersand</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>begin</key>\n\t\t\t\t\t<string>&lt;!\\[CDATA\\[</string>\n\t\t\t\t\t<key>beginCaptures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>0</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.string.begin.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>end</key>\n\t\t\t\t\t<string>]]&gt;</string>\n\t\t\t\t\t<key>endCaptures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>0</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.definition.string.end.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>string.unquoted.cdata.xml</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>bare-ampersand</key>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>&amp;</string>\n\t\t\t<key>name</key>\n\t\t\t<string>invalid.illegal.bad-ampersand.xml</string>\n\t\t</dict>\n\t\t<key>block_comment</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>\\(:</string>\n\t\t\t<key>end</key>\n\t\t\t<string>:\\)</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#block_comment</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>code_block</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>\\{</string>\n\t\t\t<key>end</key>\n\t\t\t<string>\\}</string>\n\t\t\t<key>name</key>\n\t\t\t<string>meta.code-block.xquery</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>$self</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>doublequotedString</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(?&lt;![-_a-zA-Z0-9:'\"]&gt;)\\s*\"(?![\\w\\s()']*&lt;/[-_a-zA-Z0-9:])</string>\n\t\t\t<key>beginCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.begin.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>\"</string>\n\t\t\t<key>endCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.end.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>name</key>\n\t\t\t<string>string.quoted.double.xquery</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#entity</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#bare-ampersand</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>doublequotedStringXml</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>\"</string>\n\t\t\t<key>beginCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.begin.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>\"</string>\n\t\t\t<key>endCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.end.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>name</key>\n\t\t\t<string>string.quoted.double.xml</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#entity</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#bare-ampersand</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#code_block</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>entity</key>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.constant.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(&amp;)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>constant.character.entity.xml</string>\n\t\t</dict>\n\t\t<key>function_call</key>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.parameters.begin.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t<string>[\\-_a-zA-Z0-9]+:[\\-_a-zA-Z0-9]+(?=\\()</string>\n\t\t\t<key>name</key>\n\t\t\t<string>support.function.xquery</string>\n\t\t</dict>\n\t\t<key>function_parameters</key>\n\t\t<dict>\n\t\t\t<key>match</key>\n\t\t\t<string>\\$([\\-_a-zA-Z0-9][\\-\\._a-zA-Z0-9]*:)?([\\-_a-zA-Z0-9][\\-\\._a-zA-Z0-9]*)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>variable.parameter.xquery</string>\n\t\t</dict>\n\t\t<key>internalSubset</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(\\[)</string>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.constant.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>(\\])</string>\n\t\t\t<key>name</key>\n\t\t\t<string>meta.internalsubset.xml</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#EntityDecl</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#parameterEntity</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>parameterEntity</key>\n\t\t<dict>\n\t\t\t<key>captures</key>\n\t\t\t<dict>\n\t\t\t\t<key>1</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.constant.xml</string>\n\t\t\t\t</dict>\n\t\t\t\t<key>3</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.constant.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>match</key>\n\t\t\t<string>(%)([:a-zA-Z_][:a-zA-Z0-9_.-]*)(;)</string>\n\t\t\t<key>name</key>\n\t\t\t<string>constant.character.parameter-entity.xml</string>\n\t\t</dict>\n\t\t<key>singlequotedString</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>(?&lt;![-_a-zA-Z0-9:'\"]&gt;)\\s*'(?![\\w\\s()\"]*&lt;/[-_a-zA-Z0-9:])</string>\n\t\t\t<key>beginCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.begin.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>'</string>\n\t\t\t<key>endCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.end.xquery</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>name</key>\n\t\t\t<string>string.quoted.single.xquery</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#entity</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#bare-ampersand</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>singlequotedStringXml</key>\n\t\t<dict>\n\t\t\t<key>begin</key>\n\t\t\t<string>'</string>\n\t\t\t<key>beginCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.begin.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>end</key>\n\t\t\t<string>'</string>\n\t\t\t<key>endCaptures</key>\n\t\t\t<dict>\n\t\t\t\t<key>0</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>name</key>\n\t\t\t\t\t<string>punctuation.definition.string.end.xml</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>name</key>\n\t\t\t<string>string.quoted.single.xml</string>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#entity</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#bare-ampersand</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#code_block</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>string</key>\n\t\t<dict>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#singlequotedString</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#doublequotedString</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t\t<key>tagStuff</key>\n\t\t<dict>\n\t\t\t<key>patterns</key>\n\t\t\t<array>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>captures</key>\n\t\t\t\t\t<dict>\n\t\t\t\t\t\t<key>1</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.other.attribute-name.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>2</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.other.attribute-name.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>3</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>punctuation.separator.namespace.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t\t<key>4</key>\n\t\t\t\t\t\t<dict>\n\t\t\t\t\t\t\t<key>name</key>\n\t\t\t\t\t\t\t<string>entity.other.attribute-name.localname.xml</string>\n\t\t\t\t\t\t</dict>\n\t\t\t\t\t</dict>\n\t\t\t\t\t<key>match</key>\n\t\t\t\t\t<string>(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9]+)=</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#doublequotedStringXml</string>\n\t\t\t\t</dict>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>include</key>\n\t\t\t\t\t<string>#singlequotedStringXml</string>\n\t\t\t\t</dict>\n\t\t\t</array>\n\t\t</dict>\n\t</dict>\n\t<key>scopeName</key>\n\t<string>source.xquery</string>\n\t<key>uuid</key>\n\t<string>cddd8a73-ed1e-4303-a649-a23e816fafa1</string>\n</dict>\n</plist>"
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"xml\",\n    \"displayName\": \"XML Tools\",\n    \"description\": \"XML Formatting, XQuery, and XPath Tools for Visual Studio Code\",\n    \"version\": \"2.5.1\",\n    \"preview\": false,\n    \"publisher\": \"DotJoshJohnson\",\n    \"author\": {\n        \"name\": \"Josh Johnson\",\n        \"url\": \"https://github.com/DotJoshJohnson\"\n    },\n    \"galleryBanner\": {\n        \"color\": \"#FFFFFF\",\n        \"theme\": \"light\"\n    },\n    \"icon\": \"resources/xml.png\",\n    \"homepage\": \"https://github.com/DotJoshJohnson/vscode-xml\",\n    \"repository\": {\n        \"type\": \"git\",\n        \"url\": \"https://github.com/DotJoshJohnson/vscode-xml.git\"\n    },\n    \"bugs\": {\n        \"url\": \"https://github.com/DotJoshJohnson/vscode-xml/issues\"\n    },\n    \"engines\": {\n        \"vscode\": \"^1.22.2\"\n    },\n    \"categories\": [\n        \"Formatters\",\n        \"Programming Languages\",\n        \"Linters\",\n        \"Other\"\n    ],\n    \"activationEvents\": [\n        \"onCommand:xmlTools.evaluateXPath\",\n        \"onCommand:xmlTools.executeXQuery\",\n        \"onCommand:xmlTools.formatAsXml\",\n        \"onCommand:xmlTools.textToXml\",\n        \"onCommand:xmlTools.xmlToText\",\n        \"onCommand:xmlTools.minifyXml\",\n        \"onLanguage:xml\",\n        \"onLanguage:xquery\",\n        \"onLanguage:xsl\"\n    ],\n    \"main\": \"./out/extension\",\n    \"contributes\": {\n        \"commands\": [\n            {\n                \"command\": \"xmlTools.evaluateXPath\",\n                \"title\": \"XML Tools: Evaluate XPath\"\n            },\n            {\n                \"command\": \"xmlTools.executeXQuery\",\n                \"title\": \"XML Tools: Execute XQuery\"\n            },\n            {\n                \"command\": \"xmlTools.formatAsXml\",\n                \"title\": \"XML Tools: Format as XML\"\n            },\n            {\n                \"command\": \"xmlTools.textToXml\",\n                \"title\": \"XML Tools: Convert text to XML (&lt;&gt; -> <>)\"\n            },\n            {\n                \"command\": \"xmlTools.xmlToText\",\n                \"title\": \"XML Tools: Convert XML to text  (<> -> &lt;&gt;)\"\n            },\n            {\n                \"command\": \"xmlTools.getCurrentXPath\",\n                \"title\": \"XML Tools: Get Current XPath\"\n            },\n            {\n                \"command\": \"xmlTools.minifyXml\",\n                \"title\": \"XML Tools: Minify XML\"\n            }\n        ],\n        \"configuration\": {\n            \"title\": \"XML Tools Configuration\",\n            \"type\": \"object\",\n            \"properties\": {\n                \"xmlTools.enableXmlTreeView\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Enables the XML Document view in the explorer for XML documents.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.enableXmlTreeViewMetadata\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Enables attribute and child element counts in the XML Document view.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.enableXmlTreeViewCursorSync\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.enforcePrettySelfClosingTagOnFormat\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Enforces a space before the forward slash at the end of a self-closing XML tag.\",\n                    \"scope\": \"resource\"\n                },\n                \"xmlTools.ignoreDefaultNamespace\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Ignore default xmlns attributes when evaluating XPath.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.persistXPathQuery\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Remember the last XPath query used.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.removeCommentsOnMinify\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Remove XML comments during minification.\",\n                    \"scope\": \"resource\"\n                },\n                \"xmlTools.splitAttributesOnFormat\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Put each attribute on a new line when formatting XML. Overrides `xmlTools.splitXmlnsOnFormat` if set to `true`.\",\n                    \"scope\": \"resource\"\n                },\n                \"xmlTools.splitXmlnsOnFormat\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Put each xmlns attribute on a new line when formatting XML.\",\n                    \"scope\": \"resource\"\n                },\n                \"xmlTools.xmlFormatterImplementation\": {\n                    \"type\": \"string\",\n                    \"enum\": [\n                        \"classic\",\n                        \"v2\"\n                    ],\n                    \"default\": \"v2\",\n                    \"description\": \"Supported XML Formatters: classic\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.xqueryExecutionArguments\": {\n                    \"type\": \"array\",\n                    \"default\": [\n                        \"-xquery\",\n                        \"$(script)\",\n                        \"-in\",\n                        \"$(input)\",\n                        \"-out\",\n                        \"$(input).output.xml\"\n                    ],\n                    \"description\": \"Arguments to be passed to the XQuery execution engine.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.xqueryExecutionEngine\": {\n                    \"type\": \"string\",\n                    \"default\": \"\",\n                    \"description\": \"The full path to the executable to run when executing XQuery scripts.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.xqueryExecutionInputLimit\": {\n                    \"type\": \"integer\",\n                    \"default\": 100,\n                    \"description\": \"The maximum number of input files to enumerate when executing XQuery scripts.\",\n                    \"scope\": \"window\"\n                },\n                \"xmlTools.xqueryExecutionInputSearchPattern\": {\n                    \"type\": \"string\",\n                    \"default\": \"**/*.xml\",\n                    \"description\": \"The pattern used to search for input XML files when executing XQuery scripts.\",\n                    \"scope\": \"window\"\n                }\n            }\n        },\n        \"grammars\": [\n            {\n                \"language\": \"xquery\",\n                \"path\": \"./languages/xquery/xquery.tmLanguage\",\n                \"scopeName\": \"source.xquery\"\n            }\n        ],\n        \"keybindings\": [\n            {\n                \"key\": \"ctrl+shift+alt+x\",\n                \"command\": \"xmlTools.evaluateXPath\"\n            },\n            {\n                \"key\": \"ctrl+shift+alt+b\",\n                \"command\": \"xmlTools.formatAsXml\"\n            }\n        ],\n        \"languages\": [\n            {\n                \"id\": \"xml\",\n                \"extensions\": [\n                    \".config\",\n                    \".csproj\",\n                    \".xml\",\n                    \".xsd\",\n                    \".xsl\",\n                    \".plist\",\n                    \".mobileconfig\"\n                ]\n            },\n            {\n                \"id\": \"xquery\",\n                \"aliases\": [\n                    \"XQuery\",\n                    \"xquery\"\n                ],\n                \"extensions\": [\n                    \".xq\",\n                    \".xql\",\n                    \".xqm\",\n                    \".xqy\",\n                    \".xquery\"\n                ],\n                \"configuration\": \"./languages/xquery/xquery.json\"\n            }\n        ],\n        \"menus\": {\n            \"commandPalette\": [\n                {\n                    \"command\": \"xmlTools.evaluateXPath\",\n                    \"when\": \"editorLangId == xml\"\n                },\n                {\n                    \"command\": \"xmlTools.executeXQuery\",\n                    \"when\": \"editorLangId == xquery\"\n                },\n                {\n                    \"command\": \"xmlTools.getCurrentXPath\",\n                    \"when\": \"editorLangId == xml\"\n                },\n                {\n                    \"command\": \"xmlTools.minifyXml\",\n                    \"when\": \"editorLangId == xml\"\n                }\n            ],\n            \"editor/context\": [\n                {\n                    \"command\": \"xmlTools.minifyXml\",\n                    \"group\": \"1_modification@100\",\n                    \"when\": \"editorLangId == 'xml'\"\n                }\n            ]\n        },\n        \"views\": {\n            \"explorer\": [\n                {\n                    \"id\": \"xmlTreeView\",\n                    \"name\": \"XML Document\",\n                    \"when\": \"xmlTreeViewEnabled\"\n                }\n            ]\n        }\n    },\n    \"scripts\": {\n        \"vscode:prepublish\": \"npm run compile\",\n        \"compile\": \"npm run lint && tsc -p ./\",\n        \"watch\": \"tsc -watch -p ./\",\n        \"postinstall\": \"node ./node_modules/vscode/bin/install\",\n        \"test\": \"npm run compile && mocha './out/test/**/*.js'\",\n        \"test-windows\": \"npm run compile && mocha ./out/test/**/*.js\",\n        \"lint\": \"tslint -p tslint.json --fix\"\n    },\n    \"devDependencies\": {\n        \"@types/mocha\": \"^2.2.42\",\n        \"@types/node\": \"^7.0.43\",\n        \"@types/xmldom\": \"^0.1.29\",\n        \"tslint\": \"^5.9.1\",\n        \"typescript\": \"^2.6.1\",\n        \"vscode\": \"^1.1.16\"\n    },\n    \"dependencies\": {\n        \"xmldom\": \"^0.1.27\",\n        \"xpath\": \"0.0.27\",\n        \"xqlint\": \"^0.4.1\"\n    }\n}\n"
  },
  {
    "path": "src/common/configuration.ts",
    "content": "import { workspace, Uri } from \"vscode\";\n\nconst ExtensionTopLevelSection = \"xmlTools\";\n\nexport class Configuration {\n    static get enableXmlTreeView(): boolean {\n        return this._getForWindow<boolean>(\"enableXmlTreeView\");\n    }\n\n    static get enableXmlTreeViewMetadata(): boolean {\n        return this._getForWindow<boolean>(\"enableXmlTreeViewMetadata\");\n    }\n\n    static get enableXmlTreeViewCursorSync(): boolean {\n        return this._getForWindow<boolean>(\"enableXmlTreeViewCursorSync\");\n    }\n\n    static get ignoreDefaultNamespace(): boolean {\n        return this._getForWindow<boolean>(\"ignoreDefaultNamespace\");\n    }\n\n    static get persistXPathQuery(): boolean {\n        return this._getForWindow<boolean>(\"persistXPathQuery\");\n    }\n\n    static get xmlFormatterImplementation(): string {\n        return this._getForWindow<string>(\"xmlFormatterImplementation\");\n    }\n\n    static get xqueryExecutionArguments(): string[] {\n        return this._getForWindow<string[]>(\"xqueryExecutionArguments\");\n    }\n\n    static get xqueryExecutionEngine(): string {\n        return this._getForWindow<string>(\"xqueryExecutionEngine\");\n    }\n\n    static get xqueryExecutionInputLimit(): number {\n        return this._getForWindow<number>(\"xqueryExecutionInputLimit\");\n    }\n\n    static get xqueryExecutionInputSearchPattern(): string {\n        return this._getForWindow<string>(\"xqueryExecutionInputSearchPattern\");\n    }\n\n    static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {\n        return this._getForResource<boolean>(\"enforcePrettySelfClosingTagOnFormat\", resource);\n    }\n\n    static removeCommentsOnMinify(resource: Uri): boolean {\n        return this._getForResource<boolean>(\"removeCommentsOnMinify\", resource);\n    }\n\n    static splitAttributesOnFormat(resource: Uri): boolean {\n        return this._getForResource<boolean>(\"splitAttributesOnFormat\", resource);\n    }\n\n    static splitXmlnsOnFormat(resource: Uri): boolean {\n        return this._getForResource<boolean>(\"splitXmlnsOnFormat\", resource);\n    }\n\n    private static _getForResource<T>(section: string, resource: Uri): T {\n        return workspace.getConfiguration(ExtensionTopLevelSection, resource).get<T>(section);\n    }\n\n    private static _getForWindow<T>(section: string): T  {\n        return workspace.getConfiguration(ExtensionTopLevelSection).get<T>(section);\n    }\n}\n"
  },
  {
    "path": "src/common/create-document-selector.ts",
    "content": "import { DocumentFilter } from \"vscode\";\n\nimport * as constants from \"../constants\";\n\nexport function createDocumentSelector(language: string): DocumentFilter[] {\n    return [\n        { language, scheme: constants.uriSchemes.file },\n        { language, scheme: constants.uriSchemes.untitled },\n    ];\n}\n"
  },
  {
    "path": "src/common/extension-state.ts",
    "content": "import { ExtensionContext, Memento } from \"vscode\";\n\nexport class ExtensionState {\n    private static _context: ExtensionContext;\n\n    static get global(): Memento {\n        return this._context.globalState;\n    }\n\n    static get workspace(): Memento {\n        return this._context.workspaceState;\n    }\n\n    static configure(context: ExtensionContext): void {\n        this._context = context;\n    }\n}\n"
  },
  {
    "path": "src/common/index.ts",
    "content": "export * from \"./configuration\";\nexport * from \"./create-document-selector\";\nexport * from \"./extension-state\";\nexport * from \"./native-commands\";\nexport * from \"./xml-traverser\";\n"
  },
  {
    "path": "src/common/native-commands.ts",
    "content": "import { commands } from \"vscode\";\n\nexport class NativeCommands {\n    static async cursorMove(to: string, by: string): Promise<void> {\n        await commands.executeCommand(\"cursorMove\", {\n            to: to,\n            by: by\n        });\n    }\n\n    static openGlobalSettings(): void {\n        commands.executeCommand(\"workbench.action.openGlobalSettings\");\n    }\n\n    static setContext(key: string, value: any): void {\n        commands.executeCommand(\"setContext\", key, value);\n    }\n}\n"
  },
  {
    "path": "src/common/xml-traverser.ts",
    "content": "import { Position } from \"vscode\";\nimport { DOMParser } from \"xmldom\";\n\nexport class XmlTraverser {\n\n    constructor(private _xmlDocument: Document) { }\n\n    get xmlDocument(): Document {\n        return this._xmlDocument;\n    }\n\n    set xmlDocument(value: Document) {\n        this._xmlDocument = value;\n    }\n\n    getChildAttributeArray(node: Element): any[] {\n        if (!node.attributes) {\n            return [];\n        }\n\n        const array = new Array<any>();\n\n        for (let i = 0; i < node.attributes.length; i++) {\n            array.push(node.attributes[i]);\n        }\n\n        return array;\n    }\n\n    getChildElementArray(node: Node): any[] {\n        if (!node.childNodes) {\n            return [];\n        }\n\n        const array = new Array<any>();\n\n        for (let i = 0; i < node.childNodes.length; i++) {\n            const child = node.childNodes[i];\n\n            if (this.isElement(child)) {\n                array.push(child);\n            }\n        }\n\n        return array;\n    }\n\n    getElementAtPosition(position: Position): Element {\n        const node = this.getNodeAtPosition(position);\n\n        return this.getNearestElementAncestor(node);\n    }\n\n    getNearestElementAncestor(node: Node): Element {\n        if (!this.isElement) {\n            return this.getNearestElementAncestor(node.parentNode);\n        }\n\n        return <Element>node;\n    }\n\n    getNodeAtPosition(position: Position): Node {\n        return this._getNodeAtPositionCore(position, this._xmlDocument.documentElement);\n    }\n\n    getSiblings(node: Node): Node[] {\n        if (this.isElement(node)) {\n            return this.getSiblingElements(node);\n        }\n\n        return this.getSiblingAttributes(node);\n    }\n\n    getSiblingAttributes(node: Node): Node[] {\n        return this.getChildAttributeArray(<Element>node.parentNode);\n    }\n\n    getSiblingElements(node: Node): Node[] {\n        return this.getChildElementArray(node.parentNode);\n    }\n\n    hasSimilarSiblings(node: Node): boolean {\n        if (!node || !node.parentNode || !this.isElement(node)) {\n            return false;\n        }\n\n        const siblings = this.getChildElementArray(<Element>node.parentNode);\n\n        return (siblings.filter(x => x.tagName === (node as Element).tagName).length > 1);\n    }\n\n    isElement(node: Node): boolean {\n        return (!!node && !!(node as Element).tagName);\n    }\n\n    private _getNodeAtPositionCore(position: Position, contextNode: Node): Node {\n        if (!contextNode) {\n            return undefined;\n        }\n\n        const lineNumber = (contextNode as any).lineNumber;\n        const columnNumber = (contextNode as any).columnNumber;\n        const columnRange = [columnNumber, (columnNumber + (this._getNodeWidthInCharacters(contextNode) - 1))];\n\n        // for some reason, xmldom sets the column number for attributes to the \"=\"\n        if (!this.isElement(contextNode)) {\n            columnRange[0] = (columnRange[0] - contextNode.nodeName.length);\n        }\n\n        if (this._checkRange(lineNumber, position, columnRange)) {\n            return contextNode;\n        }\n\n        if (this.isElement(contextNode)) {\n            // if the element contains text, check to see if the cursor is present in the text\n            const textContent = (contextNode as Element).textContent;\n\n            if (textContent) {\n                columnRange[1] = (columnRange[1] + textContent.length);\n\n                if (this._checkRange(lineNumber, position, columnRange)) {\n                    return contextNode;\n                }\n            }\n\n            const children = [...this.getChildAttributeArray(<Element>contextNode), ...this.getChildElementArray(contextNode)];\n            let result: Node;\n\n            for (let i = 0; i < children.length; i++) {\n                const child = children[i];\n\n                result = this._getNodeAtPositionCore(position, child);\n\n                if (result) {\n                    return result;\n                }\n            }\n        }\n\n        return undefined;\n    }\n\n    private _checkRange(lineNumber: number, position: Position, columnRange: number[]): boolean {\n        return (lineNumber === (position.line + 1) && ((position.character + 1) >= columnRange[0] && (position.character + 1) < columnRange[1]));\n    }\n\n    private _getNodeWidthInCharacters(node: Node) {\n        if (this.isElement(node)) {\n            return (node.nodeName.length + 2);\n        }\n\n        else {\n            return (node.nodeName.length + node.nodeValue.length + 3);\n        }\n    }\n}\n"
  },
  {
    "path": "src/completion/index.ts",
    "content": "export * from \"./xquery-completion-item-provider\";\n"
  },
  {
    "path": "src/completion/xquery-completion-item-provider.ts",
    "content": "import { CompletionItem, CompletionItemKind, CompletionItemProvider, Position, TextDocument } from \"vscode\";\n\nconst XQLint = require(\"xqlint\").XQLint;\n\nexport class XQueryCompletionItemProvider implements CompletionItemProvider {\n\n    provideCompletionItems(document: TextDocument, position: Position): CompletionItem[] {\n        const completionItems = new Array<CompletionItem>();\n        const linter = new XQLint(document.getText());\n\n        linter.getCompletions({ line: position.line, col: position.character }).forEach((x: any) => {\n            completionItems.push(this._getCompletionItem(x));\n        });\n\n        return completionItems;\n    }\n\n    private _getCompletionItem(xqLintCompletionItem: any): CompletionItem {\n        const completionItem = new CompletionItem(xqLintCompletionItem.name);\n        completionItem.insertText = xqLintCompletionItem.value;\n\n        switch (xqLintCompletionItem.meta) {\n            // functions (always qualified with a colon)\n            case \"function\":\n                completionItem.kind = CompletionItemKind.Function;\n\n                const funcStart = (xqLintCompletionItem.value.indexOf(\":\") + 1);\n                const funcEnd = xqLintCompletionItem.value.indexOf(\"(\");\n\n                completionItem.insertText = xqLintCompletionItem.value.substring(funcStart, funcEnd);\n            break;\n\n            // variables and parameters (always qualified with a dollar sign)\n            case \"Let binding\":\n            case \"Local variable\":\n            case \"Window variable\":\n            case \"Function parameter\":\n                completionItem.kind = CompletionItemKind.Variable;\n                completionItem.insertText = xqLintCompletionItem.value.substring(1);\n            break;\n\n            // everything else\n            default:\n                completionItem.kind = CompletionItemKind.Text;\n            break;\n        }\n\n        return completionItem;\n    }\n\n}\n"
  },
  {
    "path": "src/constants.ts",
    "content": "export namespace commands {\n    export const evaluateXPath = \"xmlTools.evaluateXPath\";\n    export const executeXQuery = \"xmlTools.executeXQuery\";\n    export const formatAsXml = \"xmlTools.formatAsXml\";\n    export const xmlToText = \"xmlTools.xmlToText\";\n    export const textToXml = \"xmlTools.textToXml\";\n    export const getCurrentXPath = \"xmlTools.getCurrentXPath\";\n    export const minifyXml = \"xmlTools.minifyXml\";\n}\n\nexport namespace contextKeys {\n    export const xmlTreeViewEnabled = \"xmlTreeViewEnabled\";\n}\n\nexport namespace diagnosticCollections {\n    export const xquery = \"XQueryDiagnostics\";\n}\n\nexport namespace languageIds {\n    export const xml = \"xml\";\n    export const xsd = \"xsd\";\n    export const xquery = \"xquery\";\n}\n\nexport namespace nativeCommands {\n    export const revealLine = \"revealLine\";\n}\n\nexport namespace stateKeys {\n    export const xpathQueryHistory = \"xpathQueryHistory\";\n    export const xPathQueryLast = \"xPathQueryLast\";\n}\n\nexport namespace uriSchemes {\n    export const file = \"file\";\n    export const untitled = \"untitled\";\n}\n\nexport namespace views {\n    export const xmlTreeView = \"xmlTreeView\";\n}\n\nexport namespace xmlFormatterImplementations {\n    export const classic = \"classic\";\n    export const v2 = \"v2\";\n}\n"
  },
  {
    "path": "src/extension.ts",
    "content": "import {\n    commands, languages, window, workspace, ExtensionContext, Memento,\n    TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection\n    } from \"vscode\";\n\nimport { createDocumentSelector, ExtensionState, Configuration } from \"./common\";\nimport { XQueryCompletionItemProvider } from \"./completion\";\nimport { XmlFormatterFactory, XmlFormattingEditProvider } from \"./formatting\";\nimport { formatAsXml, minifyXml, xmlToText, textToXml } from \"./formatting/commands\";\nimport { XQueryLinter } from \"./linting\";\nimport { XmlTreeDataProvider } from \"./tree-view\";\nimport { evaluateXPath, getCurrentXPath } from \"./xpath/commands\";\nimport { executeXQuery } from \"./xquery-execution/commands\";\n\nimport * as constants from \"./constants\";\n\nlet diagnosticCollectionXQuery: DiagnosticCollection;\n\nexport function activate(context: ExtensionContext) {\n    ExtensionState.configure(context);\n\n    const xmlXsdDocSelector = [...createDocumentSelector(constants.languageIds.xml), ...createDocumentSelector(constants.languageIds.xsd)];\n    const xqueryDocSelector = createDocumentSelector(constants.languageIds.xquery);\n\n    /* Completion Features */\n    context.subscriptions.push(\n        languages.registerCompletionItemProvider(xqueryDocSelector, new XQueryCompletionItemProvider(), \":\", \"$\")\n    );\n\n    /* Formatting Features */\n    const xmlFormattingEditProvider = new XmlFormattingEditProvider(XmlFormatterFactory.getXmlFormatter());\n\n    context.subscriptions.push(\n        commands.registerTextEditorCommand(constants.commands.formatAsXml, formatAsXml),\n        commands.registerTextEditorCommand(constants.commands.xmlToText, xmlToText),\n        commands.registerTextEditorCommand(constants.commands.textToXml, textToXml),\n        commands.registerTextEditorCommand(constants.commands.minifyXml, minifyXml),\n        languages.registerDocumentFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider),\n        languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider)\n    );\n\n    /* Linting Features */\n    diagnosticCollectionXQuery = languages.createDiagnosticCollection(constants.diagnosticCollections.xquery);\n    context.subscriptions.push(\n        diagnosticCollectionXQuery,\n        window.onDidChangeActiveTextEditor(_handleChangeActiveTextEditor),\n        window.onDidChangeTextEditorSelection(_handleChangeTextEditorSelection)\n    );\n\n    /* Tree View Features */\n    const treeViewDataProvider = new XmlTreeDataProvider(context);\n    const treeView = window.createTreeView<Node>(constants.views.xmlTreeView, {\n        treeDataProvider: treeViewDataProvider\n    });\n\n    if (Configuration.enableXmlTreeViewCursorSync) {\n        window.onDidChangeTextEditorSelection(x => {\n            if (x.kind === TextEditorSelectionChangeKind.Mouse && x.selections.length > 0) {\n                treeView.reveal(treeViewDataProvider.getNodeAtPosition(x.selections[0].start));\n            }\n        });\n    }\n\n    context.subscriptions.push(\n        treeView\n    );\n\n    /* XPath Features */\n    context.subscriptions.push(\n        commands.registerTextEditorCommand(constants.commands.evaluateXPath, evaluateXPath),\n        commands.registerTextEditorCommand(constants.commands.getCurrentXPath, getCurrentXPath)\n    );\n\n    /* XQuery Features */\n    context.subscriptions.push(\n        commands.registerTextEditorCommand(constants.commands.executeXQuery, executeXQuery)\n    );\n}\n\nexport function deactivate() {\n    // do nothing\n}\n\n\nfunction _handleContextChange(editor: TextEditor): void {\n    const supportedSchemes = [constants.uriSchemes.file, constants.uriSchemes.untitled];\n\n    if (!editor || !editor.document || supportedSchemes.indexOf(editor.document.uri.scheme) === -1) {\n        return;\n    }\n\n    switch (editor.document.languageId) {\n        case constants.languageIds.xquery:\n      diagnosticCollectionXQuery.set(editor.document.uri, new XQueryLinter().lint(editor.document.getText()));\n            break;\n    }\n}\n\nfunction _handleChangeActiveTextEditor(editor: TextEditor): void {\n    _handleContextChange(editor);\n}\n\nfunction _handleChangeTextEditorSelection(e: TextEditorSelectionChangeEvent): void {\n    _handleContextChange(e.textEditor);\n}\n"
  },
  {
    "path": "src/formatting/commands/formatAsXml.ts",
    "content": "import { workspace } from \"vscode\";\nimport { ProviderResult, Range, TextEdit, TextEditor, TextEditorEdit } from \"vscode\";\n\nimport { NativeCommands } from \"../../common\";\nimport * as constants from \"../../constants\";\n\nimport { XmlFormatterFactory } from \"../xml-formatter\";\nimport { XmlFormattingEditProvider } from \"../xml-formatting-edit-provider\";\nimport { XmlFormattingOptionsFactory } from \"../xml-formatting-options\";\n\nexport function formatAsXml(editor: TextEditor, edit: TextEditorEdit): void {\n    const xmlFormattingEditProvider = new XmlFormattingEditProvider(XmlFormatterFactory.getXmlFormatter());\n    const formattingOptions = {\n        insertSpaces: <boolean>editor.options.insertSpaces,\n        tabSize: <number>editor.options.tabSize\n    };\n\n    let edits: ProviderResult<TextEdit[]>;\n\n    if (!editor.selection.isEmpty) {\n        edits = xmlFormattingEditProvider.provideDocumentRangeFormattingEdits(\n            editor.document,\n            new Range(editor.selection.start, editor.selection.end),\n            formattingOptions,\n            null);\n    }\n\n    else {\n        edits = xmlFormattingEditProvider.provideDocumentFormattingEdits(\n            editor.document,\n            formattingOptions,\n            null);\n    }\n\n    for (let i = 0; i < (edits as TextEdit[]).length; i++) {\n        const textEdit = (edits as TextEdit[])[i];\n\n        editor.edit(async (editBuilder) => {\n            editBuilder.replace(textEdit.range, textEdit.newText);\n\n            // wiggle the cursor to deselect the formatted XML (is there a non-hacky way to go about this?)\n            await NativeCommands.cursorMove(\"left\", \"character\");\n            await NativeCommands.cursorMove(\"right\", \"character\");\n        });\n    }\n}\n"
  },
  {
    "path": "src/formatting/commands/index.ts",
    "content": "export * from \"./formatAsXml\";\nexport * from \"./minifyXml\";\nexport * from \"./xmlToText\";\nexport * from \"./textToXml\";\n"
  },
  {
    "path": "src/formatting/commands/minifyXml.ts",
    "content": "import { workspace } from \"vscode\";\nimport { ProviderResult, Range, TextEdit, TextEditor, TextEditorEdit } from \"vscode\";\n\nimport * as constants from \"../../constants\";\n\nimport { XmlFormatterFactory } from \"../xml-formatter\";\nimport { XmlFormattingEditProvider } from \"../xml-formatting-edit-provider\";\nimport { XmlFormattingOptionsFactory } from \"../xml-formatting-options\";\n\nexport function minifyXml(editor: TextEditor, edit: TextEditorEdit): void {\n    const xmlFormatter = XmlFormatterFactory.getXmlFormatter();\n    const xmlFormattingOptions = XmlFormattingOptionsFactory.getXmlFormattingOptions({\n        insertSpaces: <boolean>editor.options.insertSpaces,\n        tabSize: <number>editor.options.tabSize\n    }, editor.document);\n\n    const endPosition = editor.document.lineAt(editor.document.lineCount - 1).rangeIncludingLineBreak.end;\n    const range = new Range(editor.document.positionAt(0), endPosition);\n\n    edit.replace(range, xmlFormatter.minifyXml(editor.document.getText(), xmlFormattingOptions));\n}\n"
  },
  {
    "path": "src/formatting/commands/textToXml.ts",
    "content": "import { workspace } from \"vscode\";\nimport { ProviderResult, Range, TextEdit, TextEditor, Selection } from \"vscode\";\n\nimport { NativeCommands } from \"../../common\";\nimport * as constants from \"../../constants\";\n\nimport { XmlFormatterFactory } from \"../xml-formatter\";\nimport { XmlFormattingEditProvider } from \"../xml-formatting-edit-provider\";\nimport { XmlFormattingOptionsFactory } from \"../xml-formatting-options\";\n\nexport function textToXml(textEditor: TextEditor): void {\n    textEditor.edit(textEdit => {\n        const selections = textEditor.selections;\n        selections.forEach(selection => {\n            if (selection.isEmpty) {\n                selection = new Selection(\n                    textEditor.document.positionAt(0),\n                    textEditor.document.positionAt(textEditor.document.getText().length)\n                );\n            }\n            const txt = textEditor.document.getText(new Range(selection.start, selection.end));\n            const transformed = txt\n                .replace(/&lt;/g, \"<\")\n                .replace(/&gt;/g, \">\")\n                .replace(/&amp;/g, \"&\")\n                // tslint:disable-next-line\n                .replace(/&quot;/g, '\"')\n                .replace(/&apos;/g, \"'\");\n\n            textEdit.replace(selection, transformed);\n        });\n    });\n}\n"
  },
  {
    "path": "src/formatting/commands/xmlToText.ts",
    "content": "import { workspace } from \"vscode\";\nimport { ProviderResult, Range, TextEdit, TextEditor, Selection } from \"vscode\";\n\nimport { NativeCommands } from \"../../common\";\nimport * as constants from \"../../constants\";\n\nimport { XmlFormatterFactory } from \"../xml-formatter\";\nimport { XmlFormattingEditProvider } from \"../xml-formatting-edit-provider\";\nimport { XmlFormattingOptionsFactory } from \"../xml-formatting-options\";\n\nexport function xmlToText(textEditor: TextEditor): void {\n    textEditor.edit(textEdit => {\n        const selections = textEditor.selections;\n        selections.forEach(selection => {\n            if (selection.isEmpty) {\n                selection = new Selection(\n                    textEditor.document.positionAt(0),\n                    textEditor.document.positionAt(textEditor.document.getText().length)\n                );\n            }\n            const txt = textEditor.document.getText(new Range(selection.start, selection.end));\n            const transformed = txt\n                .replace(/</g, \"&lt;\")\n                .replace(/>/g, \"&gt;\")\n                .replace(/&/g, \"&amp;\")\n                .replace(/\"/g, \"&quot;\")\n                .replace(/'/g, \"&apos;\");\n\n            textEdit.replace(selection, transformed);\n        });\n    });\n}\n"
  },
  {
    "path": "src/formatting/formatters/classic-xml-formatter.ts",
    "content": "import { XmlFormatter } from \"../xml-formatter\";\nimport { XmlFormattingOptions } from \"../xml-formatting-options\";\n\nexport class ClassicXmlFormatter implements XmlFormatter {\n\n    formatXml(xml: string, options: XmlFormattingOptions): string {\n        xml = this.minifyXml(xml, options);\n        xml = xml.replace(/</g, \"~::~<\");\n\n        if (options.splitXmlnsOnFormat) {\n            xml = xml\n                .replace(/xmlns\\:/g, \"~::~xmlns:\")\n                .replace(/xmlns\\=/g, \"~::~xmlns=\");\n        }\n\n        const parts: string[] = xml.split(\"~::~\");\n        let inComment = false;\n        let level = 0;\n        let output = \"\";\n\n        for (let i = 0; i < parts.length; i++) {\n            // <!\n            if (parts[i].search(/<!/) > -1) {\n                output += this._getIndent(options, level, parts[i]);\n                inComment = true;\n\n                // end <!\n                if (parts[i].search(/-->/) > -1 || parts[i].search(/\\]>/) > -1 || parts[i].search(/!DOCTYPE/) > -1) {\n                    inComment = false;\n                }\n            } else if (parts[i].search(/-->/) > -1 || parts[i].search(/\\]>/) > -1) {\n                output += parts[i];\n                inComment = false;\n            } else if (/^<(\\w|:)/.test(parts[i - 1]) && /^<\\/(\\w|:)/.test(parts[i])\n                && /^<[\\w:\\-\\.\\,\\/]+/.exec(parts[i - 1])[0] === /^<\\/[\\w:\\-\\.\\,]+/.exec(parts[i])[0].replace(\"/\", \"\")) {\n\n                output += parts[i];\n                if (!inComment) { level--; }\n            } else if (parts[i].search(/<(\\w|:)/) > -1 && parts[i].search(/<\\//) === -1 && parts[i].search(/\\/>/) === -1) {\n                output = (!inComment) ? output += this._getIndent(options, level++, parts[i]) : output += parts[i];\n            } else if (parts[i].search(/<(\\w|:)/) > -1 && parts[i].search(/<\\//) > -1) {\n                output = (!inComment) ? output += this._getIndent(options, level, parts[i]) : output += parts[i];\n            } else if (parts[i].search(/<\\//) > -1) {\n                output = (!inComment) ? output += this._getIndent(options, --level, parts[i]) : output += parts[i];\n            } else if (parts[i].search(/\\/>/) > -1 && (!options.splitXmlnsOnFormat || parts[i].search(/xmlns(:|=)/) === -1)) {\n                output = (!inComment) ? output += this._getIndent(options, level, parts[i]) : output += parts[i];\n            } else if (parts[i].search(/\\/>/) > -1 && parts[i].search(/xmlns(:|=)/) > -1 && options.splitXmlnsOnFormat) {\n                output = (!inComment) ? output += this._getIndent(options, level--, parts[i]) : output += parts[i];\n            } else if (parts[i].search(/<\\?/) > -1) {\n                output += this._getIndent(options, level, parts[i]);\n            } else if (options.splitXmlnsOnFormat && (parts[i].search(/xmlns\\:/) > -1 || parts[i].search(/xmlns\\=/) > -1)) {\n                output += this._getIndent(options, level, parts[i]);\n            } else {\n                output += parts[i];\n            }\n        }\n\n        // remove leading newline\n        if (output[0] === options.newLine) {\n            output = output.slice(1);\n        } else if (output.substring(0, 1) === options.newLine) {\n            output = output.slice(2);\n        }\n\n        return output;\n    }\n\n    minifyXml(xml: string, options: XmlFormattingOptions): string {\n        xml = this._stripLineBreaks(options, xml); // all line breaks outside of CDATA elements and comments\n        xml = (options.removeCommentsOnMinify) ? xml.replace(/\\<![ \\r\\n\\t]*(--([^\\-]|[\\r\\n]|-[^\\-])*--[ \\r\\n\\t]*)\\>/g, \"\") : xml;\n        xml = xml.replace(/>\\s{0,}</g, \"><\"); // insignificant whitespace between tags\n        xml = xml.replace(/\"\\s+(?=[^\\s]+=)/g, \"\\\" \"); // spaces between attributes\n        xml = xml.replace(/\"\\s+(?=>)/g, \"\\\"\"); // spaces between the last attribute and tag close (>)\n        xml = xml.replace(/\"\\s+(?=\\/>)/g, \"\\\" \"); // spaces between the last attribute and tag close (/>)\n        xml = xml.replace(/[^ <>=\"]\\s+[^ <>=\"]+=/g, (match: string) => { // spaces between the node name and the first attribute\n            return match.replace(/\\s+/g, \" \");\n        });\n\n        return xml;\n    }\n\n    private _getIndent(options: XmlFormattingOptions, level: number, trailingValue?: string): string {\n        trailingValue = trailingValue || \"\";\n\n        const indentPattern = (options.editorOptions.preferSpaces) ? \" \".repeat(options.editorOptions.tabSize) : \"\\t\";\n\n        return `${options.newLine}${indentPattern.repeat(level)}${trailingValue}`;\n    }\n\n    /**\n     * Removes line breaks outside of CDATA, comment, and xml:space=\"preserve\" blocks.\n     */\n    private _stripLineBreaks(options: XmlFormattingOptions, xml: string): string {\n        let output = \"\";\n        const inTag = false;\n        const inTagName = false;\n        let inCdataOrComment = false;\n        const inAttribute = false;\n\n        let preserveSpace = false;\n        let level = 0;\n        let levelpreserveSpaceActivated = 0;\n\n        for (let i = 0; i < xml.length; i++) {\n            const char: string = xml.charAt(i);\n            const prev: string = xml.charAt(i - 1);\n            const next: string = xml.charAt(i + 1);\n\n            // CDATA and comments\n            if (char === \"!\" && (xml.substr(i, 8) === \"![CDATA[\" || xml.substr(i, 3) === \"!--\")) {\n                inCdataOrComment = true;\n            }\n\n            else if (char === \"]\" && (xml.substr(i, 3) === \"]]>\")) {\n                inCdataOrComment = false;\n            }\n\n            else if (char === \"-\" && (xml.substr(i, 3) === \"-->\")) {\n                inCdataOrComment = false;\n            }\n\n            // xml:space=\"preserve\"\n            if (char === \">\" && prev !== \"/\") {\n                level++;\n            }\n\n            else if (!inCdataOrComment && char === \"/\" && (prev === \"<\" || next === \">\")) {\n                level--;\n            }\n\n            if (char === \"x\" && (xml.substr(i, 20).toLowerCase() === `xml:space=\"preserve\"`)) {\n                preserveSpace = true;\n                levelpreserveSpaceActivated = level;\n            }\n\n            else if (!inCdataOrComment && preserveSpace && (char === \"/\" && (prev === \"<\" || next === \">\")) && (level === levelpreserveSpaceActivated)) {\n                preserveSpace = false;\n            }\n\n            if (char.search(/[\\r\\n]/g) > -1 && !inCdataOrComment && !preserveSpace) {\n                if (/\\r/.test(char) && /\\S|\\r|\\n/.test(prev) && /\\S|\\r|\\n/.test(xml.charAt(i + options.newLine.length))) {\n                    output += char;\n                }\n\n                else if (/\\n/.test(char) && /\\S|\\r|\\n/.test(xml.charAt(i - options.newLine.length)) && /\\S|\\r|\\n/.test(next)) {\n                    output += char;\n                }\n\n                continue;\n            }\n\n            output += char;\n        }\n\n        return output;\n    }\n}\n"
  },
  {
    "path": "src/formatting/formatters/index.ts",
    "content": "export * from \"./classic-xml-formatter\";\nexport * from \"./v2-xml-formatter\";\n"
  },
  {
    "path": "src/formatting/formatters/v2-xml-formatter.ts",
    "content": "import { XmlFormatter } from \"../xml-formatter\";\nimport { XmlFormattingOptions } from \"../xml-formatting-options\";\nimport { ClassicXmlFormatter } from \"./classic-xml-formatter\";\n\nconst MagicalStringOfWonders = \"~::~MAAAGIC~::~\";\n\n/* tslint:disable no-use-before-declare */\nexport class V2XmlFormatter implements XmlFormatter {\n    formatXml(xml: string, options: XmlFormattingOptions): string {\n        // this replaces all \"<\" brackets inside of comments and CDATA to a magical string\n        // so the following minification steps don't mess with comment and CDATA formatting\n        xml = this._sanitizeCommentsAndCDATA(xml);\n\n        // remove whitespace from between tags, except for line breaks\n        xml = xml.replace(/>\\s{0,}</g, (match: string) => {\n            return match.replace(/[^\\S\\r\\n]/g, \"\");\n        });\n\n        // do some light minification to get rid of insignificant whitespace\n        xml = xml.replace(/\"\\s+(?=[^\\s]+=)/g, \"\\\" \"); // spaces between attributes\n        xml = xml.replace(/\"\\s+(?=>)/g, \"\\\"\"); // spaces between the last attribute and tag close (>)\n        xml = xml.replace(/\"\\s+(?=\\/>)/g, \"\\\" \"); // spaces between the last attribute and tag close (/>)\n        xml = xml.replace(/(?!<!\\[CDATA\\[)[^ <>=\"]\\s+[^ <>=\"]+=(?![^<]*?\\]\\]>)/g, (match: string) => { // spaces between the node name and the first attribute\n            return match.replace(/\\s+/g, \" \");\n        });\n\n        // the coast is clear - we can drop those \"<\" brackets back in\n        xml = this._unsanitizeCommentsAndCDATA(xml);\n\n        let output = \"\";\n\n        let indentLevel = options.initialIndentLevel || 0;\n        let attributeQuote = \"\";\n        let lineBreakSpree = false;\n        let lastWordCharacter: string | undefined;\n        let inMixedContent = false;\n\n        const locationHistory: Location[] = [Location.Text];\n\n        function isLastNonTextLocation(loc: Location): boolean {\n            for (let i = (locationHistory.length - 1); i >= 0; i--) {\n                if (locationHistory[i] !== Location.Text) {\n                    return (loc === locationHistory[i]);\n                }\n            }\n\n            return false;\n        }\n\n        function isLocation(loc: Location): boolean {\n            return loc === locationHistory[locationHistory.length - 1];\n        }\n\n        function refreshMixedContentFlag(): void {\n            inMixedContent = (isLastNonTextLocation(Location.StartTag) || isLastNonTextLocation(Location.EndTag)) && lastWordCharacter !== undefined;\n        }\n\n        function setLocation(loc: Location): void {\n            if (loc === Location.Text) {\n                lastWordCharacter = undefined;\n            }\n\n            locationHistory.push(loc);\n        }\n\n        // NOTE: all \"exiting\" checks should appear after their associated \"entering\" checks\n        for (let i = 0; i < xml.length; i++) {\n            const cc = xml[i];\n            const nc = xml.charAt(i + 1);\n            const nnc = xml.charAt(i + 2);\n            const pc = xml.charAt(i - 1);\n            const ppc = xml.charAt(i - 2);\n\n            // entering CData\n            if (isLocation(Location.Text) && cc === \"<\" && nc === \"!\" && nnc === \"[\") {\n                if (pc === \">\" && ppc !== \"/\") {\n                    output += \"<\";\n                }\n\n                else {\n                    output += `${this._getIndent(options, indentLevel)}<`;\n                }\n\n                setLocation(Location.CData);\n            }\n\n            // exiting CData\n            else if (isLocation(Location.CData) && cc === \"]\" && nc === \"]\" && nnc === \">\") {\n                output += \"]]>\";\n\n                i += 2;\n\n                setLocation(Location.Text);\n            }\n\n            // entering Comment\n            else if (isLocation(Location.Text) && cc === \"<\" && nc === \"!\" && nnc === \"-\") {\n                output += `${this._getIndent(options, indentLevel)}<`;\n\n                setLocation(Location.Comment);\n            }\n\n            // exiting Comment\n            else if (isLocation(Location.Comment) && cc === \"-\" && nc === \"-\" && nnc === \">\") {\n                output += \"-->\";\n\n                i += 2;\n\n                setLocation(Location.Text);\n            }\n\n            // entering SpecialTag\n            else if (isLocation(Location.Text) && cc === \"<\" && (nc === \"!\" || nc === \"?\")) {\n                output += `${this._getIndent(options, indentLevel)}<`;\n\n                setLocation(Location.SpecialTag);\n            }\n\n            // exiting SpecialTag\n            else if (isLocation(Location.SpecialTag) && cc === \">\") {\n                output += `>`;\n\n                setLocation(Location.Text);\n            }\n\n            // entering StartTag.StartTagName\n            else if (isLocation(Location.Text) && cc === \"<\" && [\"/\", \"!\"].indexOf(nc) === -1) {\n                refreshMixedContentFlag();\n\n                // if this occurs after another tag, prepend a line break\n                // but do not add one if the previous tag was self-closing (it already adds its own)\n                if (pc === \">\" && ppc !== \"/\" && !inMixedContent) {\n                    output += `${options.newLine}${this._getIndent(options, indentLevel)}<`;\n                }\n\n                else if (!inMixedContent) {\n                    // removing trailing non-breaking whitespace here prevents endless indentations (issue #193)\n                    output = this._removeTrailingNonBreakingWhitespace(output);\n                    output += `${this._getIndent(options, indentLevel)}<`;\n                }\n\n                else {\n                    output += \"<\";\n\n                    indentLevel--;\n                }\n\n                indentLevel++;\n\n                setLocation(Location.StartTagName);\n            }\n\n            // exiting StartTag.StartTagName, enter StartTag\n            else if (isLocation(Location.StartTagName) && cc === \" \") {\n                output += \" \";\n\n                setLocation(Location.StartTag);\n            }\n\n            // entering StartTag.Attribute\n            else if (isLocation(Location.StartTag) && [\" \", \"/\", \">\"].indexOf(cc) === -1) {\n                if (locationHistory[locationHistory.length - 2] === Location.AttributeValue\n                    && ((options.splitXmlnsOnFormat\n                        && xml.substr(i, 5).toLowerCase() === \"xmlns\")\n                        || options.splitAttributesOnFormat)) {\n\n                    // trim the end of output here to ensure there is no trailing whitespace (issue #288)\n                    output = this._removeTrailingNonBreakingWhitespace(output);\n\n                    output += `${options.newLine}${this._getIndent(options, indentLevel)}`;\n                }\n\n                output += cc;\n\n                setLocation(Location.Attribute);\n            }\n\n            // entering StartTag.Attribute.AttributeValue\n            else if (isLocation(Location.Attribute) && (cc === \"\\\"\" || cc === \"'\")) {\n                output += cc;\n\n                setLocation(Location.AttributeValue);\n\n                attributeQuote = cc;\n            }\n\n            // exiting StartTag.Attribute.AttributeValue, entering StartTag\n            else if (isLocation(Location.AttributeValue) && cc === attributeQuote) {\n                output += cc;\n\n                setLocation(Location.StartTag);\n\n                attributeQuote = undefined;\n            }\n\n            // approaching the end of a self-closing tag where there was no whitespace (issue #149)\n            else if ((isLocation(Location.StartTag) || isLocation(Location.StartTagName))\n                && cc === \"/\"\n                && pc !== \" \"\n                && options.enforcePrettySelfClosingTagOnFormat) {\n                output += \" /\";\n            }\n\n            // exiting StartTag or StartTag.StartTagName, entering Text\n            else if ((isLocation(Location.StartTag) || isLocation(Location.StartTagName)) && cc === \">\") {\n                // if this was a self-closing tag, we need to decrement the indent level and add a newLine\n                if (pc === \"/\") {\n                    indentLevel--;\n                    output += \">\";\n\n                    // only add a newline here if one doesn't already exist (issue #147)\n                    if (nc !== \"\\r\" && nc !== \"\\n\") {\n                        output += options.newLine;\n                    }\n                }\n\n                else {\n                    output += \">\";\n                }\n\n                // don't go directly from StartTagName to Text; go through StartTag first\n                if (isLocation(Location.StartTagName)) {\n                    setLocation(Location.StartTag);\n                }\n\n                setLocation(Location.Text);\n            }\n\n            // entering EndTag\n            else if (isLocation(Location.Text) && cc === \"<\" && nc === \"/\") {\n                if (!inMixedContent) {\n                    indentLevel--;\n                }\n\n                refreshMixedContentFlag();\n\n                // if the end tag immediately follows a line break, just add an indentation\n                // if the end tag immediately follows another end tag or a self-closing tag (issue #185), add a line break and indent\n                // otherwise, this should be treated as a same-line end tag(ex. <element>text</element>)\n                if ((pc === \"\\n\" || lineBreakSpree) && !inMixedContent) {\n                    // removing trailing non-breaking whitespace here prevents endless indentations (issue #193)\n                    output = this._removeTrailingNonBreakingWhitespace(output);\n                    output += `${this._getIndent(options, indentLevel)}<`;\n                    lineBreakSpree = false;\n                }\n\n                else if (isLastNonTextLocation(Location.EndTag) && !inMixedContent) {\n                    output += `${options.newLine}${this._getIndent(options, indentLevel)}<`;\n                }\n\n                else if (pc === \">\" && ppc === \"/\" && !inMixedContent) {\n                    output += `${this._getIndent(options, indentLevel)}<`;\n                }\n\n                else {\n                    output += \"<\";\n                }\n\n                setLocation(Location.EndTag);\n            }\n\n            // exiting EndTag, entering Text\n            else if (isLocation(Location.EndTag) && cc === \">\") {\n                output += \">\";\n\n                setLocation(Location.Text);\n\n                inMixedContent = false;\n            }\n\n            // Text\n            else {\n                if (cc === \"\\n\") {\n                    lineBreakSpree = true;\n                    lastWordCharacter = undefined;\n                }\n\n                else if (lineBreakSpree && /\\S/.test(cc)) {\n                    lineBreakSpree = false;\n                }\n\n                if (/[\\w\\d]/.test(cc)) {\n                    lastWordCharacter = cc;\n                }\n\n                output += cc;\n            }\n        }\n\n        return output;\n    }\n\n    minifyXml(xml: string, options: XmlFormattingOptions): string {\n        return new ClassicXmlFormatter().minifyXml(xml, options);\n    }\n\n    private _getIndent(options: XmlFormattingOptions, indentLevel: number): string {\n        return ((options.editorOptions.insertSpaces) ? \" \".repeat(options.editorOptions.tabSize) : \"\\t\").repeat(Math.max(indentLevel, 0));\n    }\n\n    private _removeTrailingNonBreakingWhitespace(text: string): string {\n        return text.replace(/[^\\r\\n\\S]+$/, \"\");\n    }\n\n    private _sanitizeCommentsAndCDATA(xml: string): string {\n        let output = \"\";\n        let inCommentOrCDATA = false;\n\n        for (let i = 0; i < xml.length; i++) {\n            const cc = xml[i];\n            const nc = xml.charAt(i + 1);\n            const nnc = xml.charAt(i + 2);\n            const pc = xml.charAt(i - 1);\n\n            if (!inCommentOrCDATA && cc === \"<\" && nc === \"!\" && (nnc === \"-\" || nnc === \"[\")) {\n                inCommentOrCDATA = true;\n                output += (nnc === \"-\") ? \"<!--\" : \"<![CDATA[\";\n\n                i += (nnc === \"-\") ? 3 : 8;\n            }\n\n            else if (inCommentOrCDATA && cc === \"<\") {\n                output += MagicalStringOfWonders;\n            }\n\n            else if (inCommentOrCDATA && (cc === \"-\" && nc === \"-\" && nnc === \">\") || (cc === \"]\" && nc === \"]\" && nnc === \">\")) {\n                inCommentOrCDATA = false;\n                output += (cc === \"-\") ? \"-->\" : \"]]>\";\n\n                i += 2;\n            }\n\n            else {\n                output += cc;\n            }\n        }\n\n        return output;\n    }\n\n    private _unsanitizeCommentsAndCDATA(xml: string): string {\n        return xml.replace(new RegExp(MagicalStringOfWonders, \"g\"), \"<\");\n    }\n}\n\nenum Location {\n    Attribute,\n    AttributeValue,\n    CData,\n    Comment,\n    EndTag,\n    SpecialTag,\n    StartTag,\n    StartTagName,\n    Text\n}\n"
  },
  {
    "path": "src/formatting/index.ts",
    "content": "export * from \"./xml-formatter\";\nexport * from \"./xml-formatting-edit-provider\";\nexport * from \"./xml-formatting-options\";\n"
  },
  {
    "path": "src/formatting/xml-formatter.ts",
    "content": "import { window, workspace } from \"vscode\";\n\nimport { Configuration, ExtensionState } from \"../common\";\nimport * as constants from \"../constants\";\nimport { ClassicXmlFormatter } from \"./formatters/classic-xml-formatter\";\nimport { V2XmlFormatter } from \"./formatters/v2-xml-formatter\";\n\nimport { XmlFormattingOptions } from \"./xml-formatting-options\";\n\nexport interface XmlFormatter {\n    formatXml(xml: string, options: XmlFormattingOptions): string;\n    minifyXml(xml: string, options: XmlFormattingOptions): string;\n}\n\nexport class XmlFormatterFactory {\n    private static _xmlFormatter: XmlFormatter;\n\n    static getXmlFormatter(): XmlFormatter {\n        if (XmlFormatterFactory._xmlFormatter) {\n            return XmlFormatterFactory._xmlFormatter;\n        }\n\n        const xmlFormatterImplementationSetting = Configuration.xmlFormatterImplementation;\n        let xmlFormatterImplementation: XmlFormatter;\n\n        switch (xmlFormatterImplementationSetting) {\n            case constants.xmlFormatterImplementations.classic: xmlFormatterImplementation = new ClassicXmlFormatter(); break;\n            case constants.xmlFormatterImplementations.v2:\n            default: xmlFormatterImplementation = new V2XmlFormatter(); break;\n        }\n\n        return (XmlFormatterFactory._xmlFormatter = xmlFormatterImplementation);\n    }\n}\n"
  },
  {
    "path": "src/formatting/xml-formatting-edit-provider.ts",
    "content": "import { workspace } from \"vscode\";\nimport {\n    CancellationToken, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, EndOfLine,\n    FormattingOptions, ProviderResult, Range, TextDocument, TextEdit\n} from \"vscode\";\n\nimport * as constants from \"../constants\";\nimport { XmlFormatter } from \"./xml-formatter\";\nimport { XmlFormattingOptionsFactory } from \"./xml-formatting-options\";\n\nexport class XmlFormattingEditProvider implements DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider {\n\n    constructor(\n        public xmlFormatter: XmlFormatter\n    ) { }\n\n    provideDocumentFormattingEdits(document: TextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]> {\n        const lastLine = document.lineAt(document.lineCount - 1);\n        const documentRange = new Range(document.positionAt(0), lastLine.range.end);\n\n        return this.provideDocumentRangeFormattingEdits(document, documentRange, options, token);\n    }\n\n    provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]> {\n        const allXml = document.getText();\n        let selectedXml = document.getText(range);\n        const extFormattingOptions = XmlFormattingOptionsFactory.getXmlFormattingOptions(options, document);\n\n        const selectionStartOffset = document.offsetAt(range.start);\n        let tabCount = 0;\n        let spaceCount = 0;\n\n        for (let i = (selectionStartOffset - 1); i >= 0; i--) {\n            const cc = allXml.charAt(i);\n\n            if (/\\t/.test(cc)) {\n                tabCount++;\n            }\n\n            else if (/ /.test(cc)) {\n                spaceCount++;\n            }\n\n            else {\n                break;\n            }\n        }\n\n        if (options.insertSpaces) {\n            extFormattingOptions.initialIndentLevel = Math.ceil(spaceCount / (options.tabSize || 1));\n        }\n\n        else {\n            extFormattingOptions.initialIndentLevel = tabCount;\n        }\n\n        selectedXml = this.xmlFormatter.formatXml(selectedXml, extFormattingOptions);\n\n        // we need to remove the leading whitespace because the formatter will add an indent before the first element\n        selectedXml = selectedXml.replace(/^\\s+/, \"\");\n\n        return [TextEdit.replace(range, selectedXml)];\n    }\n}\n"
  },
  {
    "path": "src/formatting/xml-formatting-options.ts",
    "content": "import { EndOfLine, FormattingOptions, TextDocument } from \"vscode\";\n\nimport { Configuration } from \"../common\";\nimport * as constants from \"../constants\";\n\nexport interface XmlFormattingOptions {\n    editorOptions: FormattingOptions;\n    enforcePrettySelfClosingTagOnFormat: boolean;\n    newLine: string;\n    removeCommentsOnMinify: boolean;\n    splitAttributesOnFormat: boolean;\n    splitXmlnsOnFormat: boolean;\n    initialIndentLevel?: number;\n}\n\nexport class XmlFormattingOptionsFactory {\n    static getXmlFormattingOptions(formattingOptions: FormattingOptions, document: TextDocument): XmlFormattingOptions {\n        return {\n            editorOptions: formattingOptions,\n            enforcePrettySelfClosingTagOnFormat: Configuration.enforcePrettySelfClosingTagOnFormat(document.uri),\n            newLine: (document.eol === EndOfLine.CRLF) ? \"\\r\\n\" : \"\\n\",\n            removeCommentsOnMinify: Configuration.removeCommentsOnMinify(document.uri),\n            splitAttributesOnFormat: Configuration.splitAttributesOnFormat(document.uri),\n            splitXmlnsOnFormat: Configuration.splitXmlnsOnFormat(document.uri),\n            initialIndentLevel: 0\n        };\n    }\n}\n"
  },
  {
    "path": "src/linting/index.ts",
    "content": "export * from \"./xquery-linter\";\n"
  },
  {
    "path": "src/linting/xquery-linter.ts",
    "content": "import { Diagnostic, DiagnosticSeverity, Position, Range } from \"vscode\";\n\nconst XQLint = require(\"xqlint\").XQLint;\n\nexport class XQueryLinter {\n    static SEVERITY_WARNING = 1;\n    static SEVERITY_ERROR = 2;\n\n    lint(text: string): Diagnostic[] {\n        const linter = new XQLint(text);\n        const diagnostics = new Array<Diagnostic>();\n\n        linter.getErrors().forEach((error: any) => {\n            diagnostics.push(new Diagnostic(\n                new Range(\n                    new Position(error.pos.sl, error.pos.sc),\n                    new Position(error.pos.el, error.pos.ec)\n                ),\n                error.message,\n                DiagnosticSeverity.Error\n            ));\n        });\n\n        linter.getWarnings().forEach((warning: any) => {\n            diagnostics.push(new Diagnostic(\n                new Range(\n                    new Position(warning.pos.sl, warning.pos.sc),\n                    new Position(warning.pos.el, warning.pos.ec)\n                ),\n                warning.message,\n                DiagnosticSeverity.Warning\n            ));\n        });\n\n        return diagnostics;\n    }\n}\n"
  },
  {
    "path": "src/test/extension.test.ts",
    "content": "import * as assert from \"assert\";\nimport { FormattingOptions } from \"vscode\";\n\nimport { TestDataLoader } from \"./test-utils/test-data-loader\";\n\nimport { XmlFormatter, XmlFormattingOptions } from \"../formatting\";\nimport { V2XmlFormatter } from \"../formatting/formatters\";\n\ndescribe(\"V2XmlFormatter\", () => {\n\n    const xmlFormatter = new V2XmlFormatter();\n\n    describe(\"#formatXml(xml, options)\", () => {\n\n        const options = {\n            editorOptions: {\n                insertSpaces: true,\n                tabSize: 4\n            },\n            enforcePrettySelfClosingTagOnFormat: false,\n            newLine: \"\\r\\n\",\n            removeCommentsOnMinify: false,\n            splitAttributesOnFormat: false,\n            splitXmlnsOnFormat: true\n        };\n\n        it(\"should handle basic XML\", () => {\n            testFormatter(xmlFormatter, options, \"basic\");\n        });\n\n        it(\"should handle unicode element names\", () => {\n            testFormatter(xmlFormatter, options, \"unicode\");\n        });\n\n        it(\"should handle self-closing elements\", () => {\n            testFormatter(xmlFormatter, options, \"self-closing\");\n        });\n\n        it(\"should handle text-only lines\", () => {\n            testFormatter(xmlFormatter, options, \"text-only-line\");\n        });\n\n        it(\"should handle preformatted xml\", () => {\n            testFormatter(xmlFormatter, options, \"preformatted\");\n        });\n\n        it(\"should preserve line breaks between elements\", () => {\n            testFormatter(xmlFormatter, options, \"preserve-breaks\");\n        });\n\n        it(\"should maintain comment formatting\", () => {\n            testFormatter(xmlFormatter, options, \"maintain-comment-formatting\");\n        });\n\n        it(\"should handle single-quotes in attributes\", () => {\n            testFormatter(xmlFormatter, options, \"single-quotes\");\n        });\n\n        it(\"should not add extra line breaks before start tags\", () => {\n            testFormatter(xmlFormatter, options, \"issue-178\");\n        });\n\n        it(\"should allow users to enforce space before self-closing tag slash\", () => {\n            options.enforcePrettySelfClosingTagOnFormat = true;\n\n            testFormatter(xmlFormatter, options, \"issue-149\");\n\n            options.enforcePrettySelfClosingTagOnFormat = false;\n        });\n\n        it(\"should properly format closing tag after self-closing tag\", () => {\n            testFormatter(xmlFormatter, options, \"issue-185\");\n        });\n\n        it(\"should support single quotes within double-quoptes attributes and vice-versa\", () => {\n            testFormatter(xmlFormatter, options, \"issue-187\");\n        });\n\n        it(\"should not ruin attributes with unusual characters\", () => {\n            testFormatter(xmlFormatter, options, \"issue-189\");\n        });\n\n        it(\"should not add extra line breaks before closing tags\", () => {\n            testFormatter(xmlFormatter, options, \"issue-193\");\n        });\n\n        it(\"should not add extra whitespace before CDATA\", () => {\n            testFormatter(xmlFormatter, options, \"issue-194\");\n        });\n\n        it(\"should support mixed content\", () => {\n            testFormatter(xmlFormatter, options, \"issue-200\");\n        });\n\n        it(\"should not remove spaces between the node name and the first attribute within CDATA\", () => {\n            testFormatter(xmlFormatter, options, \"issue-227\");\n        });\n\n        it(\"should handle mixed content as a child of another element\", () => {\n            testFormatter(xmlFormatter, options, \"issue-257\");\n        });\n\n        it(\"should not touch CDATA content\", () => {\n            testFormatter(xmlFormatter, options, \"issue-293\");\n        });\n\n        it(\"should not add trailing whitespace\", () => {\n            testFormatter(xmlFormatter, options, \"issue-288\");\n        });\n    });\n\n    describe(\"#minifyXml(xml, options)\", () => {\n\n        const options = {\n            editorOptions: {\n                insertSpaces: true,\n                tabSize: 4\n            },\n            enforcePrettySelfClosingTagOnFormat: false,\n            newLine: \"\\r\\n\",\n            removeCommentsOnMinify: false,\n            splitAttributesOnFormat: false,\n            splitXmlnsOnFormat: true\n        };\n\n        it(\"should preserve whitespace on minify if xml:space is set to 'preserve-whitespace'\", () => {\n            testMinifier(xmlFormatter, options, \"issue-262\");\n        });\n\n    });\n\n});\n\nfunction testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void {\n    const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\\r/g, \"\");\n    const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`);\n\n    const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\\r/g, \"\");\n\n    // tslint:disable-next-line\n    assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\\n\\nACTUAL\\n${actualFormattedXml.replace(/\\s/g, \"~ws~\")}\\n\\nEXPECTED\\n${expectedFormattedXml.replace(/\\s/g, \"~ws~\")}`);\n}\n\nfunction testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void {\n    const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\\r/g, \"\");\n    const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`);\n\n    const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\\r/g, \"\");\n\n    // tslint:disable-next-line\n    assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\\n\\nACTUAL\\n${actualMinifiedXml.replace(/\\s/g, \"~ws~\")}\\n\\nEXPECTED\\n${expectedMinifiedXml.replace(/\\s/g, \"~ws~\")}`);\n}\n"
  },
  {
    "path": "src/test/test-data/basic.formatted.xml",
    "content": "<root>\n    <element>text</element>\n</root>"
  },
  {
    "path": "src/test/test-data/basic.unformatted.xml",
    "content": "<root><element>text</element></root>"
  },
  {
    "path": "src/test/test-data/issue-149.formatted.xml",
    "content": "<root>\n    <entry>\n        <field1>One</field1>\n        <field2 />\n        <field3>Three</field3>\n        <field4 />\n        <field5>Five</field5>\n    </entry>\n</root>"
  },
  {
    "path": "src/test/test-data/issue-149.unformatted.xml",
    "content": "<root><entry><field1>One</field1><field2/><field3>Three</field3><field4/><field5>Five</field5></entry></root>"
  },
  {
    "path": "src/test/test-data/issue-178.formatted.xml",
    "content": "<root>\n    <entry>\n        <field1>One</field1>\n        <field2/>\n        <field3>Three</field3>\n        <field4/>\n        <field5>Five</field5>\n    </entry>\n</root>"
  },
  {
    "path": "src/test/test-data/issue-178.unformatted.xml",
    "content": "<root><entry><field1>One</field1><field2/><field3>Three</field3><field4/><field5>Five</field5></entry></root>"
  },
  {
    "path": "src/test/test-data/issue-185.formatted.xml",
    "content": "<test>\n    <example>\n        <one/>\n    </example>\n</test>"
  },
  {
    "path": "src/test/test-data/issue-185.unformatted.xml",
    "content": "<test><example><one/></example></test>"
  },
  {
    "path": "src/test/test-data/issue-187.formatted.xml",
    "content": "<Project>\n    <PropertyGroup>\n        <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n        <LangVersion>latest</LangVersion>\n    </PropertyGroup>\n    <PropertyGroup Condition=\" '$(Configuration)'=='Release' \">\n        <DebugSymbols>false</DebugSymbols>\n        <DebugType>None</DebugType>\n        <Optimize>true</Optimize>\n    </PropertyGroup>\n    <ItemGroup Condition=\" '$(Configuration)'=='Release' \">\n        <Content Remove=\"appsettings.Development.json\" />\n    </ItemGroup>\n    <ItemGroup Condition=\" '$(Configuration)'=='Debug' \">\n        <Content Remove=\"appsettings.Production.json\" />\n    </ItemGroup>\n</Project>"
  },
  {
    "path": "src/test/test-data/issue-187.unformatted.xml",
    "content": "<Project>\n    <PropertyGroup>\n        <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n        <LangVersion>latest</LangVersion>\n    </PropertyGroup>\n    <PropertyGroup Condition=\" '$(Configuration)'=='Release' \">\n        <DebugSymbols>false</DebugSymbols>\n        <DebugType>None</DebugType>\n        <Optimize>true</Optimize>\n    </PropertyGroup>\n    <ItemGroup Condition=\" '$(Configuration)'=='Release' \">\n        <Content Remove=\"appsettings.Development.json\" />\n    </ItemGroup>\n    <ItemGroup Condition=\" '$(Configuration)'=='Debug' \">\n        <Content Remove=\"appsettings.Production.json\" />\n    </ItemGroup>\n</Project>"
  },
  {
    "path": "src/test/test-data/issue-189.formatted.xml",
    "content": "<!DOCTYPE xml>\n<core:FragmentDefinition xmlns=\"sap.m\"\n    xmlns:core=\"sap.ui.core\">\n    <Text text=\"{parts: ['i18n>dialog.countdown.text','view>/Countdown'],formatter: 'jQuery.sap.formatMessage'}\" />\n</core:FragmentDefinition>"
  },
  {
    "path": "src/test/test-data/issue-189.unformatted.xml",
    "content": "<!DOCTYPE xml>\n<core:FragmentDefinition xmlns=\"sap.m\"\n    xmlns:core=\"sap.ui.core\">\n    <Text text=\"{parts: ['i18n>dialog.countdown.text','view>/Countdown'],formatter: 'jQuery.sap.formatMessage'}\" />\n</core:FragmentDefinition>"
  },
  {
    "path": "src/test/test-data/issue-193.formatted.xml",
    "content": "<xsl:template name=\"btn-export-excel-pdf\">\n    <div class=\"row\">\n        <div class=\"col-md button-wrapper text-center\">\n            <a class=\"btn btn-outline-info\" role=\"button\" href=\"javascript:template.printToPdf()\" target=\"_blank\">\n                <i class=\"far fa-file-pdf\">&#160;</i> Export to PDF                                        \n            </a>                  &#160;                                                        \n            <a class=\"btn btn-outline-info\" role=\"button\" href=\"javascript:template.exportToExcel()\" target=\"_blank\">\n                <i class=\"far fa-file-excel\">&#160;</i> Export to EXCEL                                        \n            </a>\n        </div>\n    </div>\n</xsl:template>"
  },
  {
    "path": "src/test/test-data/issue-193.unformatted.xml",
    "content": "<xsl:template name=\"btn-export-excel-pdf\">\n    <div class=\"row\">\n      <div class=\"col-md button-wrapper text-center\">\n        <a class=\"btn btn-outline-info\" role=\"button\" href=\"javascript:template.printToPdf()\" target=\"_blank\">\n          <i class=\"far fa-file-pdf\">&#160;</i> Export to PDF                                        \n        </a>                  &#160;                                                        \n        <a class=\"btn btn-outline-info\" role=\"button\" href=\"javascript:template.exportToExcel()\" target=\"_blank\">\n          <i class=\"far fa-file-excel\">&#160;</i> Export to EXCEL                                        \n        </a>\n      </div>\n    </div>\n  </xsl:template>"
  },
  {
    "path": "src/test/test-data/issue-194.formatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<madeup>\n    <some>\n        <element>This is ok</element>\n        <other><![CDATA[Here is my cdata]]></other>\n    </some>\n</madeup>"
  },
  {
    "path": "src/test/test-data/issue-194.unformatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><madeup><some><element>This is ok</element><other><![CDATA[Here is my cdata]]></other></some></madeup>"
  },
  {
    "path": "src/test/test-data/issue-200.formatted.xml",
    "content": "<mixed>beginning text<inner>\n    <a>data</a>\n    <b>another data</b>\n</inner>end text</mixed>"
  },
  {
    "path": "src/test/test-data/issue-200.unformatted.xml",
    "content": "<mixed>beginning text<inner><a>data</a><b>another data</b></inner>end text</mixed>"
  },
  {
    "path": "src/test/test-data/issue-227.formatted.xml",
    "content": "<Job>\n    <SQLQuery test=\"\">\n        <SQLSelect Test=\"test\" test=\"test\">\n            <![CDATA[\nselect\n*\nfrom test\nwhere\naaa.aaa='AAA' and \nisnull(BBB.BBB,0)=0 and\nisnull(CCTestC.CCC,0)=1 and\nDDD.DDD is null and\nexists (select 1 from EEE where EEE.EEE=EEE.EEE and EEE is null) and\nexists (select 1 from FFF where FFF.FFF=FFF.FFF) and\n'{GGG}' like '%'+GGG.GGG+'%'\n]]>\n        </SQLSelect>\n    </SQLQuery>\n</Job>"
  },
  {
    "path": "src/test/test-data/issue-227.unformatted.xml",
    "content": "<Job>\n  <SQLQuery      test=\"\">\n    <SQLSelect    Test=\"test\"     test=\"test\">\n             <![CDATA[\nselect\n*\nfrom test\nwhere\naaa.aaa='AAA' and \nisnull(BBB.BBB,0)=0 and\nisnull(CCTestC.CCC,0)=1 and\nDDD.DDD is null and\nexists (select 1 from EEE where EEE.EEE=EEE.EEE and EEE is null) and\nexists (select 1 from FFF where FFF.FFF=FFF.FFF) and\n'{GGG}' like '%'+GGG.GGG+'%'\n]]>\n    </SQLSelect>\n\t</SQLQuery>\n</Job>"
  },
  {
    "path": "src/test/test-data/issue-257.formatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"2.0\"\n    xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n    <xsl:output method=\"xml\" encoding=\"UTF-8\" indent=\"yes\" />\n\n    <xsl:template match=\"/\">\n        <file>\n            <xsl:apply-templates />\n        </file>\n    </xsl:template>\n\n    <xsl:template match=\"*\">\n        <xsl:message terminate=\"no\">\n            WARNING: Unmatched element: <xsl:value-of select=\"name()\"/>\n        </xsl:message>\n        <xsl:apply-templates/>\n    </xsl:template>\n\n</xsl:stylesheet>"
  },
  {
    "path": "src/test/test-data/issue-257.unformatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"2.0\" \n    xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n    <xsl:output method=\"xml\" encoding=\"UTF-8\" indent=\"yes\" />\n\n    <xsl:template match=\"/\">\n        <file>\n            <xsl:apply-templates />\n        </file>\n    </xsl:template>\n\n    <xsl:template match=\"*\">\n        <xsl:message terminate=\"no\">\n            WARNING: Unmatched element: <xsl:value-of select=\"name()\"/>\n        </xsl:message>\n        <xsl:apply-templates/>\n    </xsl:template>\n\n</xsl:stylesheet>"
  },
  {
    "path": "src/test/test-data/issue-262.minified.xml",
    "content": "<tests><test>1.\n2.\n3.\n4.</test><test xml:space=\"preserve\">1.\n2.\n3.\n4.</test><test>1. 2. 3. 4.</test><test xml:space=\"preserve\">1.\n 2.\n 3.\n 4.</test></tests>"
  },
  {
    "path": "src/test/test-data/issue-262.unminified.xml",
    "content": "<tests>\n<test>1.\n2.\n3.\n4.</test>\n<test xml:space=\"preserve\">1.\n2.\n3.\n4.</test>\n<test>1.\n 2.\n 3.\n 4.</test>\n<test xml:space=\"preserve\">1.\n 2.\n 3.\n 4.</test>\n</tests>"
  },
  {
    "path": "src/test/test-data/issue-288.formatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n    xmlns=\"http://purl.org/rss/1.0/\"\n    xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n    xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\"\n    xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n    xmlns:syn=\"http://purl.org/rss/1.0/modules/syndication/\"\n    xmlns:admin=\"http://webns.net/mvcb/\">\n\n</rdf:RDF>"
  },
  {
    "path": "src/test/test-data/issue-288.unformatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n    xmlns=\"http://purl.org/rss/1.0/\"\n    xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n    xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\"\n    xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n    xmlns:syn=\"http://purl.org/rss/1.0/modules/syndication/\"\n    xmlns:admin=\"http://webns.net/mvcb/\">\n\n</rdf:RDF>"
  },
  {
    "path": "src/test/test-data/issue-293.formatted.xml",
    "content": "<xml>\n    <element><![CDATA[asdf]]></element>\n    <element><![CDATA[<secondXml>\n    <formattedNode>val</formattedNode>\n</secondXml>]]></element>\n</xml>"
  },
  {
    "path": "src/test/test-data/issue-293.unformatted.xml",
    "content": "<xml>\n    <element><![CDATA[asdf]]></element>\n    <element><![CDATA[<secondXml>\n    <formattedNode>val</formattedNode>\n</secondXml>]]></element>\n</xml>"
  },
  {
    "path": "src/test/test-data/maintain-comment-formatting.formatted.xml",
    "content": "<root>\n    <element>text</element>\n    <!--\n        <Description>\n            Any description.\n        </Description>\n        <Keyword UUID=\"fd8e6b13-9865-4d8c-9ecd-5ff08a0cf2e2\"/>\n        <Parameters>\n            <Parameter Name=\"ParameterName1\">The Parameter Name.</Parameter>\n            <Parameter Name=\"ParameterName2\" PossibleValues=\"Val1,Val2\" DefaultValue=\"Val1\"/>\n        </Parameters>\n    -->\n</root>"
  },
  {
    "path": "src/test/test-data/maintain-comment-formatting.unformatted.xml",
    "content": "<root>\n    <element>text</element>\n    <!--\n        <Description>\n            Any description.\n        </Description>\n        <Keyword UUID=\"fd8e6b13-9865-4d8c-9ecd-5ff08a0cf2e2\"/>\n        <Parameters>\n            <Parameter Name=\"ParameterName1\">The Parameter Name.</Parameter>\n            <Parameter Name=\"ParameterName2\" PossibleValues=\"Val1,Val2\" DefaultValue=\"Val1\"/>\n        </Parameters>\n    -->\n</root>"
  },
  {
    "path": "src/test/test-data/preformatted.formatted.xml",
    "content": "<root>\n    <element>text</element>\n    <element>text</element>\n    <element>text</element>\n    <element>text</element>\n    <element>\n        <element2>text</element2>\n    </element2>\n</root>"
  },
  {
    "path": "src/test/test-data/preformatted.unformatted.xml",
    "content": "<root>\n    <element>text</element>\n    <element>text</element>\n    <element>text</element>\n    <element>text</element>\n    <element>\n        <element2>text</element2>\n    </element2>\n</root>"
  },
  {
    "path": "src/test/test-data/preserve-breaks.formatted.xml",
    "content": "<root>\n    <element>text</element>\n    <element>text</element>\n\n    <element>text</element>\n    <element>text</element>\n\n    <element>\n        <element2>text</element2>\n    </element2>\n\n</root>"
  },
  {
    "path": "src/test/test-data/preserve-breaks.unformatted.xml",
    "content": "<root>\n    <element>text</element>\n    <element>text</element>\n\n    <element>text</element>\n    <element>text</element>\n\n    <element>\n        <element2>text</element2>\n    </element2>\n\n</root>"
  },
  {
    "path": "src/test/test-data/self-closing.formatted.xml",
    "content": "<Node>\n    <Node name=\"testChild\"/>\n</Node>"
  },
  {
    "path": "src/test/test-data/self-closing.unformatted.xml",
    "content": "<Node><Node name=\"testChild\"/></Node>"
  },
  {
    "path": "src/test/test-data/single-quotes.formatted.xml",
    "content": "<root>\n    <element attr='1' />\n    <element attr='2' />\n</root>"
  },
  {
    "path": "src/test/test-data/single-quotes.unformatted.xml",
    "content": "<root>\n    <element attr='1' />\n    <element attr='2' />\n</root>"
  },
  {
    "path": "src/test/test-data/text-only-line.formatted.xml",
    "content": "<Tag>\n    <Tag2>\nText1\nText2\n    </Tag2>\n</Tag>"
  },
  {
    "path": "src/test/test-data/text-only-line.unformatted.xml",
    "content": "<Tag>\n<Tag2>\nText1\nText2\n</Tag2>\n</Tag>"
  },
  {
    "path": "src/test/test-data/unicode.formatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Имя>\n    <element>text</element>\n</Имя>"
  },
  {
    "path": "src/test/test-data/unicode.unformatted.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Имя><element>text</element></Имя>"
  },
  {
    "path": "src/test/test-utils/test-data-loader.ts",
    "content": "import * as fs from \"fs\";\n\nexport class TestDataLoader {\n    static load(fileName: string): string {\n        return fs.readFileSync(`${__dirname}/../../../src/test/test-data/${fileName}`, \"UTF-8\");\n    }\n}\n"
  },
  {
    "path": "src/tree-view/index.ts",
    "content": "export * from \"./xml-tree-data-provider\";\n"
  },
  {
    "path": "src/tree-view/xml-tree-data-provider.ts",
    "content": "import { window, workspace } from \"vscode\";\nimport {\n    Event, EventEmitter, ExtensionContext, Position, TextEditor, TreeDataProvider,\n    TreeItem, TreeItemCollapsibleState\n} from \"vscode\";\n\nimport * as path from \"path\";\nimport { DOMParser } from \"xmldom\";\n\nimport { Configuration, NativeCommands, XmlTraverser } from \"../common\";\nimport * as constants from \"../constants\";\n\nexport class XmlTreeDataProvider implements TreeDataProvider<any> {\n    private _onDidChangeTreeData: EventEmitter<any> = new EventEmitter<any>();\n    private _xmlDocument: Document;\n    private _xmlTraverser: XmlTraverser;\n\n    constructor(private _context: ExtensionContext) {\n        window.onDidChangeActiveTextEditor(() => {\n            this._refreshTree();\n        });\n\n        workspace.onDidChangeTextDocument(() => {\n            this._refreshTree();\n        });\n\n        this._refreshTree();\n    }\n\n    onDidChangeTreeData = this._onDidChangeTreeData.event;\n\n    get activeEditor(): TextEditor {\n        return window.activeTextEditor || null;\n    }\n\n    getTreeItem(element: Node): TreeItem | Thenable<TreeItem> {\n        const enableMetadata = Configuration.enableXmlTreeViewMetadata;\n        const enableSync = Configuration.enableXmlTreeViewCursorSync;\n\n        const treeItem = new TreeItem(element.localName);\n\n        if (!this._xmlTraverser.isElement(element)) {\n            treeItem.label = `${element.localName} = \"${element.nodeValue}\"`;\n        }\n\n        else if (enableMetadata) {\n            const childAttributes = this._xmlTraverser.getChildAttributeArray(<Element>element);\n            const childElements = this._xmlTraverser.getChildElementArray(<Element>element);\n            const totalChildren = (childAttributes.length + childElements.length);\n\n            if (totalChildren > 0) {\n                treeItem.label += \"  (\";\n\n                if (childAttributes.length > 0) {\n                    treeItem.label += `attributes: ${childAttributes.length}, `;\n                    treeItem.collapsibleState = TreeItemCollapsibleState.Collapsed;\n                }\n\n                if (childElements.length > 0) {\n                    treeItem.label += `children: ${childElements.length}, `;\n                    treeItem.collapsibleState = TreeItemCollapsibleState.Collapsed;\n                }\n\n                treeItem.label = treeItem.label.substr(0, treeItem.label.length - 2);\n                treeItem.label += \")\";\n            }\n\n            if (this._xmlTraverser.hasSimilarSiblings(<Element>element) && enableSync) {\n                treeItem.label += ` [line ${(element as any).lineNumber}]`;\n            }\n        }\n\n        treeItem.command = {\n            command: constants.nativeCommands.revealLine,\n            title: \"\",\n            arguments: [{\n                lineNumber: (element as any).lineNumber - 1,\n                at: \"top\"\n            }]\n        };\n\n        treeItem.iconPath = this._getIcon(element);\n\n        return treeItem;\n    }\n\n    getChildren(element?: Node): Node[] | Thenable<Node[]> {\n        if (!this._xmlDocument) {\n            this._refreshTree();\n        }\n\n        if (this._xmlTraverser.isElement(element)) {\n            return [].concat(this._xmlTraverser.getChildAttributeArray(<Element>element), this._xmlTraverser.getChildElementArray(<Element>element));\n        }\n\n        else if (this._xmlDocument) {\n            return [this._xmlDocument.lastChild];\n        }\n\n        else {\n            return [];\n        }\n    }\n\n    getParent(element: Node): Node {\n        if ((!element || !element.parentNode || !element.parentNode.parentNode) && !(element as any).ownerElement) {\n            return undefined;\n        }\n\n        return element.parentNode || (element as any).ownerElement;\n    }\n\n    getNodeAtPosition(position: Position): Node {\n        return this._xmlTraverser.getNodeAtPosition(position);\n    }\n\n    private _getIcon(element: Node): any {\n        let type = \"element\";\n\n        if (!this._xmlTraverser.isElement(element)) {\n            type = \"attribute\";\n        }\n\n        const icon = {\n            dark: this._context.asAbsolutePath(path.join(\"resources\", \"icons\", `${type}.dark.svg`)),\n            light: this._context.asAbsolutePath(path.join(\"resources\", \"icons\", `${type}.light.svg`))\n        };\n\n        return icon;\n    }\n\n    private _refreshTree(): void {\n        if (!this.activeEditor || this.activeEditor.document.languageId !== constants.languageIds.xml) {\n            NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, false);\n\n            this._xmlDocument = null;\n            this._onDidChangeTreeData.fire();\n            return;\n        }\n\n        const enableTreeView = Configuration.enableXmlTreeView;\n\n        NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, enableTreeView);\n\n        const xml = this.activeEditor.document.getText();\n\n        try {\n            this._xmlDocument = new DOMParser({\n                errorHandler: () => {\n                    throw new Error(\"Invalid Document\");\n                },\n                locator: {}\n            }).parseFromString(xml, \"text/xml\");\n        }\n\n        catch {\n            this._xmlDocument = new DOMParser().parseFromString(\"<InvalidDocument />\", \"text/xml\");\n        }\n\n        finally {\n            this._xmlTraverser = this._xmlTraverser || new XmlTraverser(this._xmlDocument);\n            this._xmlTraverser.xmlDocument = this._xmlDocument;\n        }\n\n        this._onDidChangeTreeData.fire();\n    }\n\n}\n"
  },
  {
    "path": "src/xpath/commands/evaluateXPath.ts",
    "content": "import { window } from \"vscode\";\nimport { TextEditor, TextEditorEdit, ViewColumn } from \"vscode\";\n\nimport { Configuration, ExtensionState } from \"../../common\";\nimport * as constants from \"../../constants\";\n\nimport { EvaluatorResult, EvaluatorResultType, XPathEvaluator } from \"../xpath-evaluator\";\n\nclass HistoricQuery {\n    constructor(uri: string, query: string) {\n        this.uri = uri;\n        this.query = query;\n    }\n\n    uri: string;\n    query: string;\n}\n\nexport async function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): Promise<void> {\n    // if there is no workspace, we will track queries in the global Memento\n    const memento = ExtensionState.workspace || ExtensionState.global;\n\n    // get the xpath persistence setting\n    const persistQueries = Configuration.persistXPathQuery;\n\n    // get the last query if there is one for this document\n    // if not, try pulling the last query ran, regardless of document\n    // NOTE: if the user has focus on the output channel when opening the xquery prompt, the channel is the \"active\" document\n    const history = memento.get<HistoricQuery[]>(constants.stateKeys.xpathQueryHistory, new Array<HistoricQuery>());\n    const globalLastQuery = memento.get<string>(constants.stateKeys.xPathQueryLast, \"\");\n\n    const lastQuery = history.find(x => {\n        return (x.uri === editor.document.uri.toString());\n    });\n\n    // set the inital display value and prompt the user\n    let query = (lastQuery) ? lastQuery.query : globalLastQuery;\n\n    query = await window.showInputBox({\n        placeHolder: \"XPath Query\",\n        prompt: \"Please enter an XPath query to evaluate.\",\n        value: query\n    });\n\n    // showInputBox() will return undefined if the user dimissed the prompt\n    if (!query) {\n        return;\n    }\n\n    const ignoreDefaultNamespace = Configuration.ignoreDefaultNamespace;\n\n    // run the query\n    const xml = editor.document.getText();\n    let evalResult: EvaluatorResult;\n\n    try {\n        evalResult = XPathEvaluator.evaluate(query, xml, ignoreDefaultNamespace);\n    }\n\n    catch (error) {\n        console.error(error);\n        window.showErrorMessage(`Something went wrong while evaluating the XPath: ${error}`);\n        return;\n    }\n\n    // show the results to the user\n    const outputChannel = window.createOutputChannel(\"XPath Results\");\n\n    outputChannel.clear();\n\n    outputChannel.appendLine(`XPath Query: ${query}`);\n    outputChannel.append(\"\\n\");\n\n    if (evalResult.type === EvaluatorResultType.NODE_COLLECTION) {\n        (evalResult.result as Node[]).forEach((node: any) => {\n            outputChannel.appendLine(`[Line ${node.lineNumber}] ${node.localName}: ${node.textContent}`);\n        });\n    }\n\n    else {\n        outputChannel.appendLine(`[Result]: ${evalResult.result}`);\n    }\n\n    outputChannel.show(false);\n\n    if (persistQueries) {\n        const historicQuery = new HistoricQuery(editor.document.uri.toString(), query);\n\n        const affectedIndex = history.findIndex(x => x.uri === historicQuery.uri);\n\n        if (affectedIndex === -1) {\n            history.push(historicQuery);\n        }\n\n        else {\n            history[affectedIndex].query = query;\n        }\n\n        memento.update(constants.stateKeys.xpathQueryHistory, history);\n        memento.update(constants.stateKeys.xPathQueryLast, query);\n    }\n}\n"
  },
  {
    "path": "src/xpath/commands/getCurrentXPath.ts",
    "content": "import { window } from \"vscode\";\nimport { TextEditor, TextEditorEdit } from \"vscode\";\nimport { DOMParser } from \"xmldom\";\n\nimport { XPathBuilder } from \"../xpath-builder\";\n\nexport function getCurrentXPath(editor: TextEditor, edit: TextEditorEdit): void {\n    if (!editor.selection) {\n        window.showInformationMessage(\"Please put your cursor in an element or attribute name.\");\n\n        return;\n    }\n\n    const document = new DOMParser().parseFromString(editor.document.getText());\n    const xpath = new XPathBuilder(document).build(editor.selection.start);\n\n    window.showInputBox({\n        value: xpath,\n        valueSelection: undefined\n    });\n}\n"
  },
  {
    "path": "src/xpath/commands/index.ts",
    "content": "export * from \"./evaluateXPath\";\nexport * from \"./getCurrentXPath\";\n"
  },
  {
    "path": "src/xpath/index.ts",
    "content": "export * from \"./xpath-builder\";\nexport * from \"./xpath-evaluator\";\n"
  },
  {
    "path": "src/xpath/xpath-builder.ts",
    "content": "import { Position } from \"vscode\";\nimport { DOMParser } from \"xmldom\";\n\nimport { XmlTraverser } from \"../common\";\n\nexport class XPathBuilder {\n\n    private _xmlTraverser: XmlTraverser;\n\n    constructor(private _xmlDocument: Document) {\n        this._xmlTraverser = new XmlTraverser(this._xmlDocument);\n    }\n\n    build(position: Position): string {\n        const selectedNode = this._xmlTraverser.getNodeAtPosition(position);\n\n        return this._buildCore(selectedNode);\n    }\n\n    private _buildCore(selectedNode: Node): string {\n        if (selectedNode === this._xmlDocument.documentElement) {\n            return `/${selectedNode.nodeName}`;\n        }\n\n        if (!this._xmlTraverser.isElement(selectedNode)) {\n            return `${this._buildCore((selectedNode as any).ownerElement)}/@${selectedNode.nodeName}`;\n        }\n\n        else if (this._xmlTraverser.hasSimilarSiblings(selectedNode)) {\n            const siblings = this._xmlTraverser.getSiblings(selectedNode);\n            const xPathIndex = (siblings.indexOf(selectedNode) + 1);\n\n            return `${this._buildCore(selectedNode.parentNode)}/${selectedNode.nodeName}[${xPathIndex}]`;\n        }\n\n        else {\n            return `${this._buildCore(selectedNode.parentNode)}/${selectedNode.nodeName}`;\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/xpath/xpath-evaluator.ts",
    "content": "import * as xpath from \"xpath\";\nimport { SelectedValue, XPathSelect } from \"xpath\";\nimport { DOMParser } from \"xmldom\";\n\nexport class EvaluatorResult {\n    type: EvaluatorResultType;\n    result: Node[] | number | string | boolean;\n}\n\nexport class EvaluatorResultType {\n    static SCALAR_TYPE = 0;\n    static NODE_COLLECTION = 1;\n}\n\nexport class XPathResultTypes {\n    static ANY_TYPE = 0;\n    static NUMBER_TYPE = 1;\n    static STRING_TYPE = 2;\n    static BOOLEAN_TYPE = 3;\n    static UNORDERED_NODE_ITERATOR_TYPE = 4;\n    static ORDERED_NODE_ITERATOR_TYPE = 5;\n    static UNORDERED_NODE_SNAPSHOT_TYPE = 6;\n    static ORDERED_NODE_SNAPSHOT_TYPE = 7;\n    static ANY_UNORDERED_NODE_TYPE = 8;\n    static FIRST_ORDERED_NODE_TYPE = 9;\n}\n\nexport class XPathEvaluator {\n    static evaluate(query: string, xml: string, ignoreDefaultNamespace: boolean): EvaluatorResult {\n        if (ignoreDefaultNamespace) {\n            xml = xml.replace(/xmlns=\".+\"/g, (match: string) => {\n                return match.replace(/xmlns/g, \"xmlns:default\");\n            });\n        }\n\n        const nodes = new Array<Node>();\n        const xdoc: Document = new DOMParser().parseFromString(xml, \"text/xml\");\n        const resolver = (xpath as any).createNSResolver(xdoc);\n        const xPathResult = xpath.evaluate(query, xdoc, resolver, 0, null);\n\n        const evaluatorResult = new EvaluatorResult();\n        evaluatorResult.type = EvaluatorResultType.SCALAR_TYPE;\n\n        switch (xPathResult.resultType) {\n            case XPathResultTypes.NUMBER_TYPE:\n                evaluatorResult.result = xPathResult.numberValue;\n                break;\n            case XPathResultTypes.STRING_TYPE:\n                evaluatorResult.result = xPathResult.stringValue;\n                break;\n            case XPathResultTypes.BOOLEAN_TYPE:\n                evaluatorResult.result = xPathResult.booleanValue;\n                break;\n            case XPathResultTypes.UNORDERED_NODE_ITERATOR_TYPE:\n            case XPathResultTypes.ORDERED_NODE_ITERATOR_TYPE:\n                evaluatorResult.result = xPathResult.booleanValue;\n\n                let node: Node;\n\n                while (node = xPathResult.iterateNext()) {\n                    nodes.push(node);\n                }\n\n                evaluatorResult.result = nodes;\n                evaluatorResult.type = EvaluatorResultType.NODE_COLLECTION;\n                break;\n        }\n\n\n        return evaluatorResult;\n    }\n}\n"
  },
  {
    "path": "src/xquery-execution/child-process.ts",
    "content": "const child_process = require(\"child_process\");\n\nexport class ChildProcess {\n    static async spawn(executable: string, args: string[]): Promise<void> {\n        return new Promise<void>((resolve, reject) => {\n\n            let output = \"\";\n            const handle = child_process.spawn(executable, args);\n\n            handle.stdout.on(\"data\", (data: string) => {\n                output += data;\n            });\n\n            handle.stderr.on(\"data\", (data: string) => {\n                output += data;\n            });\n\n            handle.on(\"close\", (code: string) => {\n                if (code === \"0\") {\n                    resolve();\n                }\n\n                else {\n                    reject({ code: code, message: output });\n                }\n            });\n\n        });\n    }\n}\n"
  },
  {
    "path": "src/xquery-execution/commands/executeXQuery.ts",
    "content": "import { window, workspace } from \"vscode\";\nimport { Disposable, Range, TextEditor, TextEditorEdit, Uri } from \"vscode\";\n\nimport * as constants from \"../../constants\";\n\nimport { ChildProcess } from \"../child-process\";\nimport { Configuration, NativeCommands } from \"../../common\";\n\nexport async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): Promise<void> {\n    // this disposable will be used for creating status bar messages\n    let disposable: Disposable;\n\n    if (editor.document.languageId !== constants.languageIds.xquery) {\n        window.showErrorMessage(\"This action can only be performed on an XQuery file.\");\n        return;\n    }\n\n    const executable = Configuration.xqueryExecutionEngine;\n    let args = Configuration.xqueryExecutionArguments || [];\n\n    if (!executable || executable === \"\") {\n        const action = await window.showWarningMessage(\"An XQuery execution engine has not been defined.\", \"Define Now\");\n\n        if (action === \"Define Now\") {\n            NativeCommands.openGlobalSettings();\n        }\n\n        return;\n    }\n\n    let inputFile: Uri;\n    disposable = window.setStatusBarMessage(\"Searching for XML files in folder...\");\n\n    const searchPattern = Configuration.xqueryExecutionInputSearchPattern;\n    const inputLimit = Configuration.xqueryExecutionInputLimit;\n\n    const files = await workspace.findFiles(searchPattern, \"\", inputLimit);\n\n    disposable.dispose();\n\n    // user does not have a folder open - prompt for file name\n    if (typeof files === \"undefined\") {\n        window.showErrorMessage(\"You must have a folder opened in VS Code to use this feature.\");\n        return;\n    }\n\n    // if there is only one XML file, default it\n    // otherwise, prompt the user to select one from the open folder\n    if (files.length > 1) {\n        const qpItems = new Array<any>();\n\n        files.forEach((file) => {\n            const filename = file.fsPath.replace(\"\\\\\", \"/\");\n\n            qpItems.push({ // must implement vscode.QuickPickItem\n                label: filename.substring(filename.lastIndexOf(\"/\") + 1),\n                description: file.fsPath,\n                file: file\n            });\n        });\n\n        const selection = await window.showQuickPick(qpItems, { placeHolder: \"Please select an input file.\" });\n\n        if (!selection) {\n            return;\n        }\n\n        inputFile = selection.file;\n    }\n\n    else {\n        inputFile = files[0];\n    }\n\n    // prompt for output file name\n    let outputPath: string = null;\n    let outputPathPos = -1;\n\n    for (let i = 0; i < args.length; i++) {\n        if (i > 0) {\n            if (args[i].search(/out|result/) !== -1) {\n                outputPath = args[i];\n                outputPathPos = i;\n            }\n        }\n    }\n\n    if (outputPath) {\n        outputPath = await window.showInputBox({\n            placeHolder: \"ex. C:\\\\TEMP\\XQueryOutput\\\\MyOutputFile.xml\",\n            prompt: \"Please specify the output file path. Existing file behavior is determined by the execution engine you have specified.\",\n            value: outputPath\n        });\n\n        args[outputPathPos] = outputPath;\n    }\n\n    // call out to the execution engine\n    disposable = window.setStatusBarMessage(\"Executing XQuery Script...\");\n    args = args.map<string>((value: string) => {\n        return value\n            .replace(\"$(script)\", editor.document.uri.fsPath)\n            .replace(\"$(input)\", inputFile.fsPath)\n            .replace(\"$(project)\", (workspace.workspaceFolders) ? workspace.workspaceFolders[0].uri.fsPath : \"\");\n    });\n\n    try {\n        await ChildProcess.spawn(executable, args);\n    }\n\n    catch (error) {\n        if (error.message.search(/[Ll]ine:?\\s*\\d+/gm) > -1) {\n            const match: RegExpExecArray = /[Ll]ine:?\\s*\\d+/gm.exec(error.message);\n            const line: number = (Number.parseInt(match[0].replace(/([Ll]ine:?\\s*)|\\s/, \"\")) - 1);\n\n            const selection: string = await window.showErrorMessage(error.message, `Go to Line ${line}`);\n\n            if (selection === `Go to Line ${line}`) {\n                editor.revealRange(new Range(line, 0, line, 0));\n            }\n        }\n\n        else {\n            window.showErrorMessage(error.message);\n        }\n    }\n\n    finally {\n        disposable.dispose();\n    }\n}\n"
  },
  {
    "path": "src/xquery-execution/commands/index.ts",
    "content": "export * from \"./executeXQuery\";\n"
  },
  {
    "path": "src/xquery-execution/index.ts",
    "content": "export * from \"./child-process\";\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"module\": \"commonjs\",\n        \"target\": \"es6\",\n        \"outDir\": \"out\",\n        \"lib\": [\n            \"dom\",\n            \"es6\"\n        ],\n        \"sourceMap\": true,\n        \"rootDir\": \"src\",\n        \"strict\": true,\n        \"strictNullChecks\": false\n    },\n    \"exclude\": [\n        \"node_modules\",\n        \".vscode-test\"\n    ]\n}"
  },
  {
    "path": "tslint.json",
    "content": "{\n    \"rules\": {\n        \"arrow-return-shorthand\": true,\n        \"callable-types\": true,\n        \"class-name\": true,\n        \"comment-format\": [\n            true,\n            \"check-space\"\n        ],\n        \"curly\": true,\n        \"deprecation\": {\n            \"severity\": \"warn\"\n        },\n        \"eofline\": true,\n        \"forin\": true,\n        \"import-blacklist\": [\n            true,\n            \"rxjs\",\n            \"rxjs/Rx\"\n        ],\n        \"import-spacing\": true,\n        \"indent\": [\n            true,\n            \"spaces\",\n            4\n        ],\n        \"interface-over-type-literal\": true,\n        \"label-position\": true,\n        \"max-line-length\": [\n            true,\n            165\n        ],\n        \"member-access\": false,\n        \"member-ordering\": [\n            true,\n            {\n                \"order\": [\n                    \"static-field\",\n                    \"instance-field\",\n                    \"static-method\",\n                    \"instance-method\"\n                ]\n            }\n        ],\n        \"no-arg\": true,\n        \"no-bitwise\": true,\n        \"no-console\": [\n            true,\n            \"debug\",\n            \"info\",\n            \"time\",\n            \"timeEnd\",\n            \"trace\"\n        ],\n        \"no-construct\": true,\n        \"no-debugger\": true,\n        \"no-duplicate-super\": true,\n        \"no-empty\": false,\n        \"no-empty-interface\": true,\n        \"no-eval\": true,\n        \"no-inferrable-types\": [\n            true,\n            \"ignore-params\"\n        ],\n        \"no-misused-new\": true,\n        \"no-non-null-assertion\": true,\n        \"no-shadowed-variable\": true,\n        \"no-string-literal\": false,\n        \"no-string-throw\": true,\n        \"no-switch-case-fall-through\": true,\n        \"no-trailing-whitespace\": true,\n        \"no-unnecessary-initializer\": true,\n        \"no-unused-expression\": true,\n        \"no-use-before-declare\": true,\n        \"no-var-keyword\": true,\n        \"object-literal-sort-keys\": false,\n        \"one-line\": [\n            true,\n            \"check-open-brace\",\n            \"check-whitespace\"\n        ],\n        \"prefer-const\": true,\n        \"quotemark\": [\n            true,\n            \"double\"\n        ],\n        \"radix\": true,\n        \"semicolon\": [\n            true,\n            \"always\"\n        ],\n        \"triple-equals\": [\n            true,\n            \"allow-null-check\"\n        ],\n        \"typedef-whitespace\": [\n            true,\n            {\n                \"call-signature\": \"nospace\",\n                \"index-signature\": \"nospace\",\n                \"parameter\": \"nospace\",\n                \"property-declaration\": \"nospace\",\n                \"variable-declaration\": \"nospace\"\n            }\n        ],\n        \"unified-signatures\": true,\n        \"variable-name\": false,\n        \"whitespace\": [\n            true,\n            \"check-branch\",\n            \"check-decl\",\n            \"check-operator\",\n            \"check-separator\",\n            \"check-type\"\n        ]\n    }\n}"
  }
]