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

Re: numbering output and other newbie issues

Subject: Re: numbering output and other newbie issues
From: Terry Ofner <tofner@xxxxxxxxxxx>
Date: Tue, 28 Feb 2006 22:33:49 -0500
recognizing sentences
Wendell,

Thanks for your kind input on my first attempt. Here is my current stage of the xsl. I changed the tags around a bit in the XML file, which I am editing in Adobe InCopy. I find that InCopy has a handy translator from text and paragraph styles to XML tags. Here is a snippet of the current XLM.

Story>
<NameLine>Name _________________________________ Date _______________ Class
_____________________</NameLine>
<topic>Recognizing Sentences and Fragments</topic>
<definition>A sentence is a group of words that expresses a complete thought. A group of words
that expresses an incomplete thought is a sentence fragment.</definition>


<directions>Label each group of words S if it is a sentence or F if it is a fragment.</directions>

<item answer="S"> 1. The fans at the football game cheered wildly</item>
<item answer="F"> 2. Because the weather turned cold.</item>
<item answer="F"> 3. Brought a blanket to the
game.</item>
<item answer="F"> 4. The quarterback for the winning team.</item>
<item answer="S"> 5. My family watched the game from the fifty-yard line.</item>
<NameLine>Name _________________________________ Date _______________ Class
_____________________</NameLine>
<topic>Finding Complete Subjects</topic>
<definition>The subject names the person, place, thing, or idea that the sentence is about.</definition>
<directions> Underline the complete subject in each sentence.</directions>
<item> 1. <answer>Young Albert Einstein</answer> showed an interest in math and
science.</item><item> 2. <answer>His grades in other subjects</answer> were
poor.</item><item> 3. <answer>The future scientist</answer> finished high school and
technical college in Switzerland.</item><item> 4. <answer>The Swiss patent office</answer>
hired Einstein in 1902.</item><item> 5. <answer>Scholarly journals</answer> gave Einstein a
forum for his ideas. </item><item> 6. <answer>A German physics journal</answer> published
some of his articles.</item><item> 7. <answer>These articles</answer> discussed radical
theories about the nature of matter.</item><item> 8. <answer>Publication of these
articles</answer> changed scientists' view of the universe.</item><item> 9. <answer>The
theory of relativity</answer> was Einstein's most important
contribution.</item><item>10. <answer>The Nobel Prize in physics</answer> was awarded to
Einstein in 1921.</item>


Here is the stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:strip-space elements="*"/>
  <xsl:template match="NameLine"/>
  <xsl:template match="item"/>
  <xsl:template match="directions"/>
  <xsl:template match="definition"/>

  <xsl:template match="topic">
  <xsl:text>&#10;</xsl:text>
    <xsl:text>&#10;</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>&#10;</xsl:text>
    </xsl:template>

  <xsl:template match="item">
    <xsl:text>&#10;</xsl:text>
    <xsl:text>&#9;</xsl:text>
    <xsl:number count="item" level="any" from="topic" format="1.&#9;"/>
    <xsl:apply-templates select="answer | attribute::answer" />
   </xsl:template>
</xsl:stylesheet>

This gives me something close to the solution I am looking for. However, some of my answers have text that I have tagged with <us></us> for underscore like this:

<item> 1. Millions of Americans <answer><us>watch</us> displays of fireworks on the
Fourth of July.</answer>


I would like those tags to appear in the output. I have tried <xsl:copy-of select "us" /> in several positions, but the output doesn't change. Here is a snippet of the output:

Recognizing Sentences and Fragments

1. S
2. F
3. F
4. F
5. S
6. F
7. F
8. F


Finding Complete Subjects

	1.	Young Albert Einstein
	2.	His grades in other subjects
	3.	The future scientist
	4.	The Swiss patent office
	5.	Scholarly journals
	6.	A German physics journal
	7.	These articles
	8.	Publication of these
        articles
	9.	The
            theory of relativity
	10.	The Nobel Prize in physics

I am puzzled by the several random returns left in the output as in answers 8 and 9. But I am feeling good about the script. Here is my understanding of what I am doing in each section.

First I am stripping out white spaces from every element (or trying to!).
Then I am selecting NameLine, Item, definitions, and directions. I think I understand why I am selecting NameLine, definitions, and directions--so they don't appear in the output. I don't understand why I am selecting item. I will try commenting out that line to see if it changes the output.


Then I am selecting topic, adding a return before it and two returns after it. The apply-templates passes all this topic to output--is that right? If not to output, then it goes on...to the next template?

At any rate, I am then selecting the item together with the answers. I am numbering the items from the topic. Then I am selecting out the answers and answer attributes and adding returns and tabs in all the right places. The items themselves get left behind.

I think I got the aha you spoke of. That is, that when you match a node, you are removing it (perhaps to a processing cache of some kind). If you don't do anything with that node, then it remains in process until you call it out, so to speak. If you don't call it it out, it goes away to some cyber graveyard.

Am I getting close to a clearer understanding of the basic process? I have not been able to get at any of the reading you recommend. Many of the on-line sources seem to be about the development of the platform and not a patient training, as you suggest I should try to gain. I am asking for Learning XSLT by Micheal Fitgerald. It looks like a good beginner's guide.

Best wishes,

Terry
--
Terry Ofner, Consulting Editor
Perfection Learning Corporation
1541 Northbrook Drive
Indianapolis, Indiana 46260
Voice: 317-870-1992
Fax: 317-870-7101

tofner@xxxxxxxxxxx
http://www.perfectionlearning.com

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.