VirtualBox

Changeset 99156 in vbox


Ignore:
Timestamp:
Mar 23, 2023 10:31:09 PM (21 months ago)
Author:
vboxsync
Message:

manual: More work on the refentry to dita converter. bugref:10302

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/docbook-refentry-to-manual-dita.xsl

    r99137 r99156  
    3535  <xsl:import href="string.xsl"/>
    3636
    37   <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
     37  <xsl:output method="xml" version="1.0" encoding="utf-8" indent="no"/>
    3838  <xsl:strip-space elements="*"/>
    3939
     
    6161     Also we need to wrap the refsync and refsect1 elements in a refbody. -->
    6262<xsl:template match="refentry">
    63   <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd"&gt;</xsl:text>
     63  <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd"&gt;
     64</xsl:text>
    6465
    6566  <xsl:element name="reference">
     
    134135  <xsl:element name="sectiondiv">
    135136    <xsl:attribute name="rev">refsect2</xsl:attribute>
     137    <xsl:attribute name="outputclass">refsect2</xsl:attribute>
    136138    <xsl:if test="@id">
    137139      <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
     
    147149  <xsl:element name="b">
    148150    <xsl:attribute name="rev">refsect2/title</xsl:attribute>
     151    <xsl:attribute name="outputclass">refsect2title</xsl:attribute>
    149152    <xsl:apply-templates />
    150153  </xsl:element>
     
    321324</xsl:template>
    322325
    323 <!-- arg -->
     326<!--
     327   arg -> groupseq; A bit complicated though...
     328-->
     329
     330<!-- Plaintext within arg is generally translated to kwd, but value separators
     331     like '=' and ',' should be wrapped in a sep element. -->
    324332<xsl:template match="arg/text()">
    325   <xsl:element name="kwd">
    326     <xsl:attribute name="rev">arg</xsl:attribute>
    327     <xsl:value-of select="."/>
    328   </xsl:element>
    329 </xsl:template>
    330 
    331 <xsl:template match="arg[not(@choice) or @choice='opt']" >
     333  <xsl:choose>
     334    <xsl:when test="substring(., string-length(.)) = '='">
     335      <xsl:element name="kwd">
     336        <xsl:attribute name="rev">arg=</xsl:attribute>
     337        <xsl:value-of select="substring(., 1, string-length(.) - 1)"/>
     338      </xsl:element>
     339      <xsl:element name="sep">
     340        <xsl:attribute name="rev">arg=</xsl:attribute>
     341        <xsl:text>=</xsl:text>
     342      </xsl:element>
     343    </xsl:when>
     344
     345    <xsl:otherwise>
     346      <xsl:element name="kwd">
     347        <xsl:attribute name="rev">arg</xsl:attribute>
     348        <xsl:value-of select="."/>
     349      </xsl:element>
     350    </xsl:otherwise>
     351  </xsl:choose>
     352</xsl:template>
     353
     354<!-- arg -> groupseq and optionally a repsep element if repeatable. -->
     355<xsl:template match="arg" >
    332356  <xsl:element name="groupseq">
    333     <xsl:attribute name="rev">arg[opt]</xsl:attribute>
    334     <xsl:attribute name="importance">optional</xsl:attribute>
    335 
    336     <xsl:apply-templates />
     357    <xsl:attribute name="rev">arg[<xsl:value-of select="concat(@choice,',',@rep)"/>]</xsl:attribute>
     358    <xsl:choose>
     359      <xsl:when test="not(@choice) or @choice = 'opt'">
     360        <xsl:attribute name="importance">optional</xsl:attribute>
     361      </xsl:when>
     362      <xsl:when test="@choice = 'req'">
     363        <xsl:attribute name="importance">required</xsl:attribute>
     364      </xsl:when>
     365      <xsl:when test="@choice = 'plain'"/>
     366      <xsl:otherwise>
     367        <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Unexpected @choice value: <xsl:value-of select="@choice"/></xsl:message>
     368      </xsl:otherwise>
     369    </xsl:choose>
    337370
    338371    <xsl:if test="@rep='repeat'">
    339372      <xsl:element name="repsep">
    340         <xsl:attribute name="rev">arg[opt,repeat]</xsl:attribute>
     373        <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute>
    341374        <xsl:text>...</xsl:text>
    342375      </xsl:element>
    343376    </xsl:if>
    344   </xsl:element>
    345 
    346   <xsl:if test="parent::group">
     377
     378    <xsl:apply-templates />
     379
     380  </xsl:element>
     381
     382  <xsl:if test="parent::group and @choice != 'plain'">
    347383    <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected arg in group to be plain, not optional.</xsl:message>
    348384  </xsl:if>
    349385</xsl:template>
    350386
    351 <xsl:template match="arg[@choice='req']" >
    352   <xsl:element name="groupseq">
    353     <xsl:attribute name="rev">arg[req]</xsl:attribute>
    354     <xsl:attribute name="importance">required</xsl:attribute>
    355 
    356     <xsl:apply-templates />
    357 
    358     <xsl:if test="@rep='repeat'">
    359       <xsl:element name="repsep">
    360         <xsl:attribute name="rev">arg[opt,repeat]</xsl:attribute>
    361         <xsl:text>...</xsl:text>
    362       </xsl:element>
    363     </xsl:if>
    364   </xsl:element>
    365 
    366   <xsl:if test="parent::group">
    367     <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected arg in group to be plain, not required.</xsl:message>
    368   </xsl:if>
    369 </xsl:template>
    370 
    371 <xsl:template match="arg[not(ancestor::group) and ancestor::cmdsynopsis and @choice='plain' and (not(@rep) or @rep='norepeat')]" >
    372   <xsl:element name="kwd">
    373     <xsl:attribute name="rev">arg[plain]</xsl:attribute>
    374     <xsl:apply-templates />
    375   </xsl:element>
    376 </xsl:template>
    377 
    378 <xsl:template match="group/arg[replaceable and @choice='plain' and (not(@rep) or @rep='norepeat')]" >
    379   <xsl:call-template name="check-children">
    380     <xsl:with-param name="UnsupportedNodes" select="*[not(self::replaceable)]"/>
    381     <xsl:with-param name="SupportedNames">replaceable or text()</xsl:with-param>
    382   </xsl:call-template>
    383   <xsl:element name="var">
    384     <xsl:attribute name="rev">arg[plain]/replaceable</xsl:attribute>
    385     <xsl:value-of select="."/>
    386   </xsl:element>
    387 </xsl:template>
    388 
    389 <xsl:template match="group/arg[@choice='plain' and (not(@rep) or @rep='norepeat') and not(replaceable)]" >
     387<!-- Plain (required) argument in group with only text() content -> kwd; -->
     388<!--
     389<xsl:template match="group/arg[@choice='plain' and (not(@rep) or @rep='norepeat') and not(replaceable) and not(arg) and not(group)]" >
    390390  <xsl:call-template name="check-children" />
    391391  <xsl:element name="kwd">
    392     <xsl:attribute name="rev">arg[plain]</xsl:attribute>
     392    <xsl:attribute name="rev">arg[plain#3]</xsl:attribute>
    393393    <xsl:value-of select="."/>
    394394  </xsl:element>
    395 </xsl:template>
    396 
     395</xsl:template> -->
    397396
    398397<!-- replaceable under arg -> var -->
     
    431430</xsl:template>
    432431
    433 <!-- group under arg and cmdsynopsis -> groupchoice -->
     432<!-- Plain group under arg or cmdsynopsis -> groupchoice w/o importance attrib -->
    434433<xsl:template match="arg/group[@choice='plain'] | cmdsynopsis/group[@choice='plain']">
    435434  <xsl:element name="groupchoice">
    436     <xsl:attribute name="rev">group</xsl:attribute>
    437     <xsl:apply-templates />
    438   </xsl:element>
    439 </xsl:template>
    440 
     435    <xsl:attribute name="rev">group[plain]</xsl:attribute>
     436    <xsl:apply-templates />
     437  </xsl:element>
     438
     439  <xsl:if test="@rep and @rep!='norepeat'">
     440    <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Not implemented: Repeating plain group</xsl:message>
     441  </xsl:if>
     442</xsl:template>
     443
     444<!-- Required group under arg or cmdsynopsis -> groupchoice w/attrib -->
    441445<xsl:template match="arg/group[@choice='req'] | cmdsynopsis/group[@choice='req']">
    442446  <xsl:element name="groupchoice">
    443     <xsl:attribute name="rev">group</xsl:attribute>
     447    <xsl:attribute name="rev">group[req]</xsl:attribute>
    444448    <xsl:attribute name="importance">required</xsl:attribute>
    445     <xsl:apply-templates />
    446   </xsl:element>
    447 </xsl:template>
    448 
    449 <xsl:template match="cmdsynopsis/group[(@choice='opt' or not(@choice)) and (not(@rep) or @rep='norepeat')]" >
     449
     450    <xsl:if test="@rep = 'repeat'">
     451      <xsl:element name="repsep">
     452        <xsl:attribute name="rev">group[req,repeat]</xsl:attribute>
     453        <xsl:text>...</xsl:text>
     454      </xsl:element>
     455    </xsl:if>
     456
     457    <xsl:apply-templates />
     458  </xsl:element>
     459</xsl:template>
     460
     461<!-- Optional group under arg or cmdsynopsis -> groupchoice w/attrib -->
     462<xsl:template match="cmdsynopsis/group[(@choice='opt' or not(@choice))]" >
    450463  <xsl:if test="not(./arg[@choice='plain'])">
    451464    <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Did not expect group[@choice=opt] to have children other than arg[@choice=plain]:
     
    453466    </xsl:message>
    454467  </xsl:if>
     468
    455469  <xsl:element name="groupchoice">
    456470    <xsl:attribute name="rev">group[opt]</xsl:attribute>
    457471    <xsl:attribute name="importance">optional</xsl:attribute>
    458     <xsl:value-of select="."/>
    459   </xsl:element>
     472    <xsl:apply-templates />
     473  </xsl:element>
     474
     475  <xsl:if test="@rep and @rep!='norepeat'">
     476    <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Not implemented: Repeating optional group</xsl:message>
     477  </xsl:if>
    460478</xsl:template>
    461479
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette