| 
 
Subject: Re: [xsl] unparsed-text and analyze-string From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 21 Jan 2008 17:27:16 -0500  | 
My question: how do I design a single sheet that will iterate through various regex expressions.
I would like to avoid a situation where I am piping the output of one stylesheet through another if at all possible. Also, is it possible to use unparsed-text with text that already contains some elements?
My goal is to use XSLT in the place of a manual markup process if at all possible.
Any hints would be most appreciated.
t:\ftemp>type terry.txt 1 XSLT means-- (G6U1S01) A extensible stylesheet language transformations. B extremely sly lexical transformations. C XML stylesheet language transformations. D all the above
        2       Stem
                display sentence (optional)
                stem part 2 (optional)  (G6U1S01)
        A       answer choice
        B       answer choice
        C       answer choice
        D       answer choicet:\ftemp>type terry.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:param name="input-uri"/> <xsl:output indent="yes"/>
<xsl:template name="main">
  <xsl:variable name="in"
              select="unparsed-text($input-uri, 'UTF-8')"/><xsl:analyze-string select="$in"
  regex="\((G[3-8]U[1-7]S\d\d?)\)
|\t([A-D])\t(.*)
">
  <xsl:matching-substring>
    <xsl:choose>
      <xsl:when test="matches(.,'\(G')">
        <xsl:element name="notes">
          <xsl:value-of select="regex-group(1)"/>
        </xsl:element><xsl:text>
</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="choiceLetter" select="regex-group(2)"/>
        <xsl:variable name="choiceLower" select="lower-case($choiceLetter)"/>
        <xsl:element name="choice-{$choiceLower}">
          <xsl:value-of select="regex-group(3)"/>
        </xsl:element><xsl:text>
</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:matching-substring>
  <xsl:non-matching-substring>
     <xsl:value-of select="."/>
  </xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>        2       Stem
                display sentence (optional)
                stem part 2 (optional)  <notes>G6U1S01</notes>
<choice-a>answer choice</choice-a>
<choice-b>answer choice</choice-b>
<choice-c>answer choice</choice-c>
<choice-d>answer choice</choice-d>-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] unparsed-text and analyze-str, Terry Ofner | Thread | Re: [xsl] unparsed-text and analyze, Terry Ofner | 
| [xsl] List History [was: The identi, B Tommie Usdin | Date | Re: [xsl] The identity transform an, David Carlisle | 
| Month |