xsl-list
[Top] [All Lists]

[xsl] creating elements from semicolon delimited text

2010-03-03 14:08:46
I could use some help manipulating a paragraph of text delimited by a semicolon 
into a series of step elements. I need to take note/paragraph and create a 
series of steps. I'm using XSLT 2.0.

This:


<note>
        <para>Follow-on maintenance: Stuff to do; 
More stuff do to; And then even more stuff to do.</para>
</note>

To this:

<followon.maintsk>
        <title>FOLLOW ON MAINTENANCE</title>
        <step1><para>Stuff to do.</para></step1>
        <step1><para>More stuff to do.</para></step1>
        <step1><para>And then even more stuff to do.</para><step1>
</followon.maintsk>

I've started with this. However this only captures the first item. And I 
realized later would NOT capture the last item, because it ends with a period, 
not a semicolon. One note, this is just a small part of much larger transform, 
hence the "mode."



<xsl:template match="note" mode="followon">
  <xsl:if test="(child::para) and (contains(child::para,'Follow-on'))">
    <followon.maintsk>
         <title><xsl:text>FOLLOW ON MAINTENANCE</xsl:text></title>
            <xsl:variable name="noFollow">
                <xsl:value-of select="substring-after(.,':')"/>
          </xsl:variable>
          <xsl:variable name="steptext">
             <xsl:value-of select="substring-before($noFollow,';')"/>
           </xsl:variable>
                <xsl:for-each select="$steptext">       
                <step1>
                  <para>
                        <xsl:value-of select="$steptext"/><xsl:text>.</xsl:text>
                </para>
                </step1>
                </xsl:for-each>
    </followon.maintsk>
   </xsl:if>
</xsl:template>



Charles Flanders


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>