Next in thread → Next in month →

Re: [docbook-apps] Profiles

From
Bob Stayton <>
Date
2009-05-12T17:16:32+00:00
ID
021201c9d325$5daf25a0$6400a8c0@pazu
Thread
Re: [docbook-apps] Profiles
Hi,

Profiling for exclusion requires a customization of 
the profiling template named 'cross.compare' in 
profiling/profile-mode.xsl.  That template compares a profiling attribute 
to the corresponding value of the profiling parameter (e.g., @os vs. 
$profile.os).  Below is my attempt at a customization to handle a 
simple case: 

 

a.  When the profiling attribute has a single 
value, so that it does not have to recurse through a set of values separated by 
semicolons (and thereby complicating the logic), and

 

b.  When the attribute value to be excluded is 
prepended with the literal string "NOT", as in "NOTconditionB".

 

So, for example, if $profile.os="windows" and an 
element has @os="NOTwindows", then the element will be excluded.  Any other 
value of $profile.os would include the element.  More work would be needed 
if you wanted to use multiple values such as 
@os="NOTwindows;NOTmac".

 

 

<xsl:template name="cross.compare">
  
<xsl:param name="a"/>
  <xsl:param name="b"/>
  
<xsl:param name="sep" select="$profile.separator"/>

 

  <xsl:variable name="head" 
select="substring-before(concat($a, $sep), $sep)"/>
  
<xsl:variable name="tail" select="substring-after($a, 
$sep)"/>

 

  <xsl:choose>
    
<!-- special case of single value attribute that starts with NOT 
-->
    <xsl:when test="not(contains($b, $sep)) 
and
                    
starts-with(normalize-space($b),'NOT')">
      
<xsl:variable 
name="negative"
                    
select="substring-after(normalize-space($b),'NOT')"/>
      
<xsl:choose>
        <xsl:when 
test="contains(concat($sep, $negative, 
$sep),
                    
concat($sep, $a, 
$sep))"></xsl:when>
        
<!-- otherwise include it 
-->
        
<xsl:otherwise>1</xsl:otherwise>
      
</xsl:choose>
    
</xsl:when>
    <xsl:otherwise>

     <!-- this part is the 
original cross.compare -->
      <xsl:if 
test="contains(concat($sep, $b, 
$sep),
                    
concat($sep, $head, 
$sep))">1</xsl:if>
      <xsl:if 
test="$tail">
        
<xsl:call-template 
name="cross.compare">
          
<xsl:with-param name="a" 
select="$tail"/>
          
<xsl:with-param name="b" 
select="$b"/>
        
</xsl:call-template>
      
</xsl:if>
    </xsl:otherwise>
  
</xsl:choose>
</xsl:template>

 

Bob Stayton
Sagehill Enterprises


 

 

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

  
From: 
  Laurie 
  Burley 

  
To:  
  

  
Sent: Tuesday, May 12, 2009 1:05 AM

  
Subject: [docbook-apps] Profiles 

  

  

  
Has anyone managed to configure profile logic to allow 
  negative conditions?  I would like to be able to do the 
  following:

  
 

  
Show SectionA unless conditionB

  
 

  
The reason for this is because we have dozens of conditions 
  and it is common that we need to add all but one on a conditional element. We 
  will inevitably need more conditions in the future, and things are quickly 
  spiraling out of control, making the profiles unmanageable.

  
 

  
Does anyone have an example or recommendations 
  here?

  
 

  
Kind Regards,

  
 

  
Laurie
Next in thread → Next in month →