Question

I add an xsd to eclipse catalog manually (Window > Preferences > XML > XML Catalog > add)

or via WST using catalogContribution

this is the XSD :

    <xs:include schemaLocation="xmlCommon.xsd" />
    <xs:include schemaLocation="xmlStateProvider.xsd" />
    <xs:element name="tmfxml">
        <xs:complexType>
            <xs:choice maxOccurs="unbounded">
                <xs:element maxOccurs="unbounded" minOccurs="0" name="stateProvider" type="stateProvider" />
            </xs:choice>
        </xs:complexType>
    </xs:element>

</xs:schema>

The xml generated from this XSD is this :

<?xml version="1.0" encoding="UTF-8"?>
<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xmlDefinition">
</tmfxml>

when i try to validate the XML showed below, it gives me this warning :

No grammar constraints (DTD or XML Schema) referenced in the document

form there anything I put in the XML file that respect the XML standard get validated with no error except for the warning cited below (meaning its like it is not associated with an XSD)

when I change the path specified in xsi:noNamespaceSchemaLocation to an absolute like this :

<?xml version="1.0" encoding="UTF-8"?>
<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/home/l3727/workspace/linuxtools2/lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlDefinition.xsd">
</tmfxml>

it works perfectly. There is no more warning and when I try to put a random XML tag and then try to validate the XML file it give me some errors.

Is there a way to automatically generate an XML without this warning so it can be validated correctly ?

Was it helpful?

Solution

I have solved this problem by adding urn or url in the beginning of the key/name.

Using WST I added this contribution to eclipse catalog:

 <extension 
        point="org.eclipse.wst.xml.core.catalogContributions">
      <catalogContribution id="default">
        <uri 
            name="urn:xmlDefinition.xsdl" 
            uri="../org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/xmlDefinition.xsd"/>
      </catalogContribution>
   </extension>

Or manually (Window > Preferences > XML > XML Catalog > add) when eclipse ask you to enter the key

enter image description here

I don't know exactly why it works. But I'm gonna try to find out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top