I have an XML in which one of the element has list of comments concatenated. I need to format that and map it to a target xml node.
Input XML element value:
<Comment> TJ-TACO JOHNS Dented Cans - RFS# D2804 and D01441)Inspect entire load for dented cans.2)Pay close attention to hidden damage of dentedcans, specially towards the bottom cornersof pallet.3)If dented cans found,take pictures, rejectimplicated product & document in COMMENTS on PO.4)Report issue to buyer to notify vendor.5)Report issue to FSQA to notify Taco Johns QA. </Comment>
Expected Output format:
<Output>
TJ-TACO JOHNS Dented Cans - RFS# D2804 and D0144
1)Inspect entire load for dented cans.
2)Pay close attention to hidden damage of dentedcans, specially towards the bottom cornersof pallet.
3)If dented cans found,take pictures, reject implicated product & document in COMMENTS on PO.
4)Report issue to buyer to notify vendor.
5)Report issue to FSQA to notify Taco Johns QA.
</Output>
How do I achieve this in xslt?
Try this:
<xsl:template match="Comment">
<Output>
<xsl:analyze-string select="." regex="[0-9]\)">
<xsl:matching-substring>
<xsl:text>
</xsl:text><xsl:value-of select="regex-group(0)"></xsl:value-of>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."></xsl:value-of>
</xsl:non-matching-substring>
</xsl:analyze-string>
</Output>
</xsl:template>
you can check script at http://xsltransform.hikmatu.com/nbUY4ko
But there is no extra information in your question, so this is worked only for single digit number.