Subject: Re: [xsl] numbering output and other newbie issues From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Fri, 24 Feb 2006 15:33:31 -0500 |
<xsl:template match="Answer"> <xsl:number level="any" format="1. "/> <xsl:apply-templates/> </xsl:template>
<xsl:template match="/"> <xsl:copy-of select="Story/GrammarQuiz/Item/Answer" /> </xsl:template>
<xsl:template match="/"> <xsl:appy-templates select="Story/GrammarQuiz/Item/Answer"/> </xsl:template>
Enjoy, Wendell
I am a newbie to xsl stylesheets as well as xml. I have set myself a specific task as my first "assignment." I have a set of English grammar exercises for which I want to build an answer key. The exercises are not in XML format yet, so I have control over the XML format as well as the XSL stylesheet.
Here is my first trial XML document.
<?xml version="1.0" encoding="UTF-8"?>
<Story>
<chapter>The Sentence Base?</chapter>
<GrammarTopic>Finding Subjects</GrammarTopic>
<Directions>Underline the subject in each sentence. If the subject is an understood you, write you.</Directions>
<GrammarQuiz>
<Item>1. Find your seats quickly. <Answer>you</Answer></Item>
<Item>2. During open auditions there are very few empty <Answer>seats</Answer> in the auditorium.</Item>
<Item>3. Have <Answer>you</Answer> heard the director's name?</Item>
</GrammarQuiz>
</Story>
And 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:template match="/"> <xsl:copy-of select="Story/GrammarQuiz/Item/Answer" />
</xsl:template> </xsl:stylesheet>
The result is:
<?xml version="1.0" encoding="utf-8"?><Answer>you</Answer><Answer>seats</Answer><Answer>you</Answer><Answer>actress</Answer><Answer>director</Answer>
This result is okay, but I would like to number each answer. I have tried to add this line after the copy-of select line:
<xsl:number count="*" format="1. "/>
This line does not change the output.
There are other anomalies (or what appear to me to be anomalies.) For example, when I change copy-of select to value-of select I get this output:
<?xml version="1.0" encoding="utf-8"?>you.
I am using SAXON 6.5.4 on a Windows laptop. I have tried the same on Mas OS X with XSLT Tester with the same result-- which only proves that it is my stylesheet that is at fault (along with my thinking).
Any help would be appreciated.
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] numbering output and other ne, Terry Ofner | Thread | Re: [xsl] numbering output and othe, Terry Ofner |
[xsl] numbering output and other ne, Terry Ofner | Date | [xsl] Can't figure out why this jav, Bruso, John |
Month |