2016-11-06 6 views
1

すでに定義されている要素の属性を宣言したいと思います。私はこれを持っている要素personは2つの属性(nameid)を持つことができることを希望:xsd:attribute宣言はどこでグローバルxsd:complexTypeに入りますか?

<xs:element name="person" type="perso" /> 

<xs:complexType name="perso"> 
<!-- I tried to declare the attribute here.Not working--> 
     <xs:sequence> 
      <!-- I tried to declare the attribute here.Not working--> 
      <xs:element name="description" type="xs:string" /> 
     </xs:sequence> 
</xs:complexType> 

私はグローバル、ローカルではない、複雑な型を宣言するために探しています。私は混合コンテンツに興味がありません。

エラーメッセージ私は取得しています:

要素属性:スキーマパーサーエラー:要素「{} http://www.w3.org/2001/XMLSchemaシーケンス」:内容は有効ではありません。期待されるのは(注釈?、(要素|グループ|選択|シーケンス|任意)*)です。

答えて

0

属性宣言はxs:sequence後に行く:

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="person" type="perso" /> 
    <xs:complexType name="perso"> 
    <xs:sequence> 
     <xs:element name="description" type="xs:string" /> 
    </xs:sequence> 
    <xs:attribute name="name" type="xs:string"/> 
    <xs:attribute name="id" type="xs:string"/> 
    </xs:complexType> 
</xs:schema> 
+0

それは働きます!どうもありがとうございました – rockability