Validate both element and attribute with XSD

I have this XML snippet that I need to validate:


  Volvo

I want to validate both the attribute ‘model’ content and the element content ‘Volvo’. Here is one way of doing it (thank you Alex):


:

  <xs:complexType>
    <xs:simpleContent>
      
        <xs:attribute name="model" type="xsd:string"/>
      
    </xs:simpleContent>
  </xs:complexType>

:

The base attribute will validate the element content ‘Volvo’ and the attribute type will validate the ‘model’

Comments are closed.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.