Next in thread → Next in month →

Re: [docbook-apps] qanda tags with propagate.style

From
Eavid Mink
Date
2011-03-21T20:45:26+00:00
ID
AANLkTikFU12StynKhg6eLueiJWVtCm55N=8xg=
Thread
Re: [docbook-apps] qanda tags with propagate.style
Thank you very much Bob for replying.

After reading the qandaset.xsl and your most excellent documentation I came on the solution you described here.

I had two other requirements:  Namely that the qanda content needed to be broken out into two separate sections: One for the Questions, and the other for The Answers (like a college Textbook).  And the Answer section needed to be labeled as well.

To do this I first preprocessed the docbook with python lxml etree, to duplicate the qandaset in the book (the first with only 'questions' and the second with only 'answers' [and removing non-qandaentry tags from the later], as well modifying Ids in the later.)

And then I brought the following into our customization layer:

<xsl:template match="question|answer">
<xsl:template match="question|answer" mode="qanda.label">, and

<xsl:template match="question|answer" mode="label.markup">

The first two where extended to treat answers as well as questions.

Then I added the instructoronly class to the HTML tr mostly as you described:

<xsl:template match="qandaentry[@audience='instructoronly']/answer"
     mode="class.value">
  <xsl:value-of select="'answer instructoronly'"/>
</xsl:template>

Thank you again,

Regards,
David Link
New York

On Mon, Mar 21, 2011 at 1:46 PM, Bob Stayton <> wrote:

Hi David,

Yes, qandaentry is handled in a special way because 
qandaset is output in an HTML layout table, so each qandaentry becomes two row 
(tr) elements in HTML output, one for the question and one for the answer.  
In each row, the label is put in the first column and the paragraphs in the 
second. A table layout is used so that the width of the first column can adjust 
to fit the label, which can be long if labels are customized.

 

If you peek in the xhtml/qandaset.xsl, you can see 
that the template that matches on "qandaentry" just does an 
xsl:apply-templates.  The templates matching on "question" and "answer" 
each create its row.  So your customization just needs to be modified 
a bit, so it matches on the child elements:

 

<xsl:template 
match="qandaentry[@audience='instructoronly']/*]"
              
mode="class.value">
  <xsl:value-of 
select="'instructoronly'"/>
</xsl:template>

That will add the class value to the <tr> 
elements for the question and answer.

 

*But* there is one more thing that must be 
done.  It seems that not all of the qandaset templates have been updated to 
apply the template using mode="class.value".  The question template does, 
but the answer template does not.  I'll fix that in SVN, but for now you 
would need to customize the template matching on "answer".  Copy that 
template and change this line from:

 

   <tr 
class="{local-name(.)}">

 

to

 

  <tr>
    
<xsl:apply-templates select="." 
mode="class.attribute"/>

Bob Stayton
Sagehill Enterprises


 

 

  
----- Original Message ----- 

  
From: 
  David Link 

  
To:  
  

  

Sent: Friday, March 18, 2011 2:32 
PM

  
Subject: [docbook-apps] qanda tags with 
  propagate.style

  

Hi

Regarding qandaentry tags -- Is there a way to 
  preserve audience="instructoronly" information in the 
  HTML?

Example:

<qandaentry xml:id="ball-ch01_qs01_qd01_qa02" 
  audience="instructoronly">
    
  <question>
        <para 
  xml:id="ball-ch01_qs01_p02">Give an example of matter in each phase: solid, 
  liquid, or gas.</para>
    
  </question>
    
  <answer>
        <para 
  xml:id="ball-ch01_qs01_p03">solid: wood; liquid: water in a pond; gas: air 
  in the atmosphere (answers will vary)</para>
    
  </answer>
</qandaentry>                                  
  

Explaination:

We are using audience='instructoronly' on every 
  other qandaentry so that we can conditionally remove them from output via 
  styling (via styling to maintain label numbering)

We are doing this 
  with in prince for the pdf, and that is working fine.

But for the HTML 
  the xhtml/docbook.xsl transforms does not propaget the 'instructoronly' as a 
  div with class='instructoronly'

I tried

<xsl:template 
  match="qandaentry[@audience='instructoronly']"
              
  mode="class.value">
  <xsl:value-of 
  select="'instructoronly'"/>
</xsl:template>

But that 
  doesn't seem to work.  I believe because it is rendered into an html 
  table.

Can anyone suggest away to maintain the 
  audience='instructoronly' in the HTML ?
 
Thank you very 
  much.
David Link
New York
Next in thread → Next in month →