如何在XML模式中声明仅包含属性的元素?

Mir*_*rko 8 xml schema xsd

鉴于:

<authentication password="turkey" partnerid="exam" />
Run Code Online (Sandbox Code Playgroud)

如何在XML模式中声明此元素?

我有:

<xs:element name="authentication" type="auth_type" />

<xs:complexType name ="auth_type">
  <xs:simpleContent>
    <xs:extension base="xs:string">
      <xs:attribute name="password" type="xs:string" />
      <xs:attribute name="partnerid" type="xs:string" />
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)

但它会让元素有文字内容,是吗?我不要那个...

Dan*_*ley 16

你可以删除xs:simpleContentxs:extension....

  <xs:element name="authentication" type="auth_type" />

  <xs:complexType name ="auth_type">
    <xs:attribute name="password" type="xs:string" />
    <xs:attribute name="partnerid" type="xs:string" />
  </xs:complexType>
Run Code Online (Sandbox Code Playgroud)