xml - XSLT - split string using specific character -


i have xml this,

<doc>     <para>a brief 23 spell* of hea#vy rain* forc^%ed early+ lunch* 98@with nine</para> </doc> 

i need break text string each * present in text..

so expected output should be,

<doc>     <para>a brief 23 spell</para>     <para>of hea#vy rain</para>     <para>forc^%ed early+ lunch</para>     <para>98@with nine</para> </doc> 

i've written following logic that,

i have written following xslt that,

<xsl:template match="para">          <xsl:analyze-string select="text()" regex="[a-za-z0-9_.]\*">             <xsl:matching-substring>                 <para>                     <xsl:value-of select="."/>                 </para>             </xsl:matching-substring>         </xsl:analyze-string>     </xsl:template> 

can suggest me how can using xslt?

personal preference go function tokenize():

summary: function breaks $input string sequence of strings, treating substring matches $pattern separator. separators not returned.

<xsl:template match="para">    <xsl:for-each select="tokenize(.,'\*')">     <para>       <xsl:sequence select="."/>     </para>   </xsl:for-each> </xsl:template> 

results in:

<para>a brief 23 spell</para> <para> of hea#vy rain</para> <para> forc^%ed early+ lunch</para> <para> 98@with nine</para> 

to strip leading , trailing whitespaces use:

<xsl:sequence select="normalize-space(.)"/> 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -