I have my source XML like below
<contents>
<content>AuthorInformation</content>
<content>PersonInformation</content>
<content>PersonPersonalInformation</content>
<content>GurdianDetails</content>
</contents>
I would like to transform above XML into
<contents>
<content>Author Information</content>
<content>Person Information</content>
<content>Person Personal Information</content>
<content>Gurdian Details</content>
</contents>
wherever in source xml file content element data is having upper case letter I would like to prefix space inbetween. Can I have the XSLT 2.0 sample how I can achieve this.
Use a template like this:
<xsl:template match="text()">
<xsl:value-of select="replace(., '([a-z])([A-Z])', '$1 $2')"/>
</xsl:template>
This generically performs the rule for all text content in the input. You could easily make this more specific (if there are other elements that you don't want to translate). The replace
function is the key point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With