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

Re: unparsed-text and analyze-string

Subject: Re: unparsed-text and analyze-string
From: Terry Ofner <tofner@xxxxxxxxxxx>
Date: Wed, 23 Jan 2008 14:52:10 -0500
Re:  unparsed-text and analyze-string
Thank you, Ken, for your quick response to my query. Your solution
works like a charm. Unfortunately, I will not be able to use it on
this particular project. My "unparsed" text will contain some element
structures such as <u>underlined</u>, <b>bold,</b> and <i>italicized</
i> words and phrases.

It appears that both the function replace() and the element
xsl:analyze-string strip such elements from the selected text. Is
there any way to get around this?

Note the <i> element in choice B of the second question in this this
import xml:

<document>
<part>
    <par class="stem_mc">&#9;19&#9;Choose the word that is a
homophone for <inline style="font-style: italic;">Ill.</inline> </par>
    <par class="choice-a">&#9;A&#9;ill</par>
    <par class="choice-b">&#9;B&#9;aisle</par>
    <par class="choice-c">&#9;C&#9;I will</par>
    <par class="choice-d">&#9;D&#9;idle</par>
    <par class="answer">B</par>
    <par class="g_code">G5U1S6</par>

    <par class="stem_mc">&#9;20&#9;Read the sentence. Then choose
the word that fits in the blank.</par>
    <par class="display">The man needed some ____ to get into the
building.</par>
    <par class="choice-a">&#9;A&#9;assist</par>
    <par class="choice-b">&#9;B&#9;<i>unessisted</i></par>
    <par class="choice-c">&#9;C&#9;assisting</par>
    <par class="choice-d">&#9;D&#9;assistance</par>
    <par class="answer">D</par>
    <par class="g_code">G5U1S2</par>
  </part>
</document>

This stylesheet strips the <i> element while it replaces the
&#9;A&#9; structures from the choices. (There is probably a more
elegant way to make these changes. All suggestions welcome!)


<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!--<xsl:strip-space elements="*"/>-->

	<!--identity template-->
<xsl:template match="@*|node()">
	<xsl:copy>
		<xsl:apply-templates select="@*|node()"/>
	</xsl:copy>
</xsl:template>

<!--other templates removed -->


<xsl:template match='par[@class="choice-a"]'> <xsl:element name="choice-a"> <xsl:copy-of select="replace(.,'\tA\t','')"/> </xsl:element> </xsl:template>

<xsl:template match='par[@class="choice-b"]'>
<xsl:element name="choice-b">
          <xsl:copy-of select="replace(.,'\tB\t','')"/>
          </xsl:element>
</xsl:template>

<xsl:template match='par[@class="choice-c"]'>
<xsl:element name="choice-c">
          <xsl:copy-of select="replace(.,'\tC\t','')"/>
          </xsl:element>
</xsl:template>

<xsl:template match='par[@class="choice-d"]'>
<xsl:element name="choice-d">
          <xsl:copy-of select="replace(.,'\tD\t','')"/>
          </xsl:element>
</xsl:template>
</xsl:stylesheet>


Here is the output. No <i> element.



<question type="mc"> 19 Choose the word that is a homophone for Ill. </question> <choice-a>ill</choice-a> <choice-b>aisle</choice-b> <choice-c>I will</choice-c> <choice-d>idle</choice-d> <answer>B</answer> <par class="g_code">G5U1S6</par>

    <question type="mc">        20      Read the sentence. Then
choose the word that fits in the blank.</question>
    <par class="display">The man needed some ____ to get into the
building.</par>
    <choice-a>assist</choice-a>
    <choice-b>unessisted</choice-b>
    <choice-c>assisting</choice-c>
    <choice-d>assistance</choice-d>
    <answer>D</answer>
    <par class="g_code">G5U1S2</par>
  </part>
</document>

In case you are wondering, I am trying to develop a workflow that
starts with Microsoft Word documents. My current experiment is to
export styled word documents to rtf which are then converted using
UpCast. That gives me the current input document. As I noted before,
I am trying to avoid marking up this copy manually. I am not sure I
will succeed, as there are more hurdles yet to jump.

Terry

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.