|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] creating elements from semicolon delimited text
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








