私はXMLとXSDを使い始めています。私は単純なxsdというファイルをという名前でnarrative.xsdとし、別のものをというgoal.xsdと呼びます。これには物語が含まれています。私は名前空間を省略した場合XSDカスタムネームスペース
the http://mdmw.co.uk:Timescale is not declared.
、それが働いている:
問題は、私はこのエラーを取得するTimescale
タイプのgoal.xsdでいることです。
名前空間を使用するにはどうすればよいですか?
ありがとうございます。
これはnarrative.xsdある:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="narrative"
elementFormDefault="qualified"
targetNamespace="http://mdmw.co.uk"
xmlns="http://mdmw.co.uk"
xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="Timescale">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1 Month" />
<xs:enumeration value="2 Months" />
<xs:enumeration value="3 Months" />
<xs:enumeration value="6 Months" />
<xs:enumeration value="9 Months" />
<xs:enumeration value="1 Year" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
これはgoal.xsdある:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="goal"
elementFormDefault="qualified"
targetNamespace="http://mdmw.co.uk"
xmlns="http://mdmw.co.uk"
xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:include schemaLocation="narrative.xsd"/>
<xs:element name="goals">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="goalType" type="xs:string" />
<xs:element name="timeScale" type="Timescale" />
<xs:element name="currentResult" type="xs:decimal"/>
<xs:element name="currentResultDate" type="xs:date"/>
<xs:element name="comments" type="xs:string"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XMLが良好に見えます。次のメニューからVSで確認しました:プロジェクト:新規アイテムの追加:Xmlファイル次に、xmlをビューに貼り付けます。エラーは他のコンパイラエラーと同様にエラーリストに表示されます。 – jdweng