27 February 2018

blog

xmllint

Le conseil qui revient souvent est xmllint :

xmllint --schema schema.xsd undertest.xml

Lorsque certaines dépendances de schema ne sont pas disponibles, il y a une erreur.

Le problème est que xmllint ne parviens pas à récupérer les sources du schéma pour la signature, et échoue à faire la validation.

Ce qui est surprenant, c'est que le répertoire contient un fichier catalog.xml qui contient la correspondance

    <public publicId="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema" uri="xmldsig-core-schema.xsd"/>
    <system systemId="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd" uri="xmldsig-core-schema.xsd"/>

xmlbeans

En reprenant de vieux scripts à moi de 2008, je retombe sur la commande validate, qui est un script de wrapping pour un appel à une bibliothèque de parsing java, xmlbeans.

Même problème de dépendances de schéma avec la commande par défaut :

> export XMLBEANS_LIB=$(dirname $(find /usr -iname xbean.jar 2>/dev/null))
> validate xsd/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd KDM_BATMAN-GOTHAM-BY-GASLIGHT_FTR-1_EN-FR_51_HD_WR_20180124_DUB_OV_A1613.xml 
Schema invalid:
Loading referenced file file:/path/to/file/xsd/SMPTE-430-3-2008-ETM.xsd
/path/to/file/xsd/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd:11:3: error: Could not load resource "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd" (network downloads disabled).
/path/to/file/xsd/SMPTE-430-3-2008-ETM.xsd:6:3: error: Could not load resource "http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd" (network downloads disabled).
/path/to/file/xsd/SMPTE-430-3-2008-ETM.xsd:14:7: error: src-resolve: element 'Signature@http://www.w3.org/2000/09/xmldsig#' not found.
/path/to/file/xsd/SMPTE-430-3-2008-ETM.xsd:25:7: error: src-resolve: type 'X509IssuerSerialType@http://www.w3.org/2000/09/xmldsig#' not found.
/path/to/file/xsd/SMPTE-430-3-2008-ETM.xsd:47:7: error: src-resolve: element 'EncryptedKey@http://www.w3.org/2001/04/xmlenc#' not found.
/path/to/file/xsd/SMPTE-430-3-2008-ETM.xsd:48:7: error: src-resolve: element 'EncryptedData@http://www.w3.org/2001/04/xmlenc#' not found.
/path/to/file/xsd/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd:20:13: error: src-resolve: type 'X509IssuerSerialType@http://www.w3.org/2000/09/xmldsig#' not found.
/path/to/file/xsd/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd:56:13: error: src-resolve: type 'DigestValueType@http://www.w3.org/2000/09/xmldsig#' not found.

Pour résoudre le problème :

> validate -dl xsd/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd KDM_BATMAN-GOTHAM-BY-GASLIGHT_FTR-1_EN-FR_51_HD_WR_20180124_DUB_OV_A1613.xml

L'option -dl autorise à télécharger les schémas en ligne, ce qui permet de résoudre la dépendance à la definition du schéma des signatures.

schema-check

Récupération du code de schema-check dans l'annexe C.3.1 du DCI 1.1.

Installation des dépendances :

sudo apt-get install libxerces-c-devel
g++ schema-check.cpp -o schema-check -lxerces-c


A fouiller

Use local resources when validating XML