How do I provide XML Schema information to the XML Editor?

I would like to understand how I can associate an XML Schema (XSD file) with a particular XML document that I want to edit in IntelliJ in order to inform the editor how to provide XML element editing support.

0
6 comments

If you have xmlns declaration in your document, invoke "Manually Setup
External Resource" quick fix on it.  It will be registered at Project
Settings -> Resources.

0

and if you have xml without namespace you need to declare xsi namespace and xsi:noNamespaceSchemaLocation pointing to actual schema location

0
Avatar
Permanently deleted user

Thank you.

In the following XML file the element name "module" is underlined in red in IntelliJ and the fly-over help says "attribute "noNamespaceSchemaLocation" from namespace "http://www.w3.org/2001/XMLSchema-instance" not allowed at this point; ignored"

The editor is supporting the RelaxNG schema, so I am getting the benefit of the linkage. However, the red underline error report is troubling and I'd like to resolve it.

Thoughts?

Thank you -- Randy


<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../standard-module-2.0-schema-1.0.rng"
        version="2.0" >
  <meta>
    <identity>
      <uri>urn:org:netkernel:pf:static</uri>
      <version>1.0.0</version>
    </identity>
    <info>
      <name>NK Portal Framework / Static</name>
      <description>NKPF / Static Resources</description>
    </info>
  </meta>
  <system>
    <dynamic/>
  </system>
  <rootspace>
    <fileset>
      <regex>res:/etc/system/SimpleDynamicImportHook.xml</regex>
    </fileset>
    <mapper>
      <config>res:/resources/resourcesMapperConfig.xml</config>
      <space>
        <fileset>
          <regex>res:/resources/.*</regex>
        </fileset>
        <import>
          <uri>urn:org:netkernel:xml:core</uri>
        </import>
      </space>
    </mapper>
    <!--Import and Share the NK Look and Feel-->
    <import>
      <uri>urn:org:netkernel:nkse:style</uri>
    </import>
  </rootspace>
</module>

0

first this trick is not correct in the relax ng world. As i  know, relaxNG has no support for schemaLocation tip. Although something is works in idea for you, but this is not correct. Generally speaking, schemaLocation attribute is just a tip, optional for validation. To validate you need to match a concrete schema with concrete file. I know idea has a an item "Validate" in the right-click  menu. If you have no way to select desired schema there and can't register a concrete file(say using schema file path instead of uri) like Dmitry wrote, this a serious lack of xml functionality.
Feel free to fire a new issue for this, i'll vote for it once created.

As a workaround consider to switch to xsd (you can generate schema from your xml) or declare a namespace and register resource as Dmitry wrote.

0
Avatar
Permanently deleted user

On 21.01.2011 03:57, Randy Kahle wrote:

The editor is supporting the RelaxNG schema, no I am getting the benefit of the linkage. However, the red underline error report is troubling and I'd like to resolve it.


The xsi:* attributes are used by the XML Schema world and unless your RelaxNG schema explicitly
allows it, it is not considered valid.

The proper way to associate a RelaxNG schema with a document without namespace is to open the XML
document and then click on the inspection manager icon (the guy with the hat) in IDEA's status bar
and enter the schema location in the "RelaxNG Schema Association" field.

HTH,
Sascha

0
Avatar
Permanently deleted user

Dimtry,

I have tried all sorts of combinations to get reliable schema-based XML editor support and I have come back to using XSD. I'm actually authoring the schemas in RelaxNG and then converting them to XSD. Fine so far.

I used your suggestion and did the fix-up and the editor now associates the file with the XSD document.

I have one remaining problems. When I do this the root element is marked in red and therefore the whole XML document is consider invalid. This does not occur when I use the direct binding to the physical XSD file location.

I would much prefer to use a logical reference for the XSD and map it through the resources.

Do you have any suggestions about how I can get rid of the red marker associated with the root element

Thank you!

Randy

0

Please sign in to leave a comment.