Define and use attributeGroup : attributeGroup « XML Schema « XML






Define and use attributeGroup


File: Data.xml

<?xml version="1.0"?>
<employees
  xmlns="http://www.java2s.com/employees"
  xmlns:name="http://www.java2s.com/name"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.java2s.com/employees Schema.xsd"
  source="from where"
  version="1.0"/>


File: Schema.xsd

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:employees="http://www.java2s.com/employees"
  targetNamespace="http://www.java2s.com/employees"
  elementFormDefault="qualified">


  <attributeGroup name="employeeAttributes">
    <attribute name="version" type="decimal" fixed="1.0" />
    <attribute name="source" type="string"/>
  </attributeGroup>

  <element name="employees">
    <complexType>
      <attributeGroup ref="employees:employeeAttributes"/>
    </complexType>
  </element>

</schema>

 








Related examples in the same category

1.Reference an attribute group