Including the page numbers from the school book on the Worksheet

It is true that more and more individuals are using digital devices for viewing publications at our Christian meetings. However, during the Midweek meeting we have the student items where we use this publication:

Benefit From Theocratic Ministry School Education
Benefit From Theocratic Ministry School Education

As you know, the publication includes a counsel form:

At the moment this counsel form is not available in an electronic format to keep it up to date (when you have a student item). Thus, usually students are encouraged to bring their book with them so that it can be updated by hand.

As a result, it is not uncommon for the chairman to desire to make reference to the page number of the book when he is referring to counsel points. This is because we are all encouraged to follow along as we are all students too!

How To Include the Page Number on the Chairman Worksheet

It is assumed that you already know how to copy the existing style sheets to a new name for further customization. It is beyond the scope of this blog post.

Step 1

Create an XML document that includes all the page numbers for the study points. This file needs to be put it into the Meeting Schedule Assistant user application data folder.

This is what the file should look like (page numbers correct for the English publication):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0" encoding="utf-8"?>
<Lessons>
  <Study Number="1" Page="83"/>
  <Study Number="2" Page="86"/>
  <Study Number="3" Page="89"/>
  <Study Number="4" Page="93"/>
  <Study Number="5" Page="97"/>
  <Study Number="6" Page="101"/>
  <Study Number="7" Page="105"/>
  <Study Number="8" Page="107"/>
  <Study Number="9" Page="111"/>
  <Study Number="10" Page="115"/>
  <Study Number="11" Page="118"/>
  <Study Number="12" Page="121"/>
  <Study Number="13" Page="124"/>
  <Study Number="14" Page="128"/>
  <Study Number="15" Page="131"/>
  <Study Number="16" Page="135"/>
  <Study Number="17" Page="139"/>
  <Study Number="18" Page="143"/>
  <Study Number="19" Page="145"/>
  <Study Number="20" Page="147"/>
  <Study Number="21" Page="150"/>
  <Study Number="22" Page="153"/>
  <Study Number="23" Page="157"/>
  <Study Number="24" Page="160"/>
  <Study Number="25" Page="166"/>
  <Study Number="26" Page="170"/>
  <Study Number="27" Page="174"/>
  <Study Number="28" Page="179"/>
  <Study Number="29" Page="181"/>
  <Study Number="30" Page="186"/>
  <Study Number="31" Page="190"/>
  <Study Number="32" Page="194"/>
  <Study Number="33" Page="197"/>
  <Study Number="34" Page="202"/>
  <Study Number="35" Page="206"/>
  <Study Number="36" Page="209"/>
  <Study Number="37" Page="212"/>
  <Study Number="38" Page="215"/>
  <Study Number="39" Page="220"/>
  <Study Number="40" Page="223"/>
  <Study Number="41" Page="226"/>
  <Study Number="42" Page="230"/>
  <Study Number="43" Page="234"/>
  <Study Number="44" Page="236"/>
  <Study Number="45" Page="240"/>
  <Study Number="46" Page="244"/>
  <Study Number="47" Page="247"/>
  <Study Number="48" Page="251"/>
  <Study Number="49" Page="255"/>
  <Study Number="50" Page="258"/>
  <Study Number="51" Page="263"/>
  <Study Number="52" Page="265"/>
  <Study Number="53" Page="268"/>
</Lessons>

This file is also available on Pastebin: Study Point Page Numbers.

Step 2

Next, you need to open your own copy of the worksheet with a plain text editor (like Notepad++). You need to add a new template that will be applied to all StudyPoint attributes:

303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!--Display the study number, description and page number.-->
<xsl:template match="@StudyPoint">
<xsl:choose>
  <xsl:when test="current()!=''">
    <xsl:variable name="StudyPageNumbers" select="document('StudyPointPageNumbers.xml')"/>
    <xsl:text> (Page: </xsl:text>
    <xsl:value-of select="$StudyPageNumbers/Lessons/Study[@Number=current()]/@Page"/>
    <xsl:text>)</xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text>No study point.</xsl:text>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>

For example, if the study number was 12 then this will be displayed:

12 Gestures and Facial Expressions (Page: 121)

Or, if no study point was present, then this will be displayed:

No Study Point.

Step 3

There are several locations in the XSL script that you need to apply the above template. Here is one of those locations:

258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<xsl:choose>
  <xsl:when test="$Class='M'">
    <xsl:value-of select="BibleReadingM/@StudyPoint"/>&#160;
    <xsl:value-of select="BibleReadingM/@StudyPointDescription"/>
    <xsl:apply-templates select="BibleReadingM/@StudyPoint"/>
  </xsl:when>
  <xsl:when test="$Class='1'">
    <xsl:value-of select="BibleReading1/@StudyPoint"/>&#160;
    <xsl:value-of select="BibleReading1/@StudyPointDescription"/>
    <xsl:apply-templates select="BibleReading1/@StudyPoint"/>
  </xsl:when>
  <xsl:when test="$Class='2'">
    <xsl:value-of select="BibleReading2/@StudyPoint"/>&#160;
    <xsl:value-of select="BibleReading2/@StudyPointDescription"/>
    <xsl:apply-templates select="BibleReading2/@StudyPoint"/>
  </xsl:when>
</xsl:choose>

As you can see, we have made 3 changes to the script and added the calls to apply-templates.

There are three more locations in the XSL script that you will need to do a similar exercise.

This file is also available on PastebinWorksheet-Next Students-PageNo.XSL

The Result

If you have made the changes correctly then the page numbers should show in the editor:

Student Study Points with Page numbers

Addendum

As per the note I made in the comments  section below, there is an alternative way to get this done. On the surface you will not see any performance improvement but it is good to be aware of this other methodology.

It has to do with using keys. You establish a cross-reference and then the system caches this information and kind of uses a lookup table. This in the long run would be quicker if you had a larger document. The only change to the above instructions is a revised step 2.

Revised Step 2

This is the new code that you would require in the XSL file:

303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<!--The key to cross reference the study number with the page in the book-->
<xsl:key name="studies" match="Study" use="@Number" />

<!--Display the study number, description and page number.-->
<xsl:template match="@StudyPoint">
<xsl:choose>
  <xsl:when test="current()!=''">
    <xsl:text> (Page: </xsl:text>
    <xsl:variable name="num" select="." />
    <!-- change context to use a key -->
    <xsl:for-each select="document('StudyPointPageNumbers.xml')">
      <xsl:value-of select="key('studies', $num)/@Page"/>
    </xsl:for-each>
    <xsl:text>)</xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text>No study point.</xsl:text>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>

This file is also available on PastebinWorksheet-Next Students-PageNo2.XSL

[Total: 0    Average: 0/5]

3 thoughts on “Including the page numbers from the school book on the Worksheet

    1. Thanks Stefano. 🙂 I have also learned about a second way that it can be done by using “keys”. The change to the code is minimal from what I have already shown. The benefit is also negligible in this instance. But using keys is a good concept to learn because if we ever need to use a cross reference a lot in a report it kind of caches all the possibilities once and does a direct like for like. So in other situations it would be more efficient.

      See how you get on with this tutorial first. Then I may do an addendum about using keys.

    2. Hi Stefano. As per my reply yesterday, I have added an addendum to this post with an alternative way using keys.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.