dtd | 8 years ago | ||
tmp | 8 years ago | ||
tools | 8 years ago | ||
xml | 8 years ago | ||
xslt | 8 years ago | ||
.gitignore | 8 years ago | ||
README.md | 8 years ago | ||
package.json | 8 years ago | ||
parse-doctype | 8 years ago |
08 janvier 2016
git clone ssh://vsistex.intra.inist.fr:22222/git/istex/ade-outils-xml.git cd ade-outils-xml npm install
Mon fichier XML est-il bien formé ?
&<>;,
dans les attributs ou noeuds texte# test sur un XML bien formé xmlwf xml/oup-sample.xml echo $? # test sur un XML mal formé xmlwf xml/bad-formed.xml echo $? # le même test en passant par stdin cat xml/bad-formed.xml | xmlwf # test d'un répertoire entier xmlwf xml/*
NB : Valeur de retour toujours 0, même si bien formé. Obligation de vérifier stdout si on souhaite automatiser
Récupération des informations contenues dans la ligne doctype.
# récupération d'un doctype "classique" tools/parse_doctype xml/oup-sample.xml # cas d'un XML sans doctype tools/parse_doctype xml/wiley-sample.xml # cas d'un XML mal formé tools/parse_doctype xml/parsing-problem.xml # utilisation en passant par stdin cat tools/node_modules/get-doctype/test/dataset/big.xml | tools/parse_doctype
Plus d'infos sur https://github.com/Inist-CNRS/get-doctype
Site officiel : http://xmlstar.sourceforge.net/
Interrogation de documents XML en ligne de commande. Possibilité de faire des requêtes complexes via XPath. (documentation officielle)
# sélection d'une valeur dans un noeud texte xmlstarlet sel -t -v "//_:publisherInfo/_:publisherName" -n xml/wiley-sample.xml # sélection d'une valeur dans un attribut xmlstarlet sel -t -v "//_:coverDate/@startDate" -n xml/wiley-sample.xml # sélection d'une valeur avec conditionnelle xmlstarlet sel -t -v "/_:component/_:header//_:issn[@type='print']" -n xml/wiley-sample.xml # Utilisation du template -m <=> xsl:for-each xmlstarlet sel -t -m "//_:citation" -v "_:pubYear/@year" -n xml/wiley-sample.xml
Validation de documents selon DTD, Schéma XML ou RelaxNG. ([documentation officiellehttp://xmlstar.sourceforge.net/doc/UG/ch04s04.html))
# Validation contre DTD val -e -d dtd/Wileyml3gv20-flat/Wileyml3gv20-flat.dtd xml/wiley-sample.xml # Validation contre RelaxNG xmlstarlet val -e -r dtd/Wileyml3gv20-rng/Wileyml3g.rng xml/wiley-sample.xml # Echec de validation val -e -r dtd/Wileyml3gv20-rng/Wileyml3g.rng xml/not-valid.xml
Transformation XSLT de documents XML.
# Transformation vers le format MODS # Transformation avec passage de paramètre
##