##############################################################
# #
# contraintes pour les molécules #
# #
##############################################################
# 1. le nom de l'atome correspond au tableau pédiodique des éléments
# https://fr.wikipedia.org/wiki/Liste_des_%C3%A9l%C3%A9ments_chimiques
# l'élément dont le nom est le plus court est l'or
# 2. la lettre de l'atome correspond aussi au tableau pédiodique des éléments
# https://fr.wikipedia.org/wiki/Tableau_p%C3%A9riodique_des_%C3%A9l%C3%A9ments
# et tous les symboles chimiques ont une majuscule et éventuellement une minsucule
# 3.une grammaire XSD possible pour ces contraintes :
###############################################################################
$gh> rxp molecule2.xsd # la grammaire est bien formée
###############################################################################
###############################################################################
#
# un premier exemple OK
#
###############################################################################
$gh> rxp moleculeOK1.xml # un premier exemple OK
$gh> xmllint --noout --schema molecule2.xsd moleculeOK1.xml
moleculeOK1.xml validates
###############################################################################
#
# un deuxième exemple OK (noter l'absence de l'attribut nombre)
#
###############################################################################
$gh> rxp moleculeOK2.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeOK2.xml
moleculeOK2.xml validates
###############################################################################
#
# quelques exemples incorrects
#
###############################################################################
$gh> rxp moleculeBAD1.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeBAD1.xml
moleculeBAD1.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'nombre': '-1' is not a valid value of the atomic type 'xs:positiveInteger'.
moleculeBAD1.xml fails to validate
###############################################################################
$gh> rxp moleculeBAD2.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeBAD2.xml
moleculeBAD2.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'nombre': '0' is not a valid value of the atomic type 'xs:positiveInteger'.
moleculeBAD2.xml fails to validate
###############################################################################
$gh> rxp moleculeBAD3.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeBAD3.xml
moleculeBAD3.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'nombre': '' is not a valid value of the atomic type 'xs:positiveInteger'.
moleculeBAD3.xml fails to validate
###############################################################################
$gh> rxp moleculeBAD4.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeBAD4.xml
moleculeBAD4.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'lettre': [facet 'pattern'] The value '' is not accepted by the pattern '[A-Z][a-z]?'.
moleculeBAD4.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'lettre': '' is not a valid value of the atomic type 'lettreAtome'.
moleculeBAD4.xml fails to validate
###############################################################################
$gh> rxp moleculeBAD5.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeBAD5.xml
moleculeBAD5.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'lettre': [facet 'pattern'] The value 'Oui' is not accepted by the pattern '[A-Z][a-z]?'.
moleculeBAD5.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'lettre': 'Oui' is not a valid value of the atomic type 'lettreAtome'.
moleculeBAD5.xml fails to validate
###############################################################################
$gh> rxp moleculeBAD6.xml
$gh> xmllint --noout --schema molecule2.xsd moleculeBAD6.xml
moleculeBAD6.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'nom': [facet 'minLength'] The value '' has a length of '0'; this underruns the allowed minimum length of '2'.
moleculeBAD6.xml:4: element atome: Schemas validity error :
Element 'atome', attribute 'nom': '' is not a valid value of the atomic type 'nomAtome'.
moleculeBAD6.xml fails to validate