- Timestamp:
- Mar 23, 2023 8:45:15 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/docbook-refentry-to-manual-dita.xsl
r99101 r99130 221 221 </xsl:template> 222 222 223 <!-- command in cmdsynopsis -> syntaxdiagram 223 <!-- orderedlist -> ol --> 224 <xsl:template match="orderedlist"> 225 <xsl:element name="ol"> 226 <xsl:attribute name="rev">orderedlist</xsl:attribute> 227 <xsl:apply-templates /> 228 </xsl:element> 229 </xsl:template> 230 231 <!-- listitem in orderedlist -> li --> 232 <xsl:template match="orderedlist/listitem"> 233 <xsl:element name="li"> 234 <xsl:attribute name="rev">listitem</xsl:attribute> 235 <xsl:apply-templates /> 236 </xsl:element> 237 </xsl:template> 238 239 <!-- cmdsynopsis -> syntaxdiagram 224 240 If sbr is used, this gets a bit more complicated... --> 225 241 <xsl:template match="cmdsynopsis[not(sbr)]"> … … 233 249 </xsl:template> 234 250 235 <!-- This isn't working.236 <xsl:key name="G_keyUpToNextSbr"237 match="cmdsynopsis/node()[not(self::sbr)]"238 use="generate-id((..|preceding-sibling::sbr[1])[last()])"/>239 240 251 <xsl:template match="cmdsynopsis[sbr]"> 241 252 <xsl:element name="syntaxdiagram"> … … 244 255 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 245 256 </xsl:if> 246 <xsl:element name="groupcomp"> 247 <xsl:attribute name="rev">sbr/0</xsl:attribute> 248 <xsl:apply-templates select="key('G_keyUpToNextSbr', generate-id())"/> 249 </xsl:element> 250 <xsl:apply-templates select="sbr"/> 251 </xsl:element> 252 </xsl:template> 253 254 <xsl:template match="cmdsynopsis/sbr"> 255 <xsl:element name="groupcomp"> 256 <xsl:attribute name="rev">sbr/n</xsl:attribute> 257 <xsl:apply-templates select="key('G_keyUpToNextSbr', generate-id())"/> 258 </xsl:element> 259 </xsl:template> 260 --> 261 <xsl:template match="cmdsynopsis[sbr]"> 262 <xsl:if test="count(sbr) != 1"> 263 <xsl:message terminate="yes">Currently only support a single sbr element in a cmdsynopsis. Sorry.</xsl:message> 264 </xsl:if> 265 <xsl:element name="syntaxdiagram"> 266 <xsl:attribute name="rev">cmdsynopsis</xsl:attribute> 267 <xsl:if test="@id"> 268 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 269 </xsl:if> 270 <xsl:element name="groupcomp"> 271 <xsl:apply-templates select="sbr[1]/preceding-sibling::node()"/> 272 </xsl:element> 273 <xsl:apply-templates select="sbr[1]/following-sibling::node()"/> 274 </xsl:element> 275 </xsl:template> 276 277 278 <!-- command in cmdsynopsis -> groupseq + kwd --> 257 <xsl:for-each select="sbr"> 258 <xsl:variable name="idxSbr" select="position()"/> 259 <xsl:element name="groupcomp"> 260 <xsl:attribute name="rev">sbr/<xsl:value-of select="position()"/></xsl:attribute> 261 262 <xsl:if test="$idxSbr = 1"> 263 <xsl:apply-templates select="preceding-sibling::node()"/> 264 </xsl:if> 265 <xsl:if test="$idxSbr != 1"> 266 <xsl:apply-templates select="preceding-sibling::node()[ count(. | ../sbr[$idxSbr - 1]/following-sibling::node()) 267 = count(../sbr[$idxSbr - 1]/following-sibling::node())]"/> 268 </xsl:if> 269 <xsl:if test="$idxSbr = last()"> 270 <xsl:apply-templates select="following-sibling::node()"/> 271 </xsl:if> 272 </xsl:element> 273 </xsl:for-each> 274 </xsl:element> 275 </xsl:template> 276 277 <!-- command with text and/or replaceable in cmdsynopsis -> groupseq + kwd --> 279 278 <xsl:template match="cmdsynopsis/command | cmdsynopsis/*/command" > 280 279 <xsl:element name="groupseq"> 281 280 <xsl:attribute name="rev">command</xsl:attribute> 282 <xsl:element name="kwd"> 283 <xsl:attribute name="rev">command</xsl:attribute> 284 <xsl:apply-templates /> 285 </xsl:element> 286 </xsl:element> 287 </xsl:template> 288 289 <!-- command in not cmdsynopsis -> userinput --> 290 <xsl:template match="command"> 281 <xsl:apply-templates /> 282 </xsl:element> 283 </xsl:template> 284 285 <xsl:template match="cmdsynopsis/command/text() | cmdsynopsis/*/command/text()" > 286 <xsl:element name="kwd"> 287 <xsl:attribute name="rev">command/text</xsl:attribute> 288 <xsl:value-of select="."/> 289 </xsl:element> 290 </xsl:template> 291 292 <xsl:template match="cmdsynopsis/command/replaceable | cmdsynopsis/*/command/replaceable" > 293 <xsl:call-template name="check-children"/> 294 <xsl:element name="var"> 295 <xsl:attribute name="rev">command/replaceable</xsl:attribute> 296 <xsl:apply-templates /> 297 </xsl:element> 298 </xsl:template> 299 300 <!-- command with text and/or replaceable in not cmdsynopsis -> userinput + cmdname --> 301 <xsl:template match="command[not(ancestor::cmdsynopsis)]"> 291 302 <xsl:element name="userinput"> 292 303 <xsl:attribute name="rev">command</xsl:attribute> 293 304 <xsl:apply-templates /> 305 </xsl:element> 306 </xsl:template> 307 308 <xsl:template match="command[not(ancestor::cmdsynopsis)]/text()"> 309 <xsl:element name="cmdname"> 310 <xsl:attribute name="rev">command/text</xsl:attribute> 311 <xsl:value-of select="."/> 312 </xsl:element> 313 </xsl:template> 314 315 <xsl:template match="command[not(ancestor::cmdsynopsis)]/replaceable"> 316 <xsl:call-template name="check-children"/> 317 <xsl:element name="varname"> 318 <xsl:attribute name="rev">command/replaceable</xsl:attribute> 319 <xsl:value-of select="."/> 294 320 </xsl:element> 295 321 </xsl:template> … … 319 345 </xsl:template> 320 346 321 <xsl:template match="arg[not( *) and not(ancestor::group) and ancestor::cmdsynopsis and @choice='plain' and (not(@rep) or @rep='norepeat')]" >347 <xsl:template match="arg[not(ancestor::group) and ancestor::cmdsynopsis and @choice='plain' and (not(@rep) or @rep='norepeat')]" > 322 348 <xsl:element name="kwd"> 323 349 <xsl:attribute name="rev">arg[plain]</xsl:attribute> … … 327 353 328 354 <xsl:template match="group/arg[replaceable and @choice='plain' and (not(@rep) or @rep='norepeat')]" > 329 <xsl:if test="./*[not(self::replaceable)] or ./text()"> 330 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/> 331 Did not expect group/arg[@choice=plain] to have children other than replaceable: 332 <xsl:for-each select="./*|./text()"> 333 <xsl:value-of select="concat(', ', name(.))"/> 334 </xsl:for-each> 335 </xsl:message> 336 </xsl:if> 355 <xsl:call-template name="check-children"> 356 <xsl:with-param name="UnsupportedNodes" select="*[not(self::replaceable)]"/> 357 <xsl:with-param name="SupportedNames">replaceable or text()</xsl:with-param> 358 </xsl:call-template> 337 359 <xsl:element name="var"> 338 360 <xsl:attribute name="rev">arg[plain]/replaceable</xsl:attribute> … … 342 364 343 365 <xsl:template match="group/arg[@choice='plain' and (not(@rep) or @rep='norepeat') and not(replaceable)]" > 344 <xsl:if test="./*"> 345 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Did not expect arg[@choice=plain] to have children 346 <xsl:for-each select="./*"> 347 <xsl:text> 348 </xsl:text> 349 <xsl:value-of select="name()"/> 350 </xsl:for-each> 351 </xsl:message> 352 </xsl:if> 366 <xsl:call-template name="check-children" /> 353 367 <xsl:element name="kwd"> 354 368 <xsl:attribute name="rev">arg[plain]</xsl:attribute> … … 513 527 <xsl:element name="xref"> 514 528 <xsl:attribute name="href"><xsl:value-of select="@linkend"/></xsl:attribute> 515 <xsl:if test="contains(@linkend, 'http')"> 516 <xsl:attribute name="scope">external</xsl:attribute> 517 <xsl:apply-templates /> 518 </xsl:if> 529 <xsl:if test="contains(@linkend, 'http')"><xsl:message terminate="yes">xref/linkend with http</xsl:message></xsl:if> 530 </xsl:element> 531 </xsl:template> 532 533 <!-- ulink -> xref --> 534 <xsl:template match="ulink"> 535 <xsl:element name="xref"> 536 <xsl:attribute name="rev">ulink</xsl:attribute> 537 <xsl:attribute name="scope">external</xsl:attribute> <!-- Just assumes this is external. --> 538 <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute> 519 539 </xsl:element> 520 540 </xsl:template> … … 590 610 </xsl:template> 591 611 612 <!-- 613 Debug/Diagnostics: Print list of nodes (by default all children of current node). 614 --> 615 <xsl:template name="list-nodes"> 616 <xsl:param name="Nodes" select="node()"/> 617 <xsl:for-each select="$Nodes"> 618 <xsl:if test="position() != 1"> 619 <xsl:text>, </xsl:text> 620 </xsl:if> 621 <xsl:choose> 622 <xsl:when test="name(.) = ''"> 623 <xsl:text>text:text()</xsl:text> 624 </xsl:when> 625 <xsl:otherwise> 626 <xsl:value-of select="name(.)"/> 627 <xsl:if test="@id"> 628 <xsl:text>[@id=</xsl:text> 629 <xsl:value-of select="@id"/> 630 <xsl:text>]</xsl:text> 631 </xsl:if> 632 </xsl:otherwise> 633 </xsl:choose> 634 </xsl:for-each> 635 </xsl:template> 636 637 <xsl:template name="check-children"> 638 <xsl:param name="Node" select="."/> 639 <xsl:param name="UnsupportedNodes" select="*"/> 640 <xsl:param name="SupportedNames" select="'none'"/> 641 <xsl:if test="count($UnsupportedNodes) != 0"> 642 <xsl:message terminate="yes"> 643 <xsl:call-template name="get-node-path"> 644 <xsl:with-param name="Node" select="$Node"/> 645 </xsl:call-template> 646 <!-- -->: error: Only <xsl:value-of select="$SupportedNames"/> are supported as children to <!-- --> 647 <xsl:value-of select="name($Node)"/> 648 <!-- --> 649 Unsupported children: <!-- --> 650 <xsl:call-template name="list-nodes"> 651 <xsl:with-param name="Nodes" select="$UnsupportedNodes"/> 652 </xsl:call-template> 653 </xsl:message> 654 </xsl:if> 655 </xsl:template> 656 592 657 </xsl:stylesheet> 593 658
Note:
See TracChangeset
for help on using the changeset viewer.