Faire mapper deux éléments via une clé
Bonjour à tous !!
Je suis tout nouveau dans le monde de l'XSL, désolé par avance si ma question vous paraît triviale, mais j'avoue être un peu perdu.
Et je n'ai pas réussi à trouver la réponse sur le forum.
Voici mon XML
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| <?xml version="1.0" encoding="UTF-8"?>
<ex:exchange
xmlns:ns1="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.CustomPollerGlobalConfig"
xmlns:ex="http://openview.hp.com/xmlns/nnm/configExchange/1"
xmlns:ns8="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.report.ReportGroup"
xmlns:ns9="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.report.ReportCollection"
xmlns:ns4="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.Variable"
xmlns:ns5="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.CPCountBasedThresholdSetting"
xmlns:ns3="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.Collection"
xmlns:ns6="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.CPTimeBasedThresholdSetting"
xmlns:ns7="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.Policy" xmlns:ns2="http://openview.hp.com/xmlns/nnm/export?type=com.hp.ov.nms.custompoller.model.config.ComparisonMap">
<ex:header>
<ex:date>2018-02-26T15:44:25.198Z</ex:date>
</ex:header>
<ex:area>custpoll</ex:area>
<ex:items>
<ns1:customPollerGlobalConfig>
<ns1:customPollerPollingEnabled>true</ns1:customPollerPollingEnabled>
<ns1:uuid>3a50dcbb-6ac5-4b37-aaf1-78085f829ea1</ns1:uuid>
</ns1:customPollerGlobalConfig>
<ns3:collection>
<ns3:affectNodeStatus>false</ns3:affectNodeStatus>
<ns3:collectionType>INSTANCE</ns3:collectionType>
<ns3:compressExport>false</ns3:compressExport>
<ns3:exportCollection>false</ns3:exportCollection>
<ns3:generateIncident>false</ns3:generateIncident>
<ns3:incidentSource>CUSTOM_POLLED_INSTANCE</ns3:incidentSource>
<ns3:name>test</ns3:name>
<ns3:policies/>
<ns3:uuid>3280bcac-1bd6-4ac0-9522-dfe8a0e444dd</ns3:uuid>
<ns3:variables>
<ns3:item>
<ex:ref>
<ex:key>fb7d26d4-dfba-411d-8124-103082bf7c6e</ex:key>
<ex:type>com.hp.ov.nms.custompoller.model.config.Variable</ex:type>
</ex:ref>
</ns3:item>
</ns3:variables>
</ns3:collection>
<ns4:variable>
<ns4:collection>
<ex:ref>
<ex:key>3280bcac-1bd6-4ac0-9522-dfe8a0e444dd</ex:key>
<ex:type>com.hp.ov.nms.custompoller.model.config.Collection</ex:type>
</ex:ref>
</ns4:collection>
<ns4:expression>
<ex:ref>
<ex:key>com.hp.nms.mibexpr.ciscomemorypoolutil</ex:key>
<ex:type>com.hp.ov.nms.custompoller.model.config.MibExpression</ex:type>
</ex:ref>
</ns4:expression>
<ns4:maps/>
<ns4:name>coincoin</ns4:name>
<ns4:reportDataType>UNSET</ns4:reportDataType>
<ns4:thresholdSettings/>
<ns4:uuid>fb7d26d4-dfba-411d-8124-103082bf7c6e</ns4:uuid>
</ns4:variable>
</ex:items>
</ex:exchange> |
Je souhaiterais créer un fichier CSV à partir de cet XML qui donnerait ça :
Code:
coincoin-test;false
C'est à dire, la valeur de ns4:name, mappée avec la valeur ns3:name en prenant comme clé ns4:uuid (pour ns4:variable) et ns3:variables/ns3:item/ex:ref/ex:key (pour ns3:collection).
Évidemment, il peut y avoir x collections et x variables.
Le false correspond à la valeur de ns3:generateIncident.
Sauriez-vous m'aider à écrire le XSLT ?