ComposantsComponents

ComposantsComponents › XML

tXMLMap

tXMLMap

XML TraitementProcessing

Le pendant XML du tMap : il relie des flux d'entrée à des flux de sortie dans un éditeur graphique, avec des jointures, des variables, des filtres et plusieurs sorties, mais une colonne de type Document s'y déplie en arbre XML. Il sert dans les deux sens : éclater un document en lignes (une ligne par occurrence d'un élément en boucle), ou construire un document à partir de lignes (éléments répétés, groupés, un document pour tout le flux ou un par groupe). Les lookups se joignent sur les colonnes ou sur les nœuds d'un document. The XML counterpart of the tMap: it connects input flows to output flows in a graphical editor, with joins, variables, filters and several outputs, but a column of type Document unfolds there into an XML tree. It works both ways: splitting a document into rows (one row per occurrence of a loop element), or building a document from rows (repeated elements, grouped, one document for the whole flow or one per group). Lookups join on the columns or on the nodes of a document.

EntréeInput

Main un flux, obligatoire : le principal.one flow, required: the main one.
Lookup autant que nécessaire : les liens suivants, chargés avant le flux principal.as many as needed: the next links, loaded before the main flow.

SortieOutput

Main au moins une : une par arbre de sortie de l'éditeur, qui donne son nom au lien. Les rejets (sortie, jointure interne) sont des sorties comme les autres.at least one: one per output tree of the editor, which gives its name to the link. Rejects (output, inner join) are outputs like the others.

Déclencheurs en sortieOutput triggers

AucunNone On Component Ok, On Component Error et Run if sont fermés (MAX_OUTPUT="0") : enchaînez sur le sous-job.On Component Ok, On Component Error and Run if are closed (MAX_OUTPUT="0"): chain on the subjob.

UtilisationUsage

Document vers lignesDocument to rows

row1 (Main) out1 (Main) tFileInputXML_1 tXMLMap_1 tLogRow_1

Le tFileInputXML lit tout le fichier dans une colonne Document (boucle sur la racine, requête ".", Obtenir les nœuds coché). Le tXMLMap boucle sur l'élément répété et donne une ligne par occurrence. The tFileInputXML reads the whole file into a Document column (loop on the root, query ".", Get Nodes checked). The tXMLMap loops on the repeated element and gives one row per occurrence.

Lignes vers un documentRows to a document

row1 (Main) out1 (Main) tFixedFlowInput_1 tXMLMap_1 tJavaRow_1

La sortie a une colonne Document dont l'arbre décrit le XML à produire. Le document peut ensuite partir vers un service (tRESTResponse, tESBProviderResponse) ou un fichier (tAdvancedFileOutputXML). The output has a Document column whose tree describes the XML to produce. The document can then go to a service (tRESTResponse, tESBProviderResponse) or a file (tAdvancedFileOutputXML).

  1. Déposez le tXMLMap (famille XML ou Traitement), reliez le flux principal, puis les lookups : le second lien vers le composant devient un Lookup. Drop the tXMLMap (XML or Processing family), connect the main flow, then the lookups: the second link to the component becomes a Lookup.
  2. Tracez les liens de sortie, puis ouvrez l'éditeur (double clic, ou bouton de l'Éditeur de mapping). Chaque lien a son arbre. Draw the output links, then open the editor (double click, or the Map Editor button). Each link has its tree.
  3. Sous une colonne Document, importez la structure (clic droit, Import From File, un XML ou un XSD), puis désignez l'élément répété : As loop element. Under a Document column, import the structure (right click, Import From File, an XML or an XSD), then designate the repeated element: As loop element.
  4. Glissez les nœuds d'entrée vers les sorties, ou écrivez les expressions, et réglez les arbres (bouton tXmlMap settings) : jointure des lookups, All in one d'un document de sortie. Drag the input nodes to the outputs, or write the expressions, and set the trees (tXmlMap settings button): join of the lookups, All in one of an output document.

L'éditeurThe editor

Tout le travail du composant se fait dans son éditeur, enregistré dans le job avec le nœud (nodeData de type XmlMapData). Dans le Studio, ses menus et ses réglages sont en anglais, quelle que soit la langue : la page les cite tels quels. All the work of the component is done in its editor, saved in the job with the node (nodeData of type XmlMapData). In the Studio, its menus and settings are in English, whatever the language: the page quotes them as they are.

Entrées, à gaucheInputs, on the left

Un arbre par lien entrant, le flux principal en tête, puis les lookups (boutons de la barre : monter, descendre, réduire). Ses premiers nœuds sont les colonnes du schéma ; une colonne Document porte en dessous l'arbre de son XML. One tree per incoming link, the main flow first, then the lookups (bar buttons: move up, move down, minimize). Its first nodes are the columns of the schema; a Document column carries the tree of its XML below it.

Variables, au centreVariables, in the middle

La table Var : une expression, un type et un nom par variable, calculée une fois par ligne et lue par Var.nom dans les sorties. The Var table: one expression, one type and one name per variable, computed once per row and read through Var.name in the outputs.

Sorties, à droiteOutputs, on the right

Un arbre par sortie (boutons : ajouter, retirer, monter, descendre, réduire, Auto Map, qui relie les nœuds sans expression à ceux de même chemin, ou à défaut de même nom, en entrée). En bas, trois onglets : Éditeur de schéma, Éditeur de schéma en arbre (XPath, type, nullable, modèle de chaque nœud) et Éditeur d'expression. One tree per output (buttons: add, remove, move up, move down, minimize, Auto Map, which connects the nodes without expression to the input ones with the same path, or else the same name). At the bottom, three tabs: Schema editor, Tree schema editor (XPath, type, nullable, pattern of each node) and Expression editor.

Arbre d'un documentTree of a document

Clic droit sur un nœud d'une colonne Document : Import From File (XML ou XSD), Import From Repository (métadonnée XML), Create Sub-Element, Create Attribute, Set A Namespace, Change Namespace, Add Choice, Set as substitution, Rename, Delete, et les rôles ci-dessous. Le menu n'affiche que les actions possibles sur le nœud. Arbre d'entrée de l'exemple, importé d'un fichier : Right click on a node of a Document column: Import From File (XML or XSD), Import From Repository (XML metadata), Create Sub-Element, Create Attribute, Set A Namespace, Change Namespace, Add Choice, Set as substitution, Rename, Delete, and the roles below. The menu only shows the actions possible on the node. Input tree of the example, imported from a file:

row1
└─ doc                       Document
   └─ orders
      └─ order
         ├─ @id
         ├─ customer
         └─ line             loop
            ├─ @product
            └─ qty           Integer

Un nœud se désigne dans une expression par son chemin entre crochets : [row1.doc:/orders/order/@id]. Une colonne simple s'écrit row2.label, une variable Var.ref. Seul un nœud sans sous-élément (feuille, attribut) reçoit une expression ou se glisse vers une autre. A node is designated in an expression by its path in brackets: [row1.doc:/orders/order/@id]. A simple column is written row2.label, a variable Var.ref. Only a node without sub-element (leaf, attribute) gets an expression or can be dragged to another one.

Rôles d'un élémentRoles of an element

  • As loop element : l'élément répété. En entrée, une ligne par occurrence, et les nœuds des parents sont lus pour chacune (../@id). En sortie, l'élément est recréé pour chaque ligne. Une seule boucle par branche : le Studio prévient que les boucles des parents et des enfants sont retirées. Importé, le premier élément est la boucle. As loop element: the repeated element. On input, one row per occurrence, and the nodes of the parents are read for each one (../@id). On output, the element is created again for each row. One loop per branch: the Studio warns that the loops of the parents and children are removed. When imported, the first element is the loop.
  • As optional loop (entrée) : si le document n'a aucune occurrence de la boucle, son parent sert de boucle, au lieu de ne donner aucune ligne (voir l'exemple). As optional loop (input): if the document has no occurrence of the loop, its parent is used as the loop, instead of giving no row (see the example).
  • As group element (sortie) : un élément au-dessus de la boucle, repris tant que ses valeurs ne changent pas d'une ligne à la suivante. Il n'est proposé que sur un élément qui a une boucle en dessous. As group element (output): an element above the loop, reused as long as its values do not change from one row to the next. It is only offered on an element with a loop below it.
  • As aggregate element (sortie, sur une feuille) : un nouveau document commence chaque fois que sa valeur change ; impossible avec All in one. As aggregate element (output, on a leaf): a new document starts each time its value changes; not possible with All in one.

Glisser-déposerDrag and drop

Un nœud d'entrée déposé sur l'expression d'un nœud de sortie l'y ajoute. Déposé sur le nom d'un élément d'un document de sortie, il crée un nœud : la fenêtre Selection demande Create as sub-element of target node, Create as attribute of target node ou Add linker to target node (relier, seulement si l'élément n'a pas d'enfant). Un élément qui a des attributs est recopié avec eux, sans question. An input node dropped on the expression of an output node is added to it. Dropped on the name of an element of an output document, it creates a node: the Selection window asks Create as sub-element of target node, Create as attribute of target node or Add linker to target node (connect, only if the element has no child). An element that has attributes is copied with them, without question.

Plusieurs boucles en entréeSeveral loops on input

Une entrée principale peut avoir plusieurs boucles sœurs (par exemple line et note sous order). Chaque sortie sans colonne Document reçoit alors le bouton set Loop Function, qui ouvre Configure source loops : les boucles parcourues, dans l'ordre, pour cette sortie (voir l'exemple). A main input can have several sibling loops (for example line and note under order). Each output without a Document column then gets the set Loop Function button, which opens Configure source loops: the loops walked through, in order, for that output (see the example).

Réglages des arbres (bouton tXmlMap settings)Tree settings (tXmlMap settings button)

Chaque lookup et chaque sortie a ce bouton et celui du filtre (Enable/disable expression filter) ; l'entrée principale n'en a pas. Le filtre est une condition Java booléenne : sur un lookup, il écarte des lignes du lookup ; sur une sortie, il choisit les lignes qui y vont. Each lookup and each output has this button and the filter one (Enable/disable expression filter); the main input has none. The filter is a boolean Java condition: on a lookup, it discards lookup rows; on an output, it chooses the rows that go there.

RéglageSetting DéfautDefault VisibleShown Description
Lookup ModellookupMode Load once LookupLookup Load once : le lookup est chargé en mémoire au début du sous-job. Reload at each row : son sous-job est relancé pour chaque ligne principale ; une table GlobalMap Key y place d'abord des valeurs dans globalMap, que la source du lookup peut lire (une requête, par exemple). Reload at each row (cache) : de même, avec un cache des résultats. Load once: the lookup is loaded in memory at the start of the subjob. Reload at each row: its subjob is run again for each main row; a GlobalMap Key table first puts values into globalMap, which the lookup source can read (a query, for instance). Reload at each row (cache): the same, with a cache of the results.
Match ModelmatchingMode All rows LookupLookup Sans clé, All rows : chaque ligne principale est jointe à toutes les lignes du lookup. Dès qu'un nœud du lookup reçoit une expression (une clé), le Studio passe à Unique match (la dernière ligne chargée qui correspond) et propose aussi First match (la première) et All matches (toutes). Voir les modes. Without key, All rows: each main row is joined to all the lookup rows. As soon as a lookup node gets an expression (a key), the Studio switches to Unique match (the last loaded matching row) and also offers First match (the first one) and All matches (all of them). See the modes.
Join ModelinnerJoin Left Outer Join Lookup, modifiable avec une cléLookup, editable with a key Left Outer Join : une ligne sans correspondance passe, les nœuds du lookup à null. Inner Join : elle est écartée, ou envoyée à une sortie Catch Lookup Inner Join Reject. Left Outer Join: a row without match goes through, the lookup nodes set to null. Inner Join: it is dropped, or sent to a Catch Lookup Inner Join Reject output.
Catch Output Rejectreject false SortieOutput La sortie reçoit les lignes qu'aucune sortie filtrée n'a prises (voir l'exemple). The output gets the rows that no filtered output took (see the example).
Catch Lookup Inner Join RejectrejectInnerJoin false SortieOutput La sortie reçoit les lignes écartées par une jointure interne (voir l'exemple). The output gets the rows dropped by an inner join (see the example).
All in oneallInOne false Sortie avec une colonne DocumentOutput with a Document column Un seul document pour toutes les lignes, émis à la fin du flux ; décoché, un document par ligne. Non modifiable si la sortie a un élément d'agrégat. One single document for all the rows, sent at the end of the flow; unchecked, one document per row. Not editable if the output has an aggregate element.
Create empty elementenableEmptyElement true Sortie avec une colonne DocumentOutput with a Document column À false, les éléments sans texte, sans attribut et sans enfant sont retirés du document une fois fait (voir l'exemple). Set to false, the elements without text, attribute or child are removed from the finished document (see the example).

Dans TalaxieIn Talaxie

L'éditeur de Talaxie reprend les arbres, les menus des nœuds (Import From Repository et Set as substitution à partir de la version 9.0.7, sans les connexions MDM pour l'import), le glisser-déposer, les variables, Auto Map, les boucles sources et les réglages des arbres. Jusqu'à la version 9.0.6, il ne proposait pas les points suivants, repris à partir de Talaxie 9.0.7 comme dans le Studio : The Talaxie editor takes over the trees, the node menus (Import From Repository and Set as substitution from version 9.0.7, without MDM connections for the import), drag and drop, variables, Auto Map, source loops and tree settings. Up to version 9.0.6, it did not offer the following points, taken over from Talaxie 9.0.7 as in the Studio:

  • le passage automatique à Unique match quand une clé est saisie sur un lookup : le lookup restait en All rows et la clé était ignorée, chaque ligne principale étant jointe à toutes les lignes du lookup (voir l'exemple) : avec Talaxie 9.0.6, choisissez le Match Model vous-même. Talaxie 9.0.6 proposait aussi les quatre modes quelle que soit la clé, et Load once and update, absent du Studio pour ce composant ; the automatic switch to Unique match when a key is typed on a lookup: the lookup stayed in All rows and the key was ignored, each main row being joined to all the lookup rows (see the example): with Talaxie 9.0.6, choose the Match Model yourself. Talaxie 9.0.6 also offered the four modes whatever the key, and Load once and update, absent from the Studio for this component;
  • le bouton du filtre d'expression : le filtre d'une sortie n'apparaissait que s'il était déjà actif dans le job, celui d'un lookup pas du tout ; the expression filter button: the filter of an output only appeared if it was already active in the job, the one of a lookup not at all;
  • l'Éditeur de schéma en arbre : le type d'un nœud d'un document restait celui de l'import (String, ou Date pour une date d'un XSD). Avec Talaxie 9.0.6, convertissez dans l'expression, par exemple Integer.valueOf([row1.doc:/orders/order/line/qty]) ; the Tree schema editor: the type of a node of a document stayed the imported one (String, or Date for a date of an XSD). With Talaxie 9.0.6, convert in the expression, for instance Integer.valueOf([row1.doc:/orders/order/line/qty]);
  • la table GlobalMap Key d'un lookup rechargé à chaque ligne, gardée telle quelle sans être affichée ni modifiable. the GlobalMap Key table of a lookup reloaded at each row, kept as it is without being shown or editable.

Paramètres simplesBasic settings

L'onglet Composant n'a que le bouton de l'éditeur : tout le reste est dans l'éditeur. Le nom technique, en gris, est celui du paramètre dans le fichier du job. The Component tab only has the editor button: everything else is in the editor. The technical name, in grey, is the parameter name in the job file.

ParamètreSetting DéfautDefault VisibleShown Description
Éditeur de mappingMap EditorMAP — ToujoursAlways Ouvre l'éditeur (aussi par un double clic sur le composant). Opens the editor (also with a double click on the component).
Arrêter en cas d'erreurDie on errorDIE_ON_ERROR OuiYes JamaisNever Caché. Le bouton qui le changeait dans l'éditeur est désactivé dans le Studio depuis la version 5.0, et le code généré ne le lit pas : une erreur dans une expression arrête toujours le job. Une sortie ErrorReject d'un ancien job ne reçoit rien (voir les erreurs). Hidden. The button that changed it in the editor is disabled in the Studio since version 5.0, and the generated code does not read it: an error in an expression always stops the job. An ErrorReject output of an old job gets nothing (see the errors).

Paramètres avancésAdvanced settings

ParamètreSetting DéfautDefault VisibleShown Description
Garder l'ordre du documentKeep order for documentKEEP_ORDER_FOR_DOCUMENT NonNo ToujoursAlways Pour un document de sortie qui a plusieurs éléments en boucle, d'après le modèle (tXMLMapOut_begin.javajet) : chaque nouvel élément est inséré après le dernier de même nom, à sa place dans l'arbre, au lieu d'être ajouté à la fin de son parent. Sans effet avec une seule boucle. For an output document with several loop elements, per the template (tXMLMapOut_begin.javajet): each new element is inserted after the last one with the same name, at its place in the tree, instead of being appended at the end of its parent. No effect with a single loop.

ExécutionExecution

Lignes gardées jusqu'à la finRows kept until the end

Quand l'entrée principale a une colonne Document, ou qu'une sortie est All in one, a un agrégat ou plusieurs boucles, le code généré découpe le composant en deux parties, tXMLMap_1_TXMLMAP_OUT et tXMLMap_1_TXMLMAP_IN. Toutes les lignes de sortie sont gardées en mémoire, puis envoyées aux composants suivants une fois l'entrée lue en entier. Les messages d'erreur nomment tXMLMap_1_TXMLMAP_OUT. When the main input has a Document column, or an output is All in one, has an aggregate or several loops, the generated code splits the component into two parts, tXMLMap_1_TXMLMAP_OUT and tXMLMap_1_TXMLMAP_IN. All the output rows are kept in memory, then sent to the next components once the input has been read entirely. Error messages name tXMLMap_1_TXMLMAP_OUT.

Documents et bibliothèquesDocuments and libraries

Une colonne Document contient un routines.system.Document, qui enveloppe un document dom4j ; les nœuds d'entrée sont lus par XPath (Jaxen). Le composant demande dom4j-2.1.3 et jaxen-1.2.0, et chaque lookup, notamment, advancedPersistentLookupLib-1.5 par son composant de chargement, tAdvancedXMLMapHash. Les jobs des exemples ont tourné en Java 21. A Document column holds a routines.system.Document, which wraps a dom4j document; input nodes are read by XPath (Jaxen). The component asks for dom4j-2.1.3 and jaxen-1.2.0, and each lookup, among others, for advancedPersistentLookupLib-1.5 through its loading component, tAdvancedXMLMapHash. The jobs of the examples ran on Java 21.

Variables globalesGlobal variables

Aucune : le composant ne déclare pas de variable (RETURNS vide), pas même NB_LINE. Comptez les lignes sur le composant suivant, ou dans une variable de la table Var. None: the component declares no variable (empty RETURNS), not even NB_LINE. Count the rows on the next component, or in a variable of the Var table.

ExemplesExamples

Les fichiers sont lus dans le dossier de la variable de contexte folder, par un tFileInputXML en UTF-8 qui met tout le document dans une colonne Document doc. Les arbres d'entrée sont importés de ces fichiers. Les tLogRow sont en mode tableau sauf mention ; un tJavaRow affiche les documents produits mis en forme (input_row.doc.formatXMLString(org.dom4j.io.OutputFormat.createPrettyPrint())). Les sorties sont celles de la console, copiées depuis une exécution des jobs. The files are read in the folder of the folder context variable, by a tFileInputXML in UTF-8 that puts the whole document into a Document column doc. The input trees are imported from these files. The tLogRow components are in table mode unless stated; a tJavaRow prints the produced documents formatted (input_row.doc.formatXMLString(org.dom4j.io.OutputFormat.createPrettyPrint())). The outputs are the console ones, copied from a run of the jobs.

1. Un document éclaté en lignes1. A document split into rows

row1 (Main) out1 (Main) tFileInputXML_1 tXMLMap_1 tLogRow_1

Fichier orders.xml (boucle du tFileInputXML : "/orders") :orders.xml file (tFileInputXML loop: "/orders"):

<?xml version="1.0" encoding="UTF-8"?>
<orders>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P1"><qty>2</qty></line>
    <line product="P2"><qty>1</qty></line>
  </order>
  <order id="A-2">
    <customer>Grace</customer>
    <line product="P3"><qty>5</qty></line>
  </order>
</orders>

Arbre row1 : celui de l'éditeur, boucle sur line, qty en Integer. Variable ref (String) : [row1.doc:/orders/order/@id] + "/" + [row1.doc:/orders/order/line/@product]. Sortie out1 : row1 tree: the one of the editor, loop on line, qty as Integer. Variable ref (String): [row1.doc:/orders/order/@id] + "/" + [row1.doc:/orders/order/line/@product]. out1 output:

ColonneColumn Type Expression
order_idString[row1.doc:/orders/order/@id]
customerString[row1.doc:/orders/order/customer]
productString[row1.doc:/orders/order/line/@product]
qtyInteger[row1.doc:/orders/order/line/qty]
refStringVar.ref
.--------+--------+-------+---+------.
|             tLogRow_1              |
|=-------+--------+-------+---+-----=|
|order_id|customer|product|qty|ref   |
|=-------+--------+-------+---+-----=|
|A-1     |Ada     |P1     |2  |A-1/P1|
|A-1     |Ada     |P2     |1  |A-1/P2|
|A-2     |Grace   |P3     |5  |A-2/P3|
'--------+--------+-------+---+------'
  • Une ligne par élément line ; @id et customer, au-dessus de la boucle, sont lus pour chacune dans la commande qui la contient (le code généré les cherche par ../@id et ../customer). One row per line element; @id and customer, above the loop, are read for each one in the order that contains it (the generated code looks for them through ../@id and ../customer).
  • Le texte d'un nœud est converti dans son type (qty : Integer) au moment où l'expression le lit. The text of a node is converted to its type (qty: Integer) when the expression reads it.
  • Sans fichier, un tFixedFlowInput peut fournir la colonne Document : valeur routines.system.ParserUtils.parseTo_Document("<orders><order id='A-7'>…</orders>"). Même tXMLMap, sans la variable : Without a file, a tFixedFlowInput can supply the Document column: value routines.system.ParserUtils.parseTo_Document("<orders><order id='A-7'>…</orders>"). Same tXMLMap, without the variable:
.--------+--------+-------+---.
|          tLogRow_1          |
|=-------+--------+-------+--=|
|order_id|customer|product|qty|
|=-------+--------+-------+--=|
|A-7     |Alan    |P5     |4  |
'--------+--------+-------+---'

2. Des lignes vers un document : boucle et groupe2. Rows to a document: loop and group

row1 (Main) out1 (Main) tFixedFlowInput_1 tXMLMap_1 tJavaRow_1

Lignes du tFixedFlowInput (qty : Integer) :Rows of the tFixedFlowInput (qty: Integer):

customer order_id product qty
AdaA-1P12
AdaA-1P21
GraceA-2P35

Sortie out1, colonne doc (Document), arbre importé d'un exemple, All in one à true : out1 output, doc column (Document), tree imported from a sample, All in one set to true:

out1
└─ doc                  Document
   └─ orders
      └─ order          group
         ├─ @id         row1.order_id
         ├─ customer    row1.customer
         └─ line        loop
            ├─ @product row1.product
            └─ qty      row1.qty

Une seule ligne sort, avec ce document :One single row goes out, with this document:

<?xml version="1.0" encoding="UTF-8"?>

<orders>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P1">
      <qty>2</qty>
    </line>
    <line product="P2">
      <qty>1</qty>
    </line>
  </order>
  <order id="A-2">
    <customer>Grace</customer>
    <line product="P3">
      <qty>5</qty>
    </line>
  </order>
</orders>

line est créé pour chaque ligne ; order, groupe, n'est recréé que quand @id ou customer change. Trois variantes du même job : line is created for each row; order, a group, is only created again when @id or customer changes. Three variants of the same job:

Sans All in oneWithout All in one

Un document par ligne (tLogRow simple) :One document per row (basic tLogRow):

<?xml version="1.0" encoding="UTF-8"?>
<orders><order id="A-1"><customer>Ada</customer><line product="P1"><qty>2</qty></line></order></orders>
<?xml version="1.0" encoding="UTF-8"?>
<orders><order id="A-1"><customer>Ada</customer><line product="P2"><qty>1</qty></line></order></orders>
<?xml version="1.0" encoding="UTF-8"?>
<orders><order id="A-2"><customer>Grace</customer><line product="P3"><qty>5</qty></line></order></orders>

Sans groupeWithout group

Toutes les lignes sous le premier order, qui garde les valeurs de la première ligne :All the lines under the first order, which keeps the values of the first row:

<?xml version="1.0" encoding="UTF-8"?>

<orders>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P1">
      <qty>2</qty>
    </line>
    <line product="P2">
      <qty>1</qty>
    </line>
    <line product="P3">
      <qty>5</qty>
    </line>
  </order>
</orders>

Lignes non triéesUnsorted rows

Ordre A-1/P1, A-2/P3, A-1/P2 : le groupe ne réunit que des lignes qui se suivent.Order A-1/P1, A-2/P3, A-1/P2: the group only brings together rows that follow each other.

<?xml version="1.0" encoding="UTF-8"?>

<orders>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P1">
      <qty>2</qty>
    </line>
  </order>
  <order id="A-2">
    <customer>Grace</customer>
    <line product="P3">
      <qty>5</qty>
    </line>
  </order>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P2">
      <qty>1</qty>
    </line>
  </order>
</orders>

3. Un document par commande : agrégat3. One document per order: aggregate

Mêmes lignes. Sortie out1 : order_id (row1.order_id), customer (row1.customer) et doc, dont l'arbre est order (@id, puis line en boucle avec @product et qty). As aggregate element sur order/@id, All in one à false. Le tJavaRow affiche aussi les deux colonnes : Same rows. out1 output: order_id (row1.order_id), customer (row1.customer) and doc, whose tree is order (@id, then line as loop with @product and qty). As aggregate element on order/@id, All in one set to false. The tJavaRow also prints the two columns:

order_id = A-1, customer = Ada
<?xml version="1.0" encoding="UTF-8"?>

<order id="A-1">
  <line product="P1">
    <qty>2</qty>
  </line>
  <line product="P2">
    <qty>1</qty>
  </line>
</order>

order_id = A-2, customer = Grace
<?xml version="1.0" encoding="UTF-8"?>

<order id="A-2">
  <line product="P3">
    <qty>5</qty>
  </line>
</order>

Une ligne de sortie par valeur de l'agrégat ; comme le groupe, il ne réunit que des lignes qui se suivent. D'après le modèle, les colonnes simples prennent les valeurs de la dernière ligne du document. One output row per value of the aggregate; like the group, it only brings together rows that follow each other. Per the template, the simple columns take the values of the last row of the document.

4. Éléments vides4. Empty elements

Exemple 2, avec les lignes Ada, A-1, P1, 2 puis null, A-9, P9, null. Create empty element à true (défaut) : Example 2, with the rows Ada, A-1, P1, 2 then null, A-9, P9, null. Create empty element set to true (default):

<?xml version="1.0" encoding="UTF-8"?>

<orders>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P1">
      <qty>2</qty>
    </line>
  </order>
  <order id="A-9">
    <customer/>
    <line product="P9">
      <qty/>
    </line>
  </order>
</orders>

À false :Set to false:

<?xml version="1.0" encoding="UTF-8"?>

<orders>
  <order id="A-1">
    <customer>Ada</customer>
    <line product="P1">
      <qty>2</qty>
    </line>
  </order>
  <order id="A-9">
    <line product="P9"/>
  </order>
</orders>

Une valeur null donne un élément vide, retiré à false ; line reste, il porte un attribut. A null value gives an empty element, removed when false; line stays, it carries an attribute.

5. Lookup joint sur un nœud du document5. Lookup joined on a node of the document

row1 (Main) out1 (Main) row2 (Lookup) tFileInputXML_1 tXMLMap_1 tLogRow_1 tFixedFlowInput_1

Entrée principale : orders.xml, comme l'exemple 1. Lookup row2 : lignes P1, Pen, 1.5 et P2, Ink, 4.2 (code, label, price Double), sans P3. Clé : la colonne code du lookup reçoit l'expression [row1.doc:/orders/order/line/@product], Match Model Unique match. Sortie out1 : order_id, product, label (row2.label), price (row2.price). Left Outer Join : Main input: orders.xml, as in example 1. Lookup row2: rows P1, Pen, 1.5 and P2, Ink, 4.2 (code, label, price Double), without P3. Key: the code column of the lookup gets the expression [row1.doc:/orders/order/line/@product], Match Model Unique match. out1 output: order_id, product, label (row2.label), price (row2.price). Left Outer Join:

.--------+-------+-----+-----.
|         tLogRow_1          |
|=-------+-------+-----+----=|
|order_id|product|label|price|
|=-------+-------+-----+----=|
|A-1     |P1     |Pen  |1.5  |
|A-1     |P2     |Ink  |4.2  |
|A-2     |P3     |null |null |
'--------+-------+-----+-----'

Inner Join : P3 disparaît.Inner Join: P3 disappears.

.--------+-------+-----+-----.
|         tLogRow_1          |
|=-------+-------+-----+----=|
|order_id|product|label|price|
|=-------+-------+-----+----=|
|A-1     |P1     |Pen  |1.5  |
|A-1     |P2     |Ink  |4.2  |
'--------+-------+-----+-----'

Inner Join et une seconde sortie missing (order_id, product) en Catch Lookup Inner Join Reject vers tLogRow_2 :Inner Join and a second output missing (order_id, product) as Catch Lookup Inner Join Reject to tLogRow_2:

.--------+-------.
|   tLogRow_2    |
|=-------+------=|
|order_id|product|
|=-------+------=|
|A-2     |P3     |
'--------+-------'

Avec la seconde sortie, tLogRow_1 affiche les deux mêmes lignes que la jointure interne seule. With the second output, tLogRow_1 prints the same two rows as the inner join alone.

6. Modes de correspondance6. Match models

Même job, le lookup ayant P1 deux fois : P1, Pen, 1.5, P1, Pen (blue), 1.6, P2, Ink, 4.2. Left Outer Join. Same job, the lookup having P1 twice: P1, Pen, 1.5, P1, Pen (blue), 1.6, P2, Ink, 4.2. Left Outer Join.

Unique match : la dernière ligne chargée.Unique match: the last loaded row.

.--------+-------+----------+-----.
|            tLogRow_1            |
|=-------+-------+----------+----=|
|order_id|product|label     |price|
|=-------+-------+----------+----=|
|A-1     |P1     |Pen (blue)|1.6  |
|A-1     |P2     |Ink       |4.2  |
|A-2     |P3     |null      |null |
'--------+-------+----------+-----'

First match : la première.First match: the first one.

.--------+-------+-----+-----.
|         tLogRow_1          |
|=-------+-------+-----+----=|
|order_id|product|label|price|
|=-------+-------+-----+----=|
|A-1     |P1     |Pen  |1.5  |
|A-1     |P2     |Ink  |4.2  |
|A-2     |P3     |null |null |
'--------+-------+-----+-----'

All matches : une ligne par correspondance.All matches: one row per match.

.--------+-------+----------+-----.
|            tLogRow_1            |
|=-------+-------+----------+----=|
|order_id|product|label     |price|
|=-------+-------+----------+----=|
|A-1     |P1     |Pen       |1.5  |
|A-1     |P1     |Pen (blue)|1.6  |
|A-1     |P2     |Ink       |4.2  |
|A-2     |P3     |null      |null |
'--------+-------+----------+-----'

Le lookup de l'exemple 5 (sans doublon), sa clé saisie mais laissé en All rows, ce que donne Talaxie 9.0.6 quand on n'y change pas le Match Model : la clé est ignorée, chaque ligne est jointe à tout le lookup. The lookup of example 5 (without duplicate), its key typed but left in All rows, which is what Talaxie 9.0.6 gives when the Match Model is not changed: the key is ignored, each row is joined to the whole lookup.

.--------+-------+-----+-----.
|         tLogRow_1          |
|=-------+-------+-----+----=|
|order_id|product|label|price|
|=-------+-------+-----+----=|
|A-1     |P1     |Pen  |1.5  |
|A-1     |P1     |Ink  |4.2  |
|A-1     |P2     |Pen  |1.5  |
|A-1     |P2     |Ink  |4.2  |
|A-2     |P3     |Pen  |1.5  |
|A-2     |P3     |Ink  |4.2  |
'--------+-------+-----+-----'

7. Lookup sur un document7. Lookup on a document

row1 (Main) out1 (Main) row2 (Lookup) tFixedFlowInput_1 tXMLMap_1 tLogRow_1 tFileInputXML_1

Lookup : le fichier catalog.xml, en colonne Document :Lookup: the catalog.xml file, as a Document column:

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <product code="P1" price="1.50"><label>Pen</label></product>
  <product code="P2" price="4.20"><label>Ink</label></product>
</catalog>

Arbre row2 : boucle sur product, @price en BigDecimal ; la clé est le nœud @code, d'expression row1.code. Unique match. Entrée principale : lignes P2, 3, P9, 1, P1, 2 (code, qty). Sortie : row1.code, row1.qty, [row2.doc:/catalog/product/label], [row2.doc:/catalog/product/@price]. row2 tree: loop on product, @price as BigDecimal; the key is the @code node, with expression row1.code. Unique match. Main input: rows P2, 3, P9, 1, P1, 2 (code, qty). Output: row1.code, row1.qty, [row2.doc:/catalog/product/label], [row2.doc:/catalog/product/@price].

Inner Join :Inner Join:

.----+---+-----+-----.
|     tLogRow_1      |
|=---+---+-----+----=|
|code|qty|label|price|
|=---+---+-----+----=|
|P2  |3  |Ink  |4.20 |
|P1  |2  |Pen  |1.50 |
'----+---+-----+-----'

Left Outer Join : P9, sans correspondance, reçoit les valeurs de la ligne précédente.Left Outer Join: P9, without match, gets the values of the previous row.

.----+---+-----+-----.
|     tLogRow_1      |
|=---+---+-----+----=|
|code|qty|label|price|
|=---+---+-----+----=|
|P2  |3  |Ink  |4.20 |
|P9  |1  |Ink  |4.20 |
|P1  |2  |Pen  |1.50 |
'----+---+-----+-----'

Défaut du modèle de Talaxie (tXMLMap_lookup.inc.javajet) : quand l'entrée principale n'a pas de colonne Document, les valeurs lues dans le document du lookup ne sont pas effacées d'une ligne à l'autre ; le modèle à deux parties (tXMLMapOut_main.inc.javajet) les efface. Placée en premier, la ligne P9 reçoit bien null. En jointure externe sur un document, vérifiez la correspondance dans l'expression, ou passez par une jointure interne et une sortie de rejet. Defect of the Talaxie template (tXMLMap_lookup.inc.javajet): when the main input has no Document column, the values read in the lookup document are not cleared from one row to the next; the two-part template (tXMLMapOut_main.inc.javajet) clears them. Put first, the P9 row does get null. In an outer join on a document, check the match in the expression, or use an inner join and a reject output.

8. Filtre et rejet de sortie8. Output filter and reject

orders.xml, deux sorties de mêmes colonnes (order_id, product, qty). big, vers tLogRow_1, filtrée par [row1.doc:/orders/order/line/qty] >= 2 ; others, vers tLogRow_2, en Catch Output Reject : orders.xml, two outputs with the same columns (order_id, product, qty). big, to tLogRow_1, filtered by [row1.doc:/orders/order/line/qty] >= 2; others, to tLogRow_2, as Catch Output Reject:

.--------+-------+---.
|     tLogRow_1      |
|=-------+-------+--=|
|order_id|product|qty|
|=-------+-------+--=|
|A-1     |P1     |2  |
|A-2     |P3     |5  |
'--------+-------+---'

.--------+-------+---.
|     tLogRow_2      |
|=-------+-------+--=|
|order_id|product|qty|
|=-------+-------+--=|
|A-1     |P2     |1  |
'--------+-------+---'

9. Boucle facultative9. Optional loop

Fichier orders2.xml : A-1 a une ligne P1, A-3 (Linus) n'en a pas. Le tFileInputXML boucle sur "/orders/order" : un document par commande. Arbre importé de <order id=""><customer/><line product=""><qty/></line></order>, boucle sur line. Boucle normale : orders2.xml file: A-1 has one line P1, A-3 (Linus) has none. The tFileInputXML loops on "/orders/order": one document per order. Tree imported from <order id=""><customer/><line product=""><qty/></line></order>, loop on line. Normal loop:

.--------+--------+-------+---.
|          tLogRow_1          |
|=-------+--------+-------+--=|
|order_id|customer|product|qty|
|=-------+--------+-------+--=|
|A-1     |Ada     |P1     |2  |
'--------+--------+-------+---'

As optional loop sur line :As optional loop on line:

.--------+--------+-------+---.
|          tLogRow_1          |
|=-------+--------+-------+--=|
|order_id|customer|product|qty|
|=-------+--------+-------+--=|
|A-1     |Ada     |P1     |2  |
|A-3     |Linus   |null   |null|
'--------+--------+-------+---'

La règle porte sur tout le document : avec le fichier entier dans un seul document, A-3 serait perdu même en boucle facultative, puisque d'autres line existent. Le décalage du null vient du tLogRow. The rule applies to the whole document: with the whole file in a single document, A-3 would be lost even with an optional loop, since other line elements exist. The misaligned null comes from the tLogRow.

10. Deux boucles, deux sorties10. Two loops, two outputs

Fichier multi.xml :multi.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<orders>
  <order id="A-1">
    <line product="P1"/>
    <line product="P2"/>
    <note>Leave at the door</note>
    <note>Fragile</note>
  </order>
  <order id="A-2">
    <line product="P3"/>
  </order>
</orders>

As loop element sur line puis sur note : l'entrée a deux boucles. Sortie lines (@id, line/@product), boucle source line ; sortie notes (@id, note), boucle source note, choisies par Configure source loops. As loop element on line then on note: the input has two loops. lines output (@id, line/@product), source loop line; notes output (@id, note), source loop note, chosen through Configure source loops.

.--------+-------.
|   tLogRow_1    |
|=-------+------=|
|order_id|product|
|=-------+------=|
|A-1     |P1     |
|A-1     |P2     |
|A-2     |P3     |
'--------+-------'

.--------+-----------------.
|        tLogRow_2         |
|=-------+----------------=|
|order_id|note             |
|=-------+----------------=|
|A-1     |Leave at the door|
|A-1     |Fragile          |
'--------+-----------------'

ErreursErrors

Une valeur qui ne se convertit pasA value that does not convert

Fichier bad.xml : la commande A-1 a deux lignes, <qty>2</qty> et <qty>two</qty> ; arbre de l'exemple 1 (qty en Integer), sortie product, qty. Le job s'arrête (code 1) ; le nom du job est remplacé par MyJob et la pile d'appels abrégée : bad.xml file: order A-1 has two lines, <qty>2</qty> and <qty>two</qty>; tree of example 1 (qty as Integer), output product, qty. The job stops (exit code 1); the job name is replaced by MyJob and the stack trace shortened:

Exception in component tXMLMap_1_TXMLMAP_OUT (MyJob)
java.lang.NumberFormatException: For input string: "two"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
	at java.base/java.lang.Integer.parseInt(Integer.java:662)
	at java.base/java.lang.Integer.parseInt(Integer.java:778)
	at routines.system.ParserUtils.parseTo_int(ParserUtils.java:122)
	at routines.system.ParserUtils.parseTo_Integer(ParserUtils.java:137)
	…
  • Rien n'est affiché, pas même la ligne P1, lue avant l'erreur : avec un document en entrée, les lignes attendent la fin de l'entrée (voir l'exécution). Nothing is printed, not even the P1 row, read before the error: with a document as input, the rows wait for the end of the input (see the execution).
  • Même résultat avec DIE_ON_ERROR à false et une sortie ErrorReject (errorMessage, errorStackTrace) reliée à un tLogRow, comme le Studio la créait avant la version 5.0 : le code généré ne lit pas ce réglage, la sortie ne reçoit rien et le job s'arrête sur la même exception. Pour garder le job en vie, rendez l'expression sûre (test avant conversion) ou laissez le nœud en String et convertissez plus loin. Same result with DIE_ON_ERROR set to false and an ErrorReject output (errorMessage, errorStackTrace) connected to a tLogRow, as the Studio created it before version 5.0: the generated code does not read this setting, the output gets nothing and the job stops on the same exception. To keep the job alive, make the expression safe (test before converting) or leave the node as String and convert further on.

Conseils et limitesTips and limits

Triez avant de grouperSort before grouping

Groupe et agrégat ne réunissent que des lignes consécutives : des lignes d'une même commande séparées par une autre donnent deux éléments order. Triez le flux sur les colonnes du groupe avant le tXMLMap. Group and aggregate only bring together consecutive rows: rows of the same order separated by another one give two order elements. Sort the flow on the group columns before the tXMLMap.

Un groupe pour chaque niveau répétéA group for each repeated level

Sans groupe, les éléments au-dessus de la boucle ne sont créés qu'une fois : toutes les lignes tombent sous le premier, avec ses valeurs (exemple 2). Et sans All in one, chaque ligne donne son propre document. Without group, the elements above the loop are created only once: all the rows fall under the first one, with its values (example 2). And without All in one, each row gives its own document.

MémoireMemory

Un document en entrée est chargé en entier, et ses lignes de sortie sont gardées jusqu'à la fin ; All in one garde aussi tout le document produit. Pour un gros fichier, faites lire au tFileInputXML un document par élément (boucle "/orders/order") plutôt que le fichier entier. An input document is loaded entirely, and its output rows are kept until the end; All in one also keeps the whole produced document. For a large file, have the tFileInputXML read one document per element (loop "/orders/order") rather than the whole file.

Une clé, un modeOne key, one mode

Une clé sans Match Model adapté ne joint rien : en All rows, elle est ignorée. Vérifiez le mode après avoir saisi la clé, surtout dans un job modifié avec Talaxie 9.0.6 (voir ci-dessus). A key without a suitable Match Model joins nothing: in All rows, it is ignored. Check the mode after typing the key, especially in a job edited with Talaxie 9.0.6 (see above).

Voir aussiSee also