Il seguente esempio è collegato all’articolo Linguaggio XML.

Viene qui presentato un documento XML contenente un curriculum in formato XML. Viene inoltre fornito un XML Schema collegato a tale documento.

<?xml version="1.0" encoding="UTF-8"?>

<curriculum>

  <anagrafica>
    <nome>Mario</nome>
    <cognome>Rossi</cognome>
    <sesso>M</sesso>
 
    <dati_nascita>
      <luogo>Roma</luogo>
      <data>25/11/1993</data>
    </dati_nascita>
    
    <dati_residenza>
      <citta>Segrate</citta>
      <provincia>Milano</provincia>
    </dati_residenza>
  </anagrafica>
  
  <titoli_di_studio>
    <titolo_studio tipo="Diploma di Liceo Scientifico" stato="conseguito" anno_inizio="2007" anno_fine="2012" presso="Liceo Scientifico Isacco Newton" luogo="Roma"/>
    <titolo_studio tipo="Laurea in Informatica" stato="in_corso" anno_inizio="2012" presso="Università degli studi di Milano" luogo="Milano"/>
  </titoli_di_studio>
	
  <lingue>
    <lingua nome="italiano" livello="madrelingua"/>
    <lingua nome="inglese" livello="B2"/>
    <lingua nome="francese" livello="DELF B1"/>
  </lingue>
    
  <esperienze tipo="non_lavorative">
    <esperienza stato="conclusa">
      <anno_inizio>2012</anno_inizio>
      <anno_fine>2013</anno_fine>
      <descrizione>Programma università per i giovani</descrizione>
    </esperienza>
  </esperienze>
  
  <esperienze tipo="lavorative">
    <esperienza stato="conclusa">
      <anno_inizio>2015</anno_inizio>
      <ruolo tipo="Programmatore"/>
      <contratto tipo="lavoratore a progetto"/>
      <azienda nome="Il mondo dei chip"/>
      <descrizione>Progettazione di un sistema di e-commerce per un negozio specializzato in elettronica</descrizione>   
    </esperienza>

    <esperienza stato="conclusa">
      <anno_inizio>2015</anno_inizio>
      <ruolo tipo="Programmatore e responsabile progetto"/>
      <contratto tipo="lavoratore a tempo indeterminato"/>
      <azienda nome="WorkShop"/>
      <descrizione>Progettista di software cloud e assistenza sui prodotti sviluppati</descrizione>   
    </esperienza>
  </esperienze>
	
  <skills>
    <skill titolo="Programmazione PHP" livello="medio"/>
    <skill titolo="Programmazione C" livello="medio"/>
    <skill titolo="Programmazione Java" livello="medio"/>
    <skill titolo="Gestione Team" livello="base"/>
    <skill titolo="Formazione Team" livello="medio"/>
  </skills>
  
</curriculum>

XML Schema:

<?xml version="1.0" encoding="UTF-8"?>

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

  <xs:simpleType name="stringType">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>
  
  <xs:simpleType name="dateType">
    <xs:restriction base="xs:string">
      <xs:pattern value="([0-9]){2}/([0-9]){2}/([0-9]){4}"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="yearType">
    <xs:restriction base="xs:positiveInteger">
      <xs:pattern value="([0-9]){4}"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="sexType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="M"/>
      <xs:enumeration value="F"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="stateStudyType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="in_corso"/>
      <xs:enumeration value="conseguito"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="typeExperiencesType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="non_lavorative"/>
      <xs:enumeration value="lavorative"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="stateExperiencesType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="conclusa"/>
      <xs:enumeration value="in_corso"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="levelType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="base"/>
      <xs:enumeration value="medio"/>
      <xs:enumeration value="avanzato"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:complexType name="bornType">
    <xs:sequence>
      <xs:element name="luogo" type="stringType"/>
      <xs:element name="data" type="dateType"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="addressType">
    <xs:sequence>
      <xs:element name="citta" type="stringType"/>
      <xs:element name="provincia" type="stringType"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="IdentifyngType">
    <xs:sequence>
      <xs:element name="nome" type="stringType"/>
      <xs:element name="cognome" type="stringType"/>
      <xs:element name="sesso" type="sexType"/>
      <xs:element name="dati_nascita" type="bornType"/>
      <xs:element name="dati_residenza" type="addressType"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="studyType">
    <xs:attribute name="tipo" type="stringType" use="required"/>
    <xs:attribute name="stato" type="stateStudyType" use="required"/>
    <xs:attribute name="anno_inizio" type="yearType" use="required"/>
    <xs:attribute name="anno_fine" type="yearType"/>
    <xs:attribute name="presso" type="stringType" use="required"/>
    <xs:attribute name="luogo" type="stringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="studiesType">
    <xs:sequence>
      <xs:element name="titolo_studio" type="studyType" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="languageType">
    <xs:attribute name="nome" type="stringType" use="required"/>
    <xs:attribute name="livello" type="stringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="languagesType">
    <xs:sequence>
      <xs:element name="lingua" type="languageType" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="attTypeTextType">
    <xs:attribute name="tipo" type="stringType" use="required"/>
  </xs:complexType>
  
  <xs:complexType name="attnameTextType">
    <xs:attribute name="nome" type="stringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="experienceType">
    <xs:sequence>
      <xs:element name="anno_inizio" type="stringType"/>
      <xs:element name="anno_fine" type="stringType" minOccurs="0"/>
      <xs:element name="ruolo" type="attTypeTextType" minOccurs="0"/>
      <xs:element name="contratto" type="attTypeTextType" minOccurs="0"/>
      <xs:element name="azienda" type="attnameTextType" minOccurs="0"/>
      <xs:element name="descrizione" type="stringType"/>
    </xs:sequence>
    <xs:attribute name="stato" type="stateExperiencesType" use="required"/>
  </xs:complexType>

  <xs:complexType name="experiencesType">
    <xs:sequence>
      <xs:element name="esperienza" type="experienceType" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="tipo" type="typeExperiencesType" use="required"/>
  </xs:complexType>

  <xs:complexType name="skillType">
    <xs:attribute name="titolo" type="stringType" use="required"/>
    <xs:attribute name="livello" type="levelType" use="required"/>
  </xs:complexType>

  <xs:complexType name="skillsType">
    <xs:sequence>
      <xs:element name="skill" type="skillType" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="curriculumType">
    <xs:sequence>
      <xs:element name="anagrafica" type="IdentifyngType"/>
      <xs:element name="titoli_di_studio" type="studiesType"/>
      <xs:element name="lingue" type="languagesType">
        <xs:unique name="linguaUnique">
          <xs:selector xpath="lingua"/>
          <xs:field xpath="@nome"/>
        </xs:unique>
      </xs:element>
      <xs:element name="esperienze" type="experiencesType" maxOccurs="2"/>
      <xs:element name="skills" type="skillsType">
        <xs:unique name="skillUnique">
          <xs:selector xpath="skill"/>
          <xs:field xpath="@titolo"/>
        </xs:unique>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  
  <xs:element name="curriculum" type="curriculumType"/>
  
</xs:schema>