|
52 | 52 | <!-- Set the schemaversion attribute in the output XML --> |
53 | 53 | <xsl:param name="schemaversion">7.0</xsl:param> |
54 | 54 |
|
| 55 | + <!-- ID separator for autogenerated IDs --> |
| 56 | + <xsl:param name="id.sep">.</xsl:param> |
| 57 | + |
| 58 | + |
55 | 59 | <!-- ======== Keys --> |
56 | 60 | <!-- Define a key to group <language> elements by their @lang attribute --> |
57 | 61 | <xsl:key name="langKey" match="category/language[not(ancestor-or-self::product)]" use="@lang" /> |
58 | 62 |
|
| 63 | + |
59 | 64 | <!-- ======== Variables --> |
60 | 65 | <xsl:variable name="_transformation-map"> |
61 | 66 | <!-- |
|
65 | 70 | * family (str): the product family that this product belongs |
66 | 71 | * rank (int): The product rank that influences the tiles on the portal homepage |
67 | 72 | * externals (bool): Convert external links into <deliverable> and <prebuilt> elements |
| 73 | + * idabbrev (str): The product ID abbreviation used in <deliverable id="..."> |
68 | 74 | --> |
69 | 75 | <config> |
70 | | - <product id="appliance" series="pas" family="linux" rank="04150" /> |
71 | | - <product id="cloudnative" series="pas" family="cn" rank="00030" /> |
72 | | - <product id="container" series="pas" family="linux" rank="04130" externals="1" /> |
73 | | - <product id="compliance" series="pas" family="linux" rank="" /> |
74 | | - <product id="liberty" series="pas" family="linux" rank="00060" /> |
75 | | - <product id="releasenotes" series="rn" family="linux" /> |
| 76 | + <product id="appliance" series="pas" family="linux" rank="04150" idabbrev="app"/> |
| 77 | + <product id="cloudnative" series="pas" family="cn" rank="00030" idabbrev="cn" /> |
| 78 | + <product id="container" series="pas" family="linux" rank="04130" externals="1" idabbrev="cont" /> |
| 79 | + <product id="compliance" series="pas" family="linux" rank="" idabbrev="comp" /> |
| 80 | + <product id="liberty" series="pas" family="linux" rank="00060" idabbrev="lib" /> |
| 81 | + <product id="releasenotes" series="rn" family="linux" idabbrev="rn"/> |
76 | 82 | <product id="sbp" series="sbp" family="linux" /> |
77 | 83 | <product id="ses" series="pas" family="linux" rank="04160" /> |
78 | 84 | <product id="sled" series="pas" family="linux" rank="04100" /> |
79 | 85 | <product id="sle-ha" series="pas" family="linux" rank="04070" /> |
80 | 86 | <product id="sle-hpc" series="pas" family="linux" rank="04110" /> |
81 | 87 | <product id="sle-micro" series="pas" family="linux" rank="00020" /> |
82 | | - <product id="sle-public-cloud" series="pas" family="linux" rank="04060" /> |
| 88 | + <product id="sle-public-cloud" series="pas" family="linux" rank="04060" idabbrev="spc" /> |
83 | 89 | <product id="sle-rt" series="pas" family="linux" rank="04080" /> |
84 | 90 | <product id="sles-sap" series="pas" family="linux" rank="00050" /> |
85 | 91 | <product id="sles" series="pas" family="linux" rank="00080" /> |
|
88 | 94 | <product id="smt" series="pas" family="linux" rank="04330" /> |
89 | 95 | <product id="soc" series="pas" family="linux" rank="04300" /> |
90 | 96 | <product id="style" series="pas" family="linux" /> |
91 | | - <product id="subscription" series="pas" family="linux" rank="04140" /> |
| 97 | + <product id="subscription" series="pas" family="linux" rank="04140" idabbrev="sub" /> |
92 | 98 | <product id="suma" series="pas" family="linux" rank="" externals="1" /> |
93 | 99 | <product id="suma-retail" series="pas" family="linux" externals="1" /> |
94 | 100 | <product id="suma-ai" series="pas" family="suse-ai" rank="00010" /> |
95 | 101 | <product id="suma-caasp" series="pas" family="linux" rank="04310" /> |
96 | 102 | <product id="suma-cap" series="pas" family="linux" rank="04320"/> |
97 | | - <product id="suma-distribution-migration-system" series="pas" family="linux" /> |
| 103 | + <product id="suma-distribution-migration-system" series="pas" family="linux" idabbrev="suma-dms" /> |
98 | 104 | <product id="suma-edge" series="pas" family="suse-edge" rank="00040" /> |
99 | 105 | <product id="trd" series="trd" family="linux" /> |
100 | 106 | </config> |
|
218 | 224 | </xsl:if> |
219 | 225 | </xsl:template> |
220 | 226 |
|
| 227 | + <xsl:template name="generate.id"> |
| 228 | + <xsl:param name="product.idabbrev"/> |
| 229 | + <xsl:param name="docset"/> |
| 230 | + <xsl:param name="dc"/> |
| 231 | + |
| 232 | + <xsl:value-of select="$product.idabbrev"/> |
| 233 | + |
| 234 | + <xsl:if test="string($docset)"> |
| 235 | + <xsl:value-of select="$id.sep"/> |
| 236 | + <xsl:value-of select="$docset"/> |
| 237 | + </xsl:if> |
| 238 | + |
| 239 | + <xsl:if test="string($dc)"> |
| 240 | + <xsl:value-of select="$id.sep"/> |
| 241 | + <xsl:value-of select="translate($dc, &uppercase;, &lowercase;)"/> |
| 242 | + </xsl:if> |
| 243 | + </xsl:template> |
| 244 | + |
221 | 245 |
|
222 | 246 | <!-- ======== General Templates --> |
223 | 247 | <xsl:template match="node() | @*" name="copy"> |
|
303 | 327 | </xsl:template> |
304 | 328 |
|
305 | 329 | <!-- Product --> |
| 330 | + <!-- don't copy these attributes --> |
| 331 | + <xsl:template match="product/processing-instruction()" /> |
| 332 | + <xsl:template match="product/@schemaversion" /> |
| 333 | + <xsl:template match="product/@site-section" /> |
| 334 | + |
| 335 | + <xsl:template match="product/@productid"> |
| 336 | + <xsl:variable name="id" select="." /> |
| 337 | + <xsl:attribute name="id"> |
| 338 | + <xsl:value-of select="$id" /> |
| 339 | + </xsl:attribute> |
| 340 | + </xsl:template> |
| 341 | + |
306 | 342 | <xsl:template match="product"> |
307 | 343 | <xsl:variable name="id" select="@productid" /> |
308 | 344 | <xsl:variable name="cnfg" select="$config/product[@id=$id]" /> |
|
369 | 405 | <!-- We ignore the product/category as this was moved to portal/categories --> |
370 | 406 | <xsl:template match="product/category" /> |
371 | 407 |
|
| 408 | + <xsl:template match="product/@productid"> |
| 409 | + <xsl:attribute name="id"> |
| 410 | + <xsl:value-of select="."/> |
| 411 | + </xsl:attribute> |
| 412 | + </xsl:template> |
| 413 | + |
372 | 414 | <!-- Docset --> |
| 415 | + <xsl:template match="docset/@schemaversion" /> |
| 416 | + <xsl:template match="docset/processing-instruction()" /> |
| 417 | + |
373 | 418 | <xsl:template match="docset"> |
374 | 419 | <xsl:variable name="id" select="ancestor::product/@productid"/> |
375 | 420 | <xsl:variable name="ver" select="@setid"/> |
376 | 421 | <xsl:variable name="subpath" select="concat($id, '/', $ver, '.xml')"/> |
377 | 422 |
|
378 | | - |
379 | 423 | <xsl:variable name="content"> |
380 | | - <xsl:apply-templates select="." mode="render"/> |
| 424 | + <docset xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 425 | + <xsl:apply-templates select="@*|node()" /> |
| 426 | + </docset> |
381 | 427 | </xsl:variable> |
382 | 428 |
|
383 | 429 | <xsl:call-template name="write.chunk"> |
|
387 | 433 | </xsl:call-template> |
388 | 434 | </xsl:template> |
389 | 435 |
|
390 | | - <xsl:template match="docset" mode="render"> |
391 | | - <xsl:copy> |
392 | | - <xsl:apply-templates select="node()|@*"/> |
393 | | - </xsl:copy> |
394 | | - </xsl:template> |
395 | | - |
396 | | - <!-- don't copy these attributes --> |
397 | | - <xsl:template match="product/@schemaversion" /> |
398 | | - <xsl:template match="product/@site-section" /> |
399 | | - |
400 | | - <xsl:template match="product/@productid"> |
401 | | - <xsl:variable name="id" select="." /> |
| 436 | +q <xsl:template match="docset/@setid"> |
402 | 437 | <xsl:attribute name="id"> |
403 | | - <xsl:value-of select="$id" /> |
| 438 | + <xsl:value-of select="concat(ancestor::product/@productid, $id.sep, .)" /> |
404 | 439 | </xsl:attribute> |
405 | | - </xsl:template> |
406 | | - |
407 | | - |
408 | | - <!--<xsl:template match="docset/@setid"> |
409 | | - <xsl:variable name="id" select="." /> |
410 | | - <xsl:attribute name="id"> |
411 | | - <xsl:value-of select="$id"/> |
| 440 | + <xsl:attribute name="path"> |
| 441 | + <xsl:value-of select="."/> |
412 | 442 | </xsl:attribute> |
413 | | - </xsl:template>--> |
414 | | - |
415 | | - <xsl:template match="docset/@schemaversion" /> |
| 443 | + </xsl:template> |
416 | 444 |
|
417 | 445 | <xsl:template match="docset/overridedesc"> |
418 | 446 | <descriptions> |
|
428 | 456 | </xsl:template> |
429 | 457 |
|
430 | 458 | <xsl:template match="docset/builddocs/language"> |
| 459 | + <xsl:variable name="pid" select="ancestor::product/@productid"/> |
| 460 | + <xsl:variable name="do_externals" select="$config[@id=$pid]/@externals"/> |
| 461 | + <xsl:variable name="current_lang" select="@lang"/> |
| 462 | + |
431 | 463 | <locale> |
432 | 464 | <xsl:copy-of select="@lang" /><!-- no default attribute --> |
433 | 465 | <xsl:apply-templates /> |
| 466 | + |
| 467 | + <xsl:if test="$do_externals"> |
| 468 | + <xsl:apply-templates select="../../external/link[language[@lang = $current_lang]]" mode="convert-to-prebuilt"> |
| 469 | + <xsl:with-param name="lang" select="$current_lang"/> |
| 470 | + </xsl:apply-templates> |
| 471 | + </xsl:if> |
434 | 472 | </locale> |
435 | 473 | </xsl:template> |
436 | 474 |
|
437 | 475 |
|
438 | 476 | <!-- deliverable --> |
439 | | - <xsl:template match="deliverable"> |
440 | | - <xsl:copy> |
| 477 | + <xsl:template match="language[@lang='en-us']/deliverable"> |
| 478 | + <xsl:variable name="pid" select="ancestor::product/@productid"/> |
| 479 | + <xsl:variable name="abbrev" select="$config/product[@id=$pid]/@idabbrev"/> |
| 480 | + <xsl:variable name="product.idabbrev" select="$abbrev | $pid[not($abbrev)]"/> |
| 481 | + <xsl:variable name="id"> |
| 482 | + <xsl:call-template name="generate.id"> |
| 483 | + <xsl:with-param name="product.idabbrev" select="$product.idabbrev"/> |
| 484 | + <xsl:with-param name="docset" select="ancestor::docset/@setid"/> |
| 485 | + <xsl:with-param name="dc" select="dc"/> |
| 486 | + </xsl:call-template> |
| 487 | + </xsl:variable> |
| 488 | + |
| 489 | + <deliverable id="{$id}" type="dc"> |
441 | 490 | <xsl:copy-of select="@*"/> |
442 | | - <xsl:if test="../language/@lang='en-us'"> |
443 | | - <!-- Add id attribute only for English to keep it unique --> |
444 | | - <xsl:attribute name="id"> |
445 | | - <xsl:value-of select=" substring-after(translate(dc, &uppercase;, &lowercase;), 'dc-')"/> |
446 | | - </xsl:attribute> |
447 | | - </xsl:if> |
448 | | - <xsl:attribute name="type">dc</xsl:attribute> |
449 | 491 | <xsl:apply-templates /> |
450 | | - </xsl:copy> |
| 492 | + </deliverable> |
451 | 493 | </xsl:template> |
452 | 494 |
|
453 | 495 | <!-- ref --> |
454 | 496 | <xsl:template match="ref"> |
455 | | - <ref> |
456 | | - <xsl:copy-of select="@product|@docset|@category|@titleformat|@subdeliverable"/> |
457 | | - <xsl:if test="@dc"> |
458 | | - <xsl:attribute name="deliverable"> |
459 | | - <xsl:value-of select="@dc" /> |
460 | | - </xsl:attribute> |
461 | | - </xsl:if> |
| 497 | + <xsl:variable name="pid" select="@product"/> |
| 498 | + <xsl:variable name="cnfg" select="$config/product[@id=$pid]"/> |
| 499 | + <xsl:variable name="abbrev" select="$cnfg/@idabbrev"/> |
| 500 | + <xsl:variable name="product.idabbrev" select="$abbrev | $pid[not($abbrev)]"/> |
| 501 | + <xsl:variable name="ref" > |
| 502 | + <xsl:choose> |
| 503 | + <xsl:when test="not(@docset) and not(@dc)"> |
| 504 | + <xsl:call-template name="generate.id"> |
| 505 | + <xsl:with-param name="product.idabbrev" select="$product.idabbrev"/> |
| 506 | + </xsl:call-template> |
| 507 | + </xsl:when> |
| 508 | + <xsl:when test="@product and @docset and not(@dc)"> |
| 509 | + <xsl:call-template name="generate.id"> |
| 510 | + <xsl:with-param name="product.idabbrev" select="$product.idabbrev"/> |
| 511 | + <xsl:with-param name="docset" select="@docset"/> |
| 512 | + </xsl:call-template> |
| 513 | + </xsl:when> |
| 514 | + <xsl:when test="@product and @docset and @dc"> |
| 515 | + <xsl:call-template name="generate.id"> |
| 516 | + <xsl:with-param name="product.idabbrev" select="$product.idabbrev"/> |
| 517 | + <xsl:with-param name="docset" select="@docset"/> |
| 518 | + <xsl:with-param name="dc" select="@dc"/> |
| 519 | + </xsl:call-template> |
| 520 | + </xsl:when> |
| 521 | + <xsl:when test="@deliverable"> |
| 522 | + <xsl:value-of select="concat(@product, $id.sep, @docset, $id.sep, @deliverable)"/> |
| 523 | + </xsl:when> |
| 524 | + <xsl:otherwise> |
| 525 | + <xsl:message>WARN: Couldn't create a linkend for <ref <xsl:for-each select="@*"> |
| 526 | + <xsl:value-of select="concat(local-name(.), '="', ., '" ')"/> |
| 527 | + </xsl:for-each> |
| 528 | + <xsl:text>/></xsl:text> |
| 529 | + </xsl:message> |
| 530 | + </xsl:otherwise> |
| 531 | + </xsl:choose> |
| 532 | + </xsl:variable> |
| 533 | + <!--<xsl:message>ref: <xsl:value-of select="count($cnfg)"/> |
| 534 | + product=<xsl:value-of select="concat(@product, '::', $pid)"/> |
| 535 | + idabbrev=<xsl:value-of select="$abbrev"/> |
| 536 | + </xsl:message>--> |
| 537 | + <ref linkend="{$ref}"> |
| 538 | + <xsl:copy-of select="@category|@titleformat"/> |
462 | 539 | </ref> |
463 | 540 | </xsl:template> |
464 | 541 |
|
465 | 542 |
|
466 | 543 | <!-- desc --> |
467 | 544 | <xsl:template match="desc/@default" /> |
468 | 545 |
|
469 | | - |
470 | 546 | </xsl:stylesheet> |
0 commit comments