Changeset 99156 in vbox
- Timestamp:
- Mar 23, 2023 10:31:09 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/docbook-refentry-to-manual-dita.xsl
r99137 r99156 35 35 <xsl:import href="string.xsl"/> 36 36 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"/> 38 38 <xsl:strip-space elements="*"/> 39 39 … … 61 61 Also we need to wrap the refsync and refsect1 elements in a refbody. --> 62 62 <xsl:template match="refentry"> 63 <xsl:text disable-output-escaping='yes'><!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd"></xsl:text> 63 <xsl:text disable-output-escaping='yes'><!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd"> 64 </xsl:text> 64 65 65 66 <xsl:element name="reference"> … … 134 135 <xsl:element name="sectiondiv"> 135 136 <xsl:attribute name="rev">refsect2</xsl:attribute> 137 <xsl:attribute name="outputclass">refsect2</xsl:attribute> 136 138 <xsl:if test="@id"> 137 139 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> … … 147 149 <xsl:element name="b"> 148 150 <xsl:attribute name="rev">refsect2/title</xsl:attribute> 151 <xsl:attribute name="outputclass">refsect2title</xsl:attribute> 149 152 <xsl:apply-templates /> 150 153 </xsl:element> … … 321 324 </xsl:template> 322 325 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. --> 324 332 <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" > 332 356 <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> 337 370 338 371 <xsl:if test="@rep='repeat'"> 339 372 <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> 341 374 <xsl:text>...</xsl:text> 342 375 </xsl:element> 343 376 </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'"> 347 383 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected arg in group to be plain, not optional.</xsl:message> 348 384 </xsl:if> 349 385 </xsl:template> 350 386 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)]" > 390 390 <xsl:call-template name="check-children" /> 391 391 <xsl:element name="kwd"> 392 <xsl:attribute name="rev">arg[plain ]</xsl:attribute>392 <xsl:attribute name="rev">arg[plain#3]</xsl:attribute> 393 393 <xsl:value-of select="."/> 394 394 </xsl:element> 395 </xsl:template> 396 395 </xsl:template> --> 397 396 398 397 <!-- replaceable under arg -> var --> … … 431 430 </xsl:template> 432 431 433 <!-- group under arg and cmdsynopsis -> groupchoice-->432 <!-- Plain group under arg or cmdsynopsis -> groupchoice w/o importance attrib --> 434 433 <xsl:template match="arg/group[@choice='plain'] | cmdsynopsis/group[@choice='plain']"> 435 434 <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 --> 441 445 <xsl:template match="arg/group[@choice='req'] | cmdsynopsis/group[@choice='req']"> 442 446 <xsl:element name="groupchoice"> 443 <xsl:attribute name="rev">group </xsl:attribute>447 <xsl:attribute name="rev">group[req]</xsl:attribute> 444 448 <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))]" > 450 463 <xsl:if test="not(./arg[@choice='plain'])"> 451 464 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Did not expect group[@choice=opt] to have children other than arg[@choice=plain]: … … 453 466 </xsl:message> 454 467 </xsl:if> 468 455 469 <xsl:element name="groupchoice"> 456 470 <xsl:attribute name="rev">group[opt]</xsl:attribute> 457 471 <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> 460 478 </xsl:template> 461 479
Note:
See TracChangeset
for help on using the changeset viewer.