Adding Prefix in XSLT 3

26 views Asked by At

How to add a prefix (7HH) if the value doesn't start with '7HH'?

Source XML

<DATA>
   <Name>90078</Name>
</DATA>

Expected output

<DATA>
   <Name>7HH90078</Name>
</DATA>
1

There are 1 answers

0
Martin Honnen On BEST ANSWER

Well

<xsl:template match="DATA/Name[not(starts-with(., '7HH'))]">
  <xsl:copy expand-text="yes">7HH{.}</xsl:copy>
</xsl:template>

plus <xsl:mode on-no-match="shallow-copy"/> to handle the rest should suffice if you really use an XSLT 3 processor.