Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xml-schema xsd error: with namespace

I'm trying to define my first xml-schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    targetNamespace="http://www.example.net/test"
    xmlns:t="http://www.example.net/test">

    <xs:annotation>
        <xs:documentation>This schema describes the xml format that is used in for ILTIS stuff.</xs:documentation>
    </xs:annotation>
    <xs:complexType name="station">
        <xs:sequence>
            <xs:element name="transition" type="transition" minOccurs="1" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="transition">
        <xs:sequence>
            <xs:element name="wActions" type="wActions" maxOccurs="1" minOccurs="1"/>
            <xs:element name="oActions" type="oAction" maxOccurs="1" minOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="from" type="xs:string" use="required"/>
        <xs:attribute name="to" type="xs:string" use="required"/>
    </xs:complexType>

    <xs:complexType name="wActions">
        <xs:sequence>
            <xs:element name="wMessage" type="wMessage" maxOccurs="2" minOccurs="1"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="oActions">
        <xs:sequence>
            <xs:element name="trainRunMessage" type="trainRunMessage" maxOccurs="2" minOccurs="1"/>
            <xs:element name="wMessage" type="wMessage" maxOccurs="2" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="trainRunMessage">
            <xs:attribute name="track" type="xs:string" use="required"/>
            <xs:attribute name="offset" type="xs:string" default="0"/>
            <xs:attribute name="station" type="xs:string" use="required"/>   
    </xs:complexType>


    <xs:complexType name="wMessage">
        <xs:attribute name="track" type="xs:string" use="required"/>
    </xs:complexType> 
</xs:schema>

But my oxygen-editor always throw out this error-message:

src-resolve.4.1: Error resolving component 'transition'. It was detected that 'transition' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/C:/Users/mbohlaender/Desktop/rules-example-schema2.xsd'. If 'transition' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'transition' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/C:/Users/mbohlaender/Desktop/rules-example-schema2.xsd'.

I still have no conclusion what I did wrong. Please answer in easy way.

like image 783
user1323512 Avatar asked Feb 19 '23 20:02

user1323512


1 Answers

In the definition of your <transition> element, you are referencing a type transition, which is what Oxygen doesn't recognize. It doesn't exist. You have only defined a complex type named transition in your schema, so that type ends up in the target namespace http://www.example.net/test, which you have imported with the t prefix.

Try writing

<xs:element name="transition" type="t:transition" minOccurs="1" />
like image 116
O. R. Mapper Avatar answered Mar 03 '23 01:03

O. R. Mapper