[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: creating elements from semicolon delimited text

Subject: Re: creating elements from semicolon delimited text
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Wed, 3 Mar 2010 21:41:23 +0100
Re:  creating elements from semicolon delimited text
Am 03.03.2010 um 21:07 schrieb Flanders, Charles E (US SSA):

> 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.

The XSL does not take advantage of XSLT 2.0. How about something like this for
the core routine with the tokenize() function:

<xsl:template match="note[contains(para, 'Follow-on')]">
  <followon.maintsk>
    <xsl:for-each select="tokenize(para, '[:;]')">
      <xsl:choose>
        <xsl:when test="position() = 1">
          <title><xsl:value-of select="."/></title>
        </xsl:when>
        <xsl:otherwise>
          <step1><para>
            <xsl:value-of select="."/>
          </para></step1>
      	</xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </followon.maintsk>
</xsl:template>

Of course, the changes in punctuation are not yet handled, but using replace()
this would not be too difficult. I guess.

- Michael


> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.