Jump to content

Numbering with XSL


Gullinvarg

Recommended Posts

I'm creating questionnaires using XML and XSLT. The XML looks something like this: <survey>

<section type="labeltop">
<question type="text"> <text>Displayed text for question?</text> </question>

<question type="checkbox">
<text>Displayed text for question?</text> <choice value="answer 1">Answer 1</choice> <choice value="answer 2">Answer 2</choice> <choice value="answer 3">Answer 3</choice>

</question>
</section>

<section type="grid">
<text>Section instructions</text>

<question type="radio">
<text>Displayed text for question?</text> <choice value="1" /> <choice value="2" /> <choice value="3" /> <choice value="4" /> <choice value="5" />

</question>

<question type="radio">
<text>Displayed text for question?</text> <choice value="1" /> <choice value="2" /> <choice value="3" /> <choice value="4" /> <choice value="5" />

</question>
</section>
</survey> Currently, I'm numbering the questions using <xsl:number count="question" level="any" format="1. "/>. The type="grid" for section indicates that all of the questions are scale questions that are displayed in a grid with the scale listed above the entire grid, instead of separately for each question. My dilemma is this, I would like to number the "labeltop" questions normally, but label the entire section as one question for "grid", then go back to normal numbering for any questions following the grid (see below for an illustration). Any ideas on how to do this in XSLT? 1. Normal question 2. Normal question 3. Grid

a. Scale question b. Scale question

4. Normal question Thanks for any help anyone can give me. Michelle

Link to comment
Share on other sites

I'm not sure, but I believe you can useformat="1.a. "for that.
Nope, but thanks for trying.The "scaled questions" are still questions. If I omit the level="any" from <xsl:number count="question" level="any" format="1. "/> the numbering restarts with "1." for every section. I can use this fact to get the a., b., c. for the scaled questions. Using the format example, my issue is how to get the "3." and "4." labels. Maybe I should reword my example. The tags of the data being displayed should be something like this:1. <section type="labeltop"><question>2. <section type="labeltop"><question>3. <section type="grid">

a. <
question
>b. <
question
>

4. <section type="labeltop"><question>Note that I'm not putting each section type = "labeltop" question in a separate section. I just listed it this way to indicate which section those questions are in. The xml would be like this:<section type="labeltop"><question /> 1.<question /> 2.</section><section type="grid"> 3.<question /> a.<question /> b.</section><section type="labeltop"><question /> 4.</section>Michelle

Link to comment
Share on other sites

I understood what you want from the start, but I just haven't tryed xsl:number enough to know the answer.Hm... how about two xsl:number elements?<xsl:number count="question[string(../section/@type)=labeltop]" level="any" format="1. "/><xsl:number count="question[string(../section/@type)=grid]" level="any" format="a. "/>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...