Profilovani

Jirka Kosek jirka na kosek.cz
Čtvrtek Prosinec 16 11:32:50 CET 2004


Miloslav Hertl wrote:
> Neznate nekdo vhodny element (neco jako je <phrase> pro inline prvky), 
> ktery by ale byl vhodny pro profilovani uvnitr <chapter> nebo <section>. 
> Potrebuji to pro obaleni nekolika <para>, <itemizedlist> a <procedure>. 
> V TDG jsem nic nenasel (nebo jsem to prehledl).

Žádný takový element neexistuje, protože by porušil strukturu dokumentu. 
  Nic vám však nebrání obalit elementy, které pro účely profilování 
chcete sdružit nějakým vaším elementem, třeba div a nastavit u něj 
profilovací atributy. Do styu, který pak provádí profilování přidejte 
následující šablonu, aby se <div> dal pryč před zpracováním dokumentu 
stylem:

<xsl:template match="div" mode="profile">

   <xsl:variable name="arch.content">
     <xsl:if test="@arch">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.arch"/>
         <xsl:with-param name="b" select="@arch"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="arch.ok" select="not(@arch) or not($profile.arch) or
                                        $arch.content != '' or @arch = ''"/>

   <xsl:variable name="condition.content">
     <xsl:if test="@condition">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.condition"/>
         <xsl:with-param name="b" select="@condition"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="condition.ok" select="not(@condition) or 
not($profile.condition) or
                                             $condition.content != '' or 
@condition = ''"/>

   <xsl:variable name="conformance.content">
     <xsl:if test="@conformance">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.conformance"/>
         <xsl:with-param name="b" select="@conformance"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="conformance.ok" select="not(@conformance) or 
not($profile.conformance) or
                                               $conformance.content != 
'' or @conformance = ''"/>

   <xsl:variable name="lang.content">
     <xsl:if test="@lang">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.lang"/>
         <xsl:with-param name="b" select="@lang"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="lang.ok" select="not(@lang) or not($profile.lang) or
                                        $lang.content != '' or @lang = ''"/>

   <xsl:variable name="os.content">
     <xsl:if test="@os">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.os"/>
         <xsl:with-param name="b" select="@os"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="os.ok" select="not(@os) or not($profile.os) or
                                      $os.content != '' or @os = ''"/>

   <xsl:variable name="revision.content">
     <xsl:if test="@revision">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.revision"/>
         <xsl:with-param name="b" select="@revision"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="revision.ok" select="not(@revision) or 
not($profile.revision) or
                                            $revision.content != '' or 
@revision = ''"/>

   <xsl:variable name="revisionflag.content">
     <xsl:if test="@revisionflag">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.revisionflag"/>
         <xsl:with-param name="b" select="@revisionflag"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="revisionflag.ok" select="not(@revisionflag) or 
not($profile.revisionflag) or
                                                $revisionflag.content != 
'' or @revisionflag = ''"/>

   <xsl:variable name="role.content">
     <xsl:if test="@role">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.role"/>
         <xsl:with-param name="b" select="@role"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="role.ok" select="not(@role) or not($profile.role) or
                                        $role.content != '' or @role = ''"/>

   <xsl:variable name="security.content">
     <xsl:if test="@security">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.security"/>
         <xsl:with-param name="b" select="@security"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="security.ok" select="not(@security) or 
not($profile.security) or
                                            $security.content != '' or 
@security = ''"/>

   <xsl:variable name="userlevel.content">
     <xsl:if test="@userlevel">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.userlevel"/>
         <xsl:with-param name="b" select="@userlevel"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="userlevel.ok" select="not(@userlevel) or 
not($profile.userlevel) or
                                             $userlevel.content != '' or 
@userlevel = ''"/>

   <xsl:variable name="vendor.content">
     <xsl:if test="@vendor">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.vendor"/>
         <xsl:with-param name="b" select="@vendor"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="vendor.ok" select="not(@vendor) or 
not($profile.vendor) or
                                          $vendor.content != '' or 
@vendor = ''"/>

   <xsl:variable name="attribute.content">
     <xsl:if test="@*[local-name()=$profile.attribute]">
       <xsl:call-template name="cross.compare">
         <xsl:with-param name="a" select="$profile.value"/>
         <xsl:with-param name="b" 
select="@*[local-name()=$profile.attribute]"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:variable>
   <xsl:variable name="attribute.ok"
                 select="not(@*[local-name()=$profile.attribute]) or 
not($profile.value) or
                         $attribute.content != '' or
                         @*[local-name()=$profile.attribute] = '' or 
not($profile.attribute)"/>

   <xsl:if test="$arch.ok and $condition.ok and $conformance.ok and 
$lang.ok and $os.ok
                 and $revision.ok and $revisionflag.ok and $role.ok and 
$security.ok
                 and $userlevel.ok and $vendor.ok and $attribute.ok">
       <xsl:apply-templates select="node()" mode="profile"/>
   </xsl:if>
</xsl:template>

Samozřejmě by to ještě chtělo upravit si DTD DocBooku tak, aby v něm byl 
element <div> a fungovala validace a doplňování elementů v editoru.

-- 
------------------------------------------------------------------
   Jirka Kosek     e-mail: jirka na kosek.cz     http://www.kosek.cz
------------------------------------------------------------------
   Profesionální školení a poradenství v oblasti technologií XML.
      Podívejte se na náš nově spuštěný web http://DocBook.cz
        Podrobný přehled školení http://xmlguru.cz/skoleni/
------------------------------------------------------------------

------------- další část ---------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3158 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.linux.cz/pipermail/docbook/attachments/20041216/11ef0b19/attachment.bin>


Další informace o konferenci Docbook