Skip to content

Commit 6c2f03f

Browse files
committed
Introduce id's and linkends
* Introduce id's for <deliverable>, <product>, <docset> * Add idabbrev in transformation map. This is to abbreviate long product IDs to make it more readable for <deliverable> id's. * Introduce id.sep parameter * Don't copy PIs for product and docset * Convert old ids into new "id": * productid -> id * setid -> id * Rewrite <ref .../> into one single reference: <ref linkend="..."/> * Create generate.id: abbrev-product-id [+ $id.sep + docset [+ $id.sep + dc.lowercase]?]? * The ID values for a deliverable ID are generated by
1 parent 6fcb4bc commit 6c2f03f

1 file changed

Lines changed: 128 additions & 52 deletions

File tree

src/docbuild/config/xml/data/convert-v6-to-v7.xsl

Lines changed: 128 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@
5252
<!-- Set the schemaversion attribute in the output XML -->
5353
<xsl:param name="schemaversion">7.0</xsl:param>
5454

55+
<!-- ID separator for autogenerated IDs -->
56+
<xsl:param name="id.sep">.</xsl:param>
57+
58+
5559
<!-- ======== Keys -->
5660
<!-- Define a key to group <language> elements by their @lang attribute -->
5761
<xsl:key name="langKey" match="category/language[not(ancestor-or-self::product)]" use="@lang" />
5862

63+
5964
<!-- ======== Variables -->
6065
<xsl:variable name="_transformation-map">
6166
<!--
@@ -65,21 +70,22 @@
6570
* family (str): the product family that this product belongs
6671
* rank (int): The product rank that influences the tiles on the portal homepage
6772
* externals (bool): Convert external links into <deliverable> and <prebuilt> elements
73+
* idabbrev (str): The product ID abbreviation used in <deliverable id="...">
6874
-->
6975
<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"/>
7682
<product id="sbp" series="sbp" family="linux" />
7783
<product id="ses" series="pas" family="linux" rank="04160" />
7884
<product id="sled" series="pas" family="linux" rank="04100" />
7985
<product id="sle-ha" series="pas" family="linux" rank="04070" />
8086
<product id="sle-hpc" series="pas" family="linux" rank="04110" />
8187
<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" />
8389
<product id="sle-rt" series="pas" family="linux" rank="04080" />
8490
<product id="sles-sap" series="pas" family="linux" rank="00050" />
8591
<product id="sles" series="pas" family="linux" rank="00080" />
@@ -88,13 +94,13 @@
8894
<product id="smt" series="pas" family="linux" rank="04330" />
8995
<product id="soc" series="pas" family="linux" rank="04300" />
9096
<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" />
9298
<product id="suma" series="pas" family="linux" rank="" externals="1" />
9399
<product id="suma-retail" series="pas" family="linux" externals="1" />
94100
<product id="suma-ai" series="pas" family="suse-ai" rank="00010" />
95101
<product id="suma-caasp" series="pas" family="linux" rank="04310" />
96102
<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" />
98104
<product id="suma-edge" series="pas" family="suse-edge" rank="00040" />
99105
<product id="trd" series="trd" family="linux" />
100106
</config>
@@ -218,6 +224,24 @@
218224
</xsl:if>
219225
</xsl:template>
220226

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+
221245

222246
<!-- ======== General Templates -->
223247
<xsl:template match="node() | @*" name="copy">
@@ -303,6 +327,18 @@
303327
</xsl:template>
304328

305329
<!-- 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+
306342
<xsl:template match="product">
307343
<xsl:variable name="id" select="@productid" />
308344
<xsl:variable name="cnfg" select="$config/product[@id=$id]" />
@@ -369,15 +405,25 @@
369405
<!-- We ignore the product/category as this was moved to portal/categories -->
370406
<xsl:template match="product/category" />
371407

408+
<xsl:template match="product/@productid">
409+
<xsl:attribute name="id">
410+
<xsl:value-of select="."/>
411+
</xsl:attribute>
412+
</xsl:template>
413+
372414
<!-- Docset -->
415+
<xsl:template match="docset/@schemaversion" />
416+
<xsl:template match="docset/processing-instruction()" />
417+
373418
<xsl:template match="docset">
374419
<xsl:variable name="id" select="ancestor::product/@productid"/>
375420
<xsl:variable name="ver" select="@setid"/>
376421
<xsl:variable name="subpath" select="concat($id, '/', $ver, '.xml')"/>
377422

378-
379423
<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>
381427
</xsl:variable>
382428

383429
<xsl:call-template name="write.chunk">
@@ -387,32 +433,14 @@
387433
</xsl:call-template>
388434
</xsl:template>
389435

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">
402437
<xsl:attribute name="id">
403-
<xsl:value-of select="$id" />
438+
<xsl:value-of select="concat(ancestor::product/@productid, $id.sep, .)" />
404439
</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="."/>
412442
</xsl:attribute>
413-
</xsl:template>-->
414-
415-
<xsl:template match="docset/@schemaversion" />
443+
</xsl:template>
416444

417445
<xsl:template match="docset/overridedesc">
418446
<descriptions>
@@ -428,43 +456,91 @@
428456
</xsl:template>
429457

430458
<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+
431463
<locale>
432464
<xsl:copy-of select="@lang" /><!-- no default attribute -->
433465
<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>
434472
</locale>
435473
</xsl:template>
436474

437475

438476
<!-- 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">
441490
<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>
449491
<xsl:apply-templates />
450-
</xsl:copy>
492+
</deliverable>
451493
</xsl:template>
452494

453495
<!-- ref -->
454496
<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 &lt;ref <xsl:for-each select="@*">
526+
<xsl:value-of select="concat(local-name(.), '=&quot;', ., '&quot; ')"/>
527+
</xsl:for-each>
528+
<xsl:text>/&gt;</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"/>
462539
</ref>
463540
</xsl:template>
464541

465542

466543
<!-- desc -->
467544
<xsl:template match="desc/@default" />
468545

469-
470546
</xsl:stylesheet>

0 commit comments

Comments
 (0)