I have the following XML files:

main file

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<template_structure xmlns:xi="http://www.w3.org/2001/XInclude"    
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    xsi:noNamespaceSchemaLocation="template_structure_validator.xsd">
    <xi:include href="parameter_definitions.xml" parse="xml"/>
    <parameters>
        <parameter idref="first_param" value="10"/>
    </parameters>
</template_structure>

parameter_definitions.xml

<parameter_definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xsi:noNamespaceSchemaLocation="template_structure_validator.xsd">
    <def_parameter id="first_param" advanced="true">
        <description>
            first parameter
        </description>
    </def_parameter>
    <def_parameter id="second_param" advanced="true">
        <description>
            second parameter
        </description>
    </def_parameter>
</parameter_definitions>

template_structure_validator.xsd:

<xs:element name="parameter_definitions">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="def_parameter" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="def_parameter">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="description"/>
        </xs:sequence>
        <xs:attribute name="id" use="required" type="xs:ID"/>
        <xs:attribute name="advanced" use="required" type="xs:boolean"/>
    </xs:complexType>
</xs:element>
<xs:element name="parameters">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="parameter">
    <xs:complexType>
        <xs:attribute name="idref" use="required" type="xs:IDREF"/>
                    <xs:attribute name="value" use="required" type="xs:string"/>
    </xs:complexType>
</xs:element>
<xs:element name="js_template_structure">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="parameter_definitions"/>
            <xs:element ref="parameters"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

When I load them with Webstorm I get an error "first_param" is unresolved in the main file. How can I fix it?

1

There are 1 answers

2
Paul Sweatte On

IDREF requires that the value specified for the attribute is also specified elsewhere in the document as an ID-attribute value. An IDREF value must appear elsewhere as an ID value:

 <xs:attribute name="id" type="xs:ID" use="required"/>
 <!--...-->
 <xs:attribute name="idref" use="required" type="xs:IDREF"/>