Subject: Re: [xsl] numbering output and other newbie issues From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 27 Feb 2006 12:41:01 -0500 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Item"> <xsl:number level="any" format="1.	"/> <xsl:apply-templates select="Answer"/> </xsl:template>
Cheers, Wendell
Thanks Wendell,
Your suggestion worked like a charm. I added some tabs and newline characters as needed for my purposes. There is one more aspect of this project that has me really puzzled. Suppose that some quiz items have more than one answer. I changed item 3 of the the XML file to represent this situation.
<Story>
<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> and <Answer>Marsha</Answer> heard the director's name?</Item>
</GrammarQuiz>
</Story>
Here is my current 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:text> </xsl:text> <xsl:apply-templates select="Story/GrammarTopic" /> <xsl:apply-templates select="Story/GrammarQuiz/Item/Answer"/> </xsl:template>
<xsl:template match="Answer"> <xsl:text> </xsl:text><xsl:text>	</xsl:text> <xsl:number level="any" format="1.	"/> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet>
This works great except, of course, it numbers all the answers consecutively. The output looks like this:
Finding Subjects 1. you 2. seats 3. you 4. Marsha
What I want to do now is get both answers for item 3 ("you" and "Marsha") together on one line like this.
Finding Subjects 1. you 2. seats 3. you, Marsha
I have a feeling that this will involve some complicated routines. I have reviewed The XSLT Cookbook and several other resources, but I am not even sure where to start.
Again, any help will be greatly appreciated.
Terry
====================================================================== 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 -> |
---|---|---|
Re: [xsl] numbering output and othe, Terry Ofner | Thread | Re: [xsl] numbering output and othe, Terry Ofner |
RE: [xsl] when to use 'as' attribut, Michael Kay | Date | Re: [xsl] constructing a "variable", Tracey Zellmann |
Month |