I have a requirement where I have to concatenate each of the <troubleticketalarm> details into a one string per alarm, then map it to Description field in my xslt.
Description is of type array in my xslt.
Here is my xml,
<ticketDetails>
<alarms>
<troubleticketalarm>
<alarmId>3117</alarmId>
<alarmName>OSS</alarmName>
<amo>amo</amo>
<alarmedEquipment>alarmedEquipment</alarmedEquipment>
<severity>1</severity>
<specificProblem>specificProblem</specificProblem>
<probableCause>probableCause</probableCause>
<activationDate>2015-03-17T17:33:04</activationDate>
<associationDate>2015-03-17T17:33:04</associationDate>
<clearDate>2015-03-17T17:33:04</clearDate>
</troubleticketalarm>
<troubleticketalarm>
<alarmId>3118</alarmId>
<alarmName>OSS123</alarmName>
<activationDate>2015-03-17T17:33:0405:30</activationDate>
<asociationDate>2015-03-17T17:33:0405:30</asociationDate>
<clearDate></clearDate>
</troubleticketalarm>
<troubleticketalarm>
<alarmId>3119</alarmId>
<alarmName>OSS124</alarmName>
<amo>amo</amo>
<alarmedEquipment>alarmedEquipment</alarmedEquipment>
<severity>1</severity>
<activationDate>2015-03-17T17:33:0405:30</activationDate>
<asociationDate>2015-03-17T17:33:0405:30</asociationDate>
<clearDate></clearDate>
</troubleticketalarm>
</alarms>
</ticketDetails>
Here is the part of xslt :
<ns:Description type="Array">
<ns:Description type="String" mandatory="" readonly=""></ns:Description>
</ns:Description>
What I want is to concatenate values for separated by '|' and map it to the ns:Description for each concatenated value of
Concatenated string looks something like this
3117|OSS|amo|alarmedEquipment|1|specificProblem|probableCause|2015-03-17T17:33:04+05:30|2015-03-17T17:33:04+05:30|2015-03-17T17:33:04+05:30
3118|OSS123|||||||2015-03-17T17:33:04+05:30|
3119|OSS124|amo|alarmedEquipment|1|||2015-03-17T17:33:04+05:30|2015-03-17T17:33:04+05:30|
These 3 strings should be added to Description[0],Description[1],Description[1].
There could be multiple <troubleticketalarm> tags in xml so the xslt Description should be dynamic.
How do I achieve this? Please let me know if question is not clear.
Edit
My XSLT file looks something like
<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match='/'>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://schemas.hp.com/SM/7" xmlns:com="http://schemas.hp.com/SM/7/Common" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
<soapenv:Header/>
<soapenv:Body>
<ns:CloseIncidentRequest attachmentInfo="" attachmentData="" ignoreEmptyElements="true" updateconstraint="-1">
<ns:model query="">
<ns:keys query="" updatecounter="1">
<ns:IncidentID type="String" mandatory="" readonly=""></ns:IncidentID>
</ns:keys>
<ns:instance query="" uniquequery="" recordid="" updatecounter="1">
<ns:IncidentID type="String" mandatory="" readonly=""></ns:IncidentID>
<ns:Description type="Array">
<ns:Description type="String" mandatory="" readonly=""></ns:Description>
</ns:Description>
......
......
</ns:instance>
</ns:model>
</ns:CloseIncidentRequest>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
<ns:Description type="Array">is not XSLT, it might be some custom format to describe data types but it certainly is not something defined in the XSLT 1.0 or 2.0 or 3.0 language. You seem to want to map the elements to a bar|delimited list but it is not clear which item defines the columns in that list. A simple approach would be<xsl:template match="troubleticketalarm"><xsl:value-of select="*" separator="|"/></xsl:template>to create the list but the lists will then have different lengths depending on the number of child elements.