Lev
Lev

Reputation: 3924

XSD Schema for XML Element which has a value and an Attribute

How could be XSD for this element?

<Message isEnabled="true">Message body</Message>

I have searched in Google but there are only examples where Message is a complex type, not element with type.

Or this is wrong format for XML at all?

Upvotes: 1

Views: 68

Answers (1)

devuxer
devuxer

Reputation: 42354

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="Message">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="isEnabled" type="xs:boolean" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>

</xs:schema>

Upvotes: 3

Related Questions