<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.cienciavitae.pt/ns/narrative-cv" xmlns:narrative-cv="http://www.cienciavitae.pt/ns/narrative-cv"
    xmlns:common="http://www.cienciavitae.pt/ns/common" xmlns:common-enum="http://www.cienciavitae.pt/ns/common-enum" xmlns:identifying-info="http://www.cienciavitae.pt/ns/identifying-info" xmlns:career-profile="http://www.cienciavitae.pt/ns/career-profile"
    xmlns:contribution="http://www.cienciavitae.pt/ns/contribution">

    <xs:annotation>
        <xs:documentation>...</xs:documentation>
    </xs:annotation>

    <xs:import namespace="http://www.cienciavitae.pt/ns/common" schemaLocation="../common/common.xsd"/>
    <xs:import namespace="http://www.cienciavitae.pt/ns/common-enum" schemaLocation="../common/common-enum.xsd"/>
    <xs:import namespace="http://www.cienciavitae.pt/ns/identifying-info" schemaLocation="../cv/identifying-info.xsd"/>
    <xs:import namespace="http://www.cienciavitae.pt/ns/career-profile" schemaLocation="career-profile.xsd"/>
    <xs:import namespace="http://www.cienciavitae.pt/ns/contribution" schemaLocation="contribution.xsd"/>
    
    <xs:element name="narrative-versions">
        <xs:annotation>
            <xs:documentation>Container for the list of narrative versions from user.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
        	<xs:complexContent>
                <xs:extension base="common:container-ctype">
                 	 <xs:sequence>
						<xs:element ref="narrative-cv:narrative-cv-summary" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:extension>
            </xs:complexContent>
         </xs:complexType>
    </xs:element>
    
    <xs:element name="narrative-cv-summary">
        <xs:annotation>
            <xs:documentation>Container for the list of narrative versions from user.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
	        	<xs:complexContent>
	                <xs:extension base="common:record-ctype">
	                 	<xs:sequence>
		                    	<xs:element name="name" type="common:string-50-stype" minOccurs="0"/>
		                    	<xs:element name="narrative-template" type="narrative-cv:narrative-type-ctype" minOccurs="0"/>
	                    </xs:sequence>
			            <xs:attribute name="preferred" type="xs:boolean"/>
			            <xs:attribute name="total" type="xs:int"/>
	                </xs:extension>
	            </xs:complexContent>
         </xs:complexType>
    </xs:element>

    <xs:element name="narrative-cv">
         <xs:annotation>
            <xs:documentation>Narrative curriculum</xs:documentation>
			<xs:documentation>
			    Accepted narrative template at the moment: GLOBAL.
			    For GLOBAL template, expected structure is:
			    - exactly 1 career-profile
			    - exactly 1 career-profile-item
			    - exactly 1 contributions
			    - exactly 5 contribution
			    These cardinality constraints are enforced in Schematron.
			</xs:documentation>
        </xs:annotation>
        <xs:complexType>
        <xs:complexContent>
        	<xs:extension base="common:record-ctype">
            <xs:sequence>
            	<xs:element name="name" type="common:string-50-stype" minOccurs="0"/>
                <xs:element name="narrative-template" type="narrative-cv:narrative-type-ctype" minOccurs="0"/>
                <xs:element ref="identifying-info:identifying-info" minOccurs="0"/>
                <xs:element xmlns:career-profile="http://www.cienciavitae.pt/ns/career-profile" ref="career-profile:career-profile"/>
                <xs:element xmlns:contribution="http://www.cienciavitae.pt/ns/contribution" ref="contribution:contributions"/>
            </xs:sequence>
            <xs:attribute name="preferred" type="xs:boolean"/>
            <xs:attribute name="language" type="xs:string"/>
            </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:element>
    
    <xs:complexType name="narrative-type-ctype">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="code" type="common-enum:narrative-type-enum" use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    
</xs:schema>
