Skip to content

Commit

Permalink
Merge pull request pleonex#18 from ivanatpr/master
Browse files Browse the repository at this point in the history
Add support for xsi:schemaLocation
  • Loading branch information
pleonex committed May 10, 2016
2 parents 951043b + f5015e9 commit 319fa18
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ utils = require './xml-utils'

xmlValidation = /xmlns:xsi="http:\/\/www.w3.org\/2001\/XMLSchema-instance"/
xsdPattern = /xsi:noNamespaceSchemaLocation="(.+)"/
xsdWithNamespacePattern = /xsi:schemaLocation="\S+\s+(.+)"/

module.exports =
# Enable for XML but not for XML comments.
Expand Down Expand Up @@ -55,7 +56,13 @@ module.exports =
getXsdUri: ({editor}) ->
# Get the XSD url only if the XML ask for validation.
txt = editor.getText()
if txt.match(xmlValidation) then uri = txt.match(xsdPattern)?[1] else null
if txt.match(xmlValidation)
xsdMatch = txt.match(xsdPattern)
if xsdMatch then uri = xsdMatch?[1]
else
xsdWithNamespaceMatch = txt.match(xsdWithNamespacePattern)
if xsdWithNamespaceMatch then uri = xsdWithNamespaceMatch?[1]
else null


## Filter the candidate completions by prefix.
Expand Down

0 comments on commit 319fa18

Please sign in to comment.