ComposantsComponents › XML
Valide un fichier XML par rapport à une DTD, avec l'analyseur XML du JDK. Le DOCTYPE du fichier est remplacé par un autre qui désigne le Fichier DTD du composant : la DTD citée par le fichier n'est pas chargée. Le composant produit une ligne qui décrit le résultat et affiche un message, mais il ne dit pas pourquoi un fichier est invalide. Pour un schéma XSD, prenez un tXSDValidator, qui détaille les erreurs.
Validates an XML file against a DTD, with the XML parser of the JDK. The DOCTYPE of the file is replaced with another one that designates the DTD file of the component: the DTD cited by the file is not loaded. The component produces one row that describes the result and prints a message, but it does not say why a file is invalid. For an XSD schema, take a tXSDValidator, which details the errors.
EntréeInput
Aucune : il commence son sous-job. Sinon un lien Iterate (un fichier par itération) ou Main (une validation par ligne, d'après le modèle). None: it starts its subjob. Otherwise one Iterate link (one file per iteration) or Main (one validation per row, per the template).
SortieOutput
Main une ligne par validation : le résultat.one row per validation: the result.
Déclencheurs en sortieOutput triggers
On Subjob Ok On Subjob Error On Component Ok On Component Error Run if
Condition du lien : ((Boolean) globalMap.get("tDTDValidator_1_VALID")). Un fichier invalide n'arrête pas le job ; un fichier mal formé, si (voir les erreurs).
Link condition: ((Boolean) globalMap.get("tDTDValidator_1_VALID")). An invalid file does not stop the job; a malformed file does (see the errors).
Le Fichier XML reprend le fichier de l'itération : ((String) globalMap.get("tFileList_1_CURRENT_FILEPATH")). Le tLogRow reçoit une ligne par fichier.
The Xml file takes the file of the iteration: ((String) globalMap.get("tFileList_1_CURRENT_FILEPATH")). The tLogRow gets one row per file.
VALID dans un lien Run if, ou le message dans la console.
Use the result: Main output, VALID variable in a Run if link, or the message in the console.
Lu dans le modèle (tDTDValidator_main.javajet) ; les exemples en vérifient les conséquences :
Read in the template (tDTDValidator_main.javajet); the examples check its consequences:
<!DOCTYPE au premier > est retiré, puis le document est lu sans validation pour connaître sa racine, sa version et son encodage déclaré (ISO-8859-1 s'il n'en déclare pas).
The text that goes from <!DOCTYPE to the first > is removed, then the document is read without validation to know its root, its version and its declared encoding (ISO-8859-1 if it declares none).
<?xml version='…' encoding='…'?> et <!DOCTYPE racine SYSTEM 'Fichier DTD'> ; avec un Fichier DTD vide (""), par le DOCTYPE retiré. Les commentaires placés avant la racine disparaissent.
Everything before the root is replaced with <?xml version='…' encoding='…'?> and <!DOCTYPE root SYSTEM 'DTD file'>; with an empty DTD file (""), with the removed DOCTYPE. The comments placed before the root disappear.
Une DTD citée par une adresse web dans le fichier n'est pas téléchargée quand le Fichier DTD est rempli (exemple). Le document relu n'a plus de chemin : une DTD relative, citée par le fichier, est cherchée dans le dossier de travail du job. A DTD cited by a web address in the file is not downloaded when the DTD file is filled (example). The document read again no longer has a path: a relative DTD, cited by the file, is looked for in the working folder of the job.
Un DOCTYPE qui contient ses déclarations entre crochets (<!DOCTYPE note [ <!ELEMENT …> ]>) est coupé au premier >, celui de la première déclaration : le reste casse le document, et le job s'arrête, Fichier DTD rempli ou non (voir les erreurs).
A DOCTYPE that holds its declarations between brackets (<!DOCTYPE note [ <!ELEMENT …> ]>) is cut at the first >, the one of the first declaration: the rest breaks the document, and the job stops, DTD file filled or not (see the errors).
Les libellés sont ceux de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Le composant n'a pas de paramètres avancés. Labels are those of the Component tab; the technical name, in grey, is the parameter name in the job file. The component has no advanced settings.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| SchémaSchemaSCHEMA | sept colonnesseven columns | ToujoursAlways |
En lecture seule : dtdfile (le Fichier DTD), xmlfile (le Fichier XML), moment (Date de la validation), job, component, validate (Integer, 1 valide, 0 invalide) et message.
Read-only: dtdfile (the DTD file), xmlfile (the Xml file), moment (Date of the validation), job, component, validate (Integer, 1 valid, 0 invalid) and message.
|
| Fichier DTDDTD fileDTDFILE | chemin par défaut + /need_test.dtddefault path + /need_test.dtd |
ToujoursAlways |
La DTD, écrite dans le DOCTYPE qui remplace celui du fichier. Un chemin Windows avec des \ a été accepté. Vide ("") : le DOCTYPE du fichier est gardé.
The DTD, written into the DOCTYPE that replaces the one of the file. A Windows path with \ was accepted. Empty (""): the DOCTYPE of the file is kept.
|
| Fichier XMLXml fileXMLFILE | chemin par défaut + /reference.xmldefault path + /reference.xml |
ToujoursAlways |
Le fichier validé. D'après le modèle, une expression qui commence par " suivi d'un protocole ("http://…) est lue comme une adresse.
The validated file. Per the template, an expression that starts with " followed by a protocol ("http://…) is read as an address.
|
| Afficher si le XML est valideIf XML is valid, displayVALID_MESSAGE | "[job " + jobName + "] File is Valid" |
ToujoursAlways | Message d'un fichier valide : console et colonne message.Message of a valid file: console and message column. |
| Afficher si XML invalideIf XML is invalid, displayINVALID_MESSAGE | "[job " + jobName + "] File is Invalid" |
ToujoursAlways | Message d'un fichier invalide, de même.Message of an invalid file, likewise. |
| Afficher dans la consolePrint to consolePRINT | OuiYes | ToujoursAlways | Écrit le message, valide ou invalide, sur la sortie standard. Rien d'autre : pas le détail des erreurs.Writes the message, valid or invalid, to the standard output. Nothing else: not the details of the errors. |
"1" valide, "0" invalide.String, Difference: "1" valid, "0" invalid.null pour un fichier valide ou invalide ; le message de l'exception quand le composant s'arrête (fichier mal formé ou introuvable).String, common to all components: null for a valid or invalid file; the message of the exception when the component stops (malformed or missing file).((String) globalMap.get("tDTDValidator_1_DIFFERENCE"))
((Boolean) globalMap.get("tDTDValidator_1_VALID"))
((String) globalMap.get("tDTDValidator_1_ERROR_MESSAGE"))
Après une exception, DIFFERENCE et VALID ne sont pas écrites : un Run if sur VALID reçoit null.
After an exception, DIFFERENCE and VALID are not written: a Run if on VALID gets null.
Les jobs ont été exécutés dans Talaxie, avec Java 21 ; les sorties sont celles de la console, copiées telles quelles. Le dossier des fichiers est remplacé par C:/data et le nom du job par MyJob. La sortie Main va vers un tLogRow en mode simple (séparateur |) ; un tJava relié par On Subjob Ok affiche ensuite les variables globales.
The jobs were run in Talaxie, with Java 21; the outputs are the console ones, copied as they are. The files folder is replaced with C:/data and the job name with MyJob. The Main output goes to a tLogRow in basic mode (| separator); a tJava connected with On Subjob Ok then prints the global variables.
DTD note.dtd :note.dtd DTD:
<!ELEMENT note (to, from, heading?, body)> <!ATTLIST note priority (low|normal|high) "normal"> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
Fichier note-ok.xml :note-ok.xml file:
<?xml version="1.0" encoding="UTF-8"?> <note priority="high"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Call me back.</body> </note>
Fichier note-bad.xml :note-bad.xml file:
<?xml version="1.0" encoding="UTF-8"?> <note priority="urgent"> <to>Tove</to> <body>Call me back.</body> <signature>J.</signature> </note>
Fichier DTD "C:/data/note.dtd", Fichier XML "C:/data/note-ok.xml" :DTD file "C:/data/note.dtd", Xml file "C:/data/note-ok.xml":
[job MyJob] File is Valid C:/data/note.dtd|C:/data/note-ok.xml|2026-11-20 20:16:21|MyJob|tDTDValidator_1|1|[job MyJob] File is Valid DIFFERENCE = 1 VALID = true ERROR_MESSAGE = null
Avec "C:/data/note-bad.xml" (priorité urgent hors liste, from absent, élément signature non déclaré) :With "C:/data/note-bad.xml" (urgent priority out of the list, from missing, undeclared signature element):
[job MyJob] File is Invalid C:/data/note.dtd|C:/data/note-bad.xml|2026-11-20 20:16:24|MyJob|tDTDValidator_1|0|[job MyJob] File is Invalid DIFFERENCE = 0 VALID = false ERROR_MESSAGE = null
Trois erreurs, et aucune n'est signalée : seul le message « invalide » le dit. Le job se termine normalement. Three errors, and none of them is reported: only the “invalid” message says so. The job ends normally.
Fichier note-doctype.xml, dont la DTD est à une adresse injoignable :note-doctype.xml file, whose DTD is at an unreachable address:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE note SYSTEM "http://127.0.0.1:9/dtd/note.dtd"> <note> <to>Tove</to> <from>Jani</from> <body>Call me back.</body> </note>
Fichier DTD "C:/data/note.dtd" :DTD file "C:/data/note.dtd":
[job MyJob] File is Valid C:/data/note.dtd|C:/data/note-doctype.xml|2026-11-20 20:16:27|MyJob|tDTDValidator_1|1|[job MyJob] File is Valid DIFFERENCE = 1 VALID = true ERROR_MESSAGE = null
L'adresse n'a pas été contactée : le fichier est validé par la DTD du composant. The address was not contacted: the file is validated by the DTD of the component.
Fichier note-relative.xml, à côté de note.dtd :note-relative.xml file, next to note.dtd:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Tove</to> <from>Jani</from> <body>Call me back.</body> </note>
Fichier DTD "" :DTD file "":
Exception in component tDTDValidator_1 (MyJob) java.io.FileNotFoundException: C:\work\note.dtd (Le fichier spécifié est introuvable) … [On Subjob Error] DIFFERENCE = null VALID = null ERROR_MESSAGE = C:\work\note.dtd (Le fichier spécifié est introuvable)
La DTD est cherchée dans le dossier de travail du job (ici remplacé par C:\work), pas à côté du fichier XML. Avec "C:/data/note.dtd", le même fichier est valide.
The DTD is looked for in the working folder of the job (replaced with C:\work here), not next to the XML file. With "C:/data/note.dtd", the same file is valid.
Ces erreurs arrêtent le composant. Les jobs ont un tJava relié par On Subjob Error, qui affiche [On Subjob Error] puis les variables ; les piles d'appels sont abrégées (…).
These errors stop the component. The jobs have a tJava connected with On Subjob Error, which prints [On Subjob Error] then the variables; the stack traces are shortened (…).
note-broken.xml, où <from>Jani</to> est mal fermé :note-broken.xml, where <from>Jani</to> is badly closed:
[Fatal Error] :4:15: Le type d'élément "from" doit se terminer par la balise de fin correspondante "</from>". Exception in component tDTDValidator_1 (MyJob) org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 15; Le type d'élément "from" doit se terminer par la balise de fin correspondante "</from>". … [On Subjob Error] DIFFERENCE = null VALID = null ERROR_MESSAGE = Le type d'élément "from" doit se terminer par la balise de fin correspondante "</from>".
Contrairement au fichier invalide, le fichier mal formé arrête le composant : pas de ligne en sortie, pas de message « invalide ». La ligne [Fatal Error] est écrite par l'analyseur du JDK.Unlike the invalid file, the malformed file stops the component: no output row, no “invalid” message. The [Fatal Error] line is written by the JDK parser.
Fichier note-internal.xml, valide d'après sa propre DTD :note-internal.xml file, valid according to its own DTD:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE note [ <!ELEMENT note (to, from, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to>Tove</to> <from>Jani</from> <body>Call me back.</body> </note>
Fichier DTD "C:/data/note.dtd" ou "" : même sortie.DTD file "C:/data/note.dtd" or "": same output.
[Fatal Error] :3:5: Le balisage du document précédant l'élément racine doit avoir un format correct. Exception in component tDTDValidator_1 (MyJob) org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 5; Le balisage du document précédant l'élément racine doit avoir un format correct. … [On Subjob Error] DIFFERENCE = null VALID = null ERROR_MESSAGE = Le balisage du document précédant l'élément racine doit avoir un format correct.
Défaut du modèle de Talaxie (tDTDValidator_main.javajet, lignes 59-64) : le DOCTYPE est coupé au premier >, celui de <!ELEMENT note …>. Retirez la DTD interne du fichier, ou validez-le autrement.Defect of the Talaxie template (tDTDValidator_main.javajet, lines 59-64): the DOCTYPE is cut at the first >, the one of <!ELEMENT note …>. Remove the internal DTD from the file, or validate it another way.
Fichier XML "C:/data/missing.xml", absent :Xml file "C:/data/missing.xml", missing:
Exception in component tDTDValidator_1 (MyJob) java.lang.NullPointerException: Cannot invoke "java.io.BufferedReader.close()" because "<local19>" is null at demo.myjob_0_1.MyJob.tDTDValidator_1Process(MyJob.java:1144) … [On Subjob Error] DIFFERENCE = null VALID = null ERROR_MESSAGE = Cannot invoke "java.io.BufferedReader.close()" because "<local19>" is null
Défaut du modèle (lignes 47-56) : l'ouverture échoue, puis la fermeture d'un lecteur jamais créé lève une NullPointerException, qui cache la vraie cause. Le texte de l'exception est celui de Java 21 ; une version ancienne de Java n'en donne pas. Vérifiez l'existence du fichier avant (tFileExist).Defect of the template (lines 47-56): the opening fails, then closing a reader that was never created throws a NullPointerException, which hides the real cause. The exception text is the Java 21 one; an old Java version gives none. Check that the file exists first (tFileExist).
Fichier DTD "C:/data/missing.dtd", absent :DTD file "C:/data/missing.dtd", missing:
Exception in component tDTDValidator_1 (MyJob) java.io.FileNotFoundException: C:\data\missing.dtd (Le fichier spécifié est introuvable) … [On Subjob Error] DIFFERENCE = null VALID = null ERROR_MESSAGE = C:\data\missing.dtd (Le fichier spécifié est introuvable)
Avec un chemin absolu vers une copie locale : le composant ne dépend alors ni du DOCTYPE du fichier, ni du dossier de travail, ni du réseau.
With an absolute path to a local copy: the component then depends neither on the DOCTYPE of the file, nor on the working folder, nor on the network.
Valide, invalide (le job continue, VALID = false) ou exception (fichier mal formé, introuvable : le composant s'arrête). Prévoyez un lien On Subjob Error ou On Component Error pour la troisième.
Valid, invalid (the job goes on, VALID = false) or exception (malformed or missing file: the component stops). Plan an On Subjob Error or On Component Error link for the third one.
D'après le modèle, le fichier est lu dans l'encodage par défaut de la JVM, puis relu en UTF-8 sous l'en-tête de son encodage déclaré. Avec Java 21, un fichier UTF-8 est bien lu ; un fichier ISO-8859-1 accentué peut voir ses caractères altérés (non essayé). Per the template, the file is read in the default encoding of the JVM, then read again in UTF-8 under the header of its declared encoding. With Java 21, a UTF-8 file is read correctly; an accented ISO-8859-1 file may get its characters altered (not tried).
Le composant ne donne pas la raison d'un refus. Si un schéma XSD équivalent existe, le tXSDValidator liste chaque erreur avec sa ligne. The component does not give the reason of a refusal. If an equivalent XSD schema exists, the tXSDValidator lists each error with its line.
tXSDValidator · valider par un schéma XSD, fichier ou fluxvalidate with an XSD schema, file or flowtXSLT · transformer un XML par une feuille XSLtransform an XML with an XSL stylesheettFileInputXML · lire les lignes d'un fichier XMLread the rows of an XML filetFileList · valider plusieurs fichiers, un par itérationvalidate several files, one per iterationtFileExist · vérifier qu'un fichier existecheck that a file existstLogRow · afficher les lignes d'un fluxdisplay the rows of a flow