0

I am trying to make XSD for categories but it always give me this warning error warning : namespace '' is not available to be referenced in this schema Error: 'Category' was not reported I tried to make recursive categories with not specified level of hierarchy

and this is my XSD structure

<xs:schema xmlns:tns="http://www.tempuri.org" targetNamespace="http://www.tempuri.org" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Categories">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="Category" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Category">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="name" type="xs:string" />
        <xs:element name="code" type="xs:string" />
        <xs:element name="parent" nillable="true" type="xs:string" />
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="Category" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

The needed xml is like

<?xml version="1.0" encoding="utf-8"?>
<Categorıes>
<Category>
<Code>1</Code>
<Name>Kategori1</Name>
<Parent>0</Parent>
<Category>
<Code>11</Code>
<Name>Kategori11</Name>
<Parent>1</Parent>
<Category>
<Code>111</Code>
<Name>Kategori111</Name>
<Parent>11</Parent>
</Category>
</Category>
</Category>
<Category>
<Code>2</Code>
<Name>Kategori2</Name>
<Parent>0</Parent>
<Category>
<Code>21</Code>
<Name>Kategori21</Name>
<Parent>2</Parent>
<Category>
<Code>211</Code>
<Name>Kategori211</Name>
<Parent>21</Parent>
</Category>
<Category>
<Code>212</Code>
<Name>Kategori212</Name>
<Parent>21</Parent>
</Category>
</Category>
</Category>
</Categorıes>

Please help me

1 Answer 1

0

The Category element is in namespace http://www.tempuri.org so you need to reference it as

<xs:element minOccurs="0" maxOccurs="unbounded" ref="t:Category"
            xmlns:t="http://www.tempuri.org"/>

Of course the namespace declaration can appear on any ancestor element; it's usual to put it on xs:schema itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.