Validate xml through xsd. Implict schema declaration.

Hi all.
I'v managed to register xsd schema(through StandartResourceProvider) and it works pretty for xml files, where I declared xlmns="SOME_URL" attribute.

Can I somehow attach this scheme to all xml files, based on their extension? Yes, I already have custom FileType for this files.

Can I get validation results? If there some error in xml, how can I knew about it while processing file?

Thanks in advance!

3 comments

Hi, to provide the schema you need to implement XmlSchemaProvider extension point.
Currently there is no open API for getting highlighting results directly, you may look at some code at DaemonCodeAnalyzerImpl.runPasses().

0

Thank's for answer, Dmitry!

Sorry. But I'm think, my poor English makes a confusion here. I'm looking some way to set default namespace to all xml files with given extension. And still can't understand how.

Schema is already provided and I can see it in autocomplete popup and in action, when editing document with manually specified xmlns attribute.

Did I misunderstand something?

0

Hello,

Namespace alone cannot provide validation and autocomplete. You must be missing the Schema Instance and its schemaLocation attribute.

<Resource xmlns="http://xml.metamug.net/resource/1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://xml.metamug.net/resource/1.0 http://xml.metamug.net/schema/resource.xsd">
</Resource>

Reference:

https://metamug.com/article/auto-complete-xml-editor-with-xsd-and-validations.php

0

Please sign in to leave a comment.