1 <?xml version="1.0" encoding="UTF-8"?>
 
   2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
   3                                 xmlns:d="http://docbook.org/ns/docbook"
 
   4                                 xmlns="http://www.w3.org/1999/xhtml"
 
   5                                 exclude-result-prefixes="d"
 
   9         <!-- no separate HTML page with index as this is binary in hv1 -->
 
  10         <xsl:param name="generate.index" select="0"/>
 
  13         <!-- Generate help tags in header -->
 
  14         <xsl:template name="user.head.content">
 
  15                 <xsl:param name="node" select="''" />
 
  16                 <xsl:variable name="up" select="parent::*"/>
 
  18                 <!-- Locale should be first Help tag-->
 
  19                 <meta name="Microsoft.Help.Locale">
 
  20                         <xsl:attribute name="content">
 
  22                                         <xsl:when test="$product.locale and product.locale != ''">
 
  23                                                 <xsl:value-of select="$product.locale"/>
 
  26                                                 <xsl:text>en-US</xsl:text>
 
  32                 <!-- Specify locale for this chunk. Should probably query xml:lang -->
 
  33                 <meta name="Microsoft.Help.TopicLocale">
 
  34                         <xsl:attribute name="content">
 
  36                                         <xsl:when test="@xml:lang">
 
  37                                                 <xsl:value-of select="@xml:lang"/>
 
  39                                         <xsl:when test="$product.locale and product.locale != ''">
 
  40                                                 <xsl:value-of select="$product.locale"/>
 
  43                                                 <xsl:text>en-US</xsl:text>
 
  49                 <!-- This is the unique ID for this page -->
 
  50                 <meta name="Microsoft.Help.Id">
 
  51                         <xsl:attribute name="content">
 
  52                                 <xsl:call-template name="hv1.toc.id"/>
 
  56                 <!-- The ID of the parent TOC node (-1 is root) -->
 
  57                 <meta name="Microsoft.Help.TocParent">
 
  58                         <xsl:attribute name="content">
 
  59                                 <xsl:call-template name="hv1.toc.parent.id">
 
  60                                         <xsl:with-param name="up" select="$up"/>
 
  65                 <!-- For all pages with the same parent, the order is set by TocOrder -->
 
  66                 <meta name="Microsoft.Help.TocOrder">
 
  67                         <xsl:attribute name="content">
 
  68                                 <xsl:value-of select="1+count(preceding-sibling::chapter|preceding-sibling::section)"/>
 
  72                 <!-- boolean to indicate if this page is allowed to load custom branding -->
 
  73                 <meta name="Microsoft.Help.SelfBranded">
 
  74                         <xsl:attribute name="content">
 
  76                                         <xsl:when test="$topic.selfbrand">
 
  77                                                 <xsl:text>true</xsl:text>
 
  80                                                 <xsl:text>false</xsl:text>
 
  87                         Insert description meta element. This is shown in searches and indexes
 
  90                 <xsl:variable name="description">
 
  91                         <xsl:call-template name="hv1.description"/>
 
  93                 <xsl:if test="$description != ''">
 
  94                         <meta name="Description">
 
  95                                 <xsl:attribute name="content">
 
  96                                         <xsl:call-template name="hv1.description"/>
 
 101                 <!-- Display version of page -->
 
 102                 <xsl:variable name="display.version">
 
 103                         <xsl:call-template name="hv1.display.version"/>
 
 105                 <xsl:if test="$display.version != ''">
 
 106                         <meta name="Microsoft.Help.DisplayVersion">
 
 107                                 <xsl:attribute name="content">
 
 108                                         <xsl:value-of select="$display.version"/>
 
 114                         Content type is used to distinguish between multiple topics with same id.
 
 115                         Usualy to have multiple versions available
 
 118                 <meta name="Microsoft.Help.ContentType">
 
 119                         <xsl:attribute name="content">
 
 126                 <!-- If a product name is given, then mark each header with this name-->
 
 127                 <xsl:if test="$product.name and $product.name != ''">
 
 128                         <meta name="Microsoft.Help.Product">
 
 129                                 <xsl:attribute name="content">
 
 130                                         <xsl:value-of select="$product.name"/>
 
 135                 <!-- If a version is given, then mark each header with version-->
 
 136                 <xsl:if test="$product.version and $product.version != ''">
 
 137                         <meta name="Microsoft.Help.ProductVersion">
 
 138                                 <xsl:attribute name="content">
 
 139                                         <xsl:value-of select="$product.version"/>
 
 145                         Insert all keywords for this chunk. These are used
 
 146                         by the help runtime to generate indexes and refine search
 
 148                 <xsl:call-template name="hv1.keywords" />
 
 151                         Insert all F1 ids for this chunk. This is used
 
 152                         by the help runtime to resolve F1 queries
 
 154                 <xsl:call-template name="hv1.f1" />
 
 158         <!-- There are links from ToC pane to bibliodivs, so there must be anchor -->
 
 159         <xsl:template match="bibliodiv/title">
 
 160                 <h3 class="{name(.)}">
 
 161                         <xsl:call-template name="anchor">
 
 162                                 <xsl:with-param name="node" select=".."/>
 
 163                                 <xsl:with-param name="conditional" select="0"/>
 
 165                         <xsl:apply-templates/>
 
 170                 Template to get a page id.
 
 172                 Needs to be unique in the target help system; microsoft uses UUIDs for this.
 
 173                 To avoid UUIDs and generate-id (only unique in current xml fragment),
 
 176                                 <last ancestor title> +
 
 177                                         <second last ancestor title> +
 
 179                                                 <self title>,   where different types of sections/fragments
 
 180                                                                                         may be prefixed with a type identifier.
 
 182                 This should generate a fairly specific/unique ID.
 
 184         <xsl:template name="get.id.from.pagename">
 
 185                 <xsl:param name="target" />
 
 186                 <xsl:value-of select="$root.filename"/>
 
 187                 <xsl:variable name="id.of.document">
 
 188                         <xsl:apply-templates select="$target" mode="recursive-chunk-id"/>
 
 190                 <xsl:variable name="titleWithSpace">
 
 191                         <xsl:value-of select="key('id',$id.of.document)/title"/>
 
 193                 <xsl:value-of select="translate($id.of.document,' ','')" />
 
 196         <!-- template that returns the page id used above -->
 
 197         <xsl:template match="*" mode="recursive-chunk-id">
 
 198                 <xsl:param name="recursive" select="false()"/>
 
 200                 <!-- returns the filename of a chunk -->
 
 201                 <xsl:variable name="ischunk">
 
 202                         <xsl:call-template name="chunk"/>
 
 205                 <xsl:variable name="dbhtml-filename">
 
 206                         <xsl:call-template name="pi.dbhtml_filename"/>
 
 209                 <xsl:variable name="filename">
 
 211                                 <xsl:when test="$dbhtml-filename != ''">
 
 212                                         <xsl:value-of select="$dbhtml-filename"/>
 
 214                                 <!-- if this is the root element, use the root.filename -->
 
 215                                 <xsl:when test="not(parent::*) and $root.filename != ''">
 
 216                                         <xsl:value-of select="$root.filename"/>
 
 217                                         <!-- <xsl:value-of select="$html.ext"/> -->
 
 219                                 <!-- Special case -->
 
 220                                 <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
 
 222                                                 <xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)">
 
 223                                                         <!-- * if this legalnotice has an ID, then go ahead and use -->
 
 224                                                         <!-- * just the value of that ID as the basename for the file -->
 
 225                                                         <!-- * (that is, without prepending an "ln-" too it) -->
 
 226                                                         <xsl:value-of select="(@id|@xml:id)[1]"/>
 
 227                                                         <!-- <xsl:value-of select="$html.ext"/>-->
 
 230                                                         <!-- * otherwise, if this legalnotice does not have an ID, -->
 
 231                                                         <!-- * then we generate an ID... -->
 
 232                                                         <xsl:variable name="id">
 
 233                                                                 <xsl:call-template name="object.id"/>
 
 235                                                         <!-- * ...and then we take that generated ID, prepend an -->
 
 236                                                         <!-- * "ln-" to it, and use that as the basename for the file -->
 
 237                                                         <!-- <xsl:value-of select="concat('ln-',$id,$html.ext)"/>-->
 
 241                                 <!-- if there's no dbhtml filename, and if we're to use IDs as -->
 
 242                                 <!-- filenames, then use the ID to generate the filename. -->
 
 243                                 <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
 
 244                                         <xsl:value-of select="(@id|@xml:id)[1]"/>
 
 245                                         <!-- <xsl:value-of select="$html.ext"/>-->
 
 252                         <xsl:when test="$ischunk='0'">
 
 253                                 <!-- if called on something that isn't a chunk, walk up... -->
 
 255                                         <xsl:when test="count(parent::*)>0">
 
 256                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 257                                                         <xsl:with-param name="recursive" select="$recursive"/>
 
 258                                                 </xsl:apply-templates>
 
 260                                         <!-- unless there is no up, in which case return "" -->
 
 265                         <xsl:when test="not($recursive) and $filename != ''">
 
 266                                 <!-- if this chunk has an explicit name, use it -->
 
 267                                 <xsl:value-of select="$filename"/>
 
 270                         <xsl:when test="self::set">
 
 271                                 <xsl:value-of select="$root.filename"/>
 
 274                         <xsl:when test="self::book">
 
 275                                 <xsl:text>bk</xsl:text>
 
 276                                 <xsl:number level="any" format="01"/>
 
 279                         <xsl:when test="self::article">
 
 281                                         <!-- in a set, make sure we inherit the right book info... -->
 
 282                                         <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 283                                                 <xsl:with-param name="recursive" select="true()"/>
 
 284                                         </xsl:apply-templates>
 
 287                                 <xsl:text>ar</xsl:text>
 
 288                                 <xsl:number level="any" format="01" from="book"/>
 
 291                         <xsl:when test="self::preface">
 
 293                                         <!-- in a set, make sure we inherit the right book info... -->
 
 294                                         <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 295                                                 <xsl:with-param name="recursive" select="true()"/>
 
 296                                         </xsl:apply-templates>
 
 299                                 <xsl:text>pr</xsl:text>
 
 300                                 <xsl:number level="any" format="01" from="book"/>
 
 303                         <xsl:when test="self::chapter">
 
 305                                         <!-- in a set, make sure we inherit the right book info... -->
 
 306                                         <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 307                                                 <xsl:with-param name="recursive" select="true()"/>
 
 308                                         </xsl:apply-templates>
 
 311                                 <xsl:text>ch</xsl:text>
 
 312                                 <xsl:number level="any" format="01" from="book"/>
 
 315                         <xsl:when test="self::appendix">
 
 317                                         <!-- in a set, make sure we inherit the right book info... -->
 
 318                                         <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 319                                                 <xsl:with-param name="recursive" select="true()"/>
 
 320                                         </xsl:apply-templates>
 
 323                                 <xsl:text>ap</xsl:text>
 
 324                                 <xsl:number level="any" format="a" from="book"/>
 
 327                         <xsl:when test="self::part">
 
 329                                         <xsl:when test="/set">
 
 330                                                 <!-- in a set, make sure we inherit the right book info... -->
 
 331                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 332                                                         <xsl:with-param name="recursive" select="true()"/>
 
 333                                                 </xsl:apply-templates>
 
 339                                 <xsl:text>pt</xsl:text>
 
 340                                 <xsl:number level="any" format="01" from="book"/>
 
 343                         <xsl:when test="self::reference">
 
 345                                         <xsl:when test="/set">
 
 346                                                 <!-- in a set, make sure we inherit the right book info... -->
 
 347                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 348                                                         <xsl:with-param name="recursive" select="true()"/>
 
 349                                                 </xsl:apply-templates>
 
 355                                 <xsl:text>rn</xsl:text>
 
 356                                 <xsl:number level="any" format="01" from="book"/>
 
 359                         <xsl:when test="self::refentry">
 
 361                                         <xsl:when test="parent::reference">
 
 362                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 363                                                         <xsl:with-param name="recursive" select="true()"/>
 
 364                                                 </xsl:apply-templates>
 
 370                                 <xsl:text>re</xsl:text>
 
 371                                 <xsl:number level="any" format="01" from="book"/>
 
 374                         <xsl:when test="self::colophon">
 
 376                                         <xsl:when test="/set">
 
 377                                                 <!-- in a set, make sure we inherit the right book info... -->
 
 378                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 379                                                         <xsl:with-param name="recursive" select="true()"/>
 
 380                                                 </xsl:apply-templates>
 
 386                                 <xsl:text>co</xsl:text>
 
 387                                 <xsl:number level="any" format="01" from="book"/>
 
 390                         <xsl:when test="self::sect1
 
 396                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 397                                         <xsl:with-param name="recursive" select="true()"/>
 
 398                                 </xsl:apply-templates>
 
 399                                 <xsl:text>s</xsl:text>
 
 400                                 <xsl:number format="01"/>
 
 403                         <xsl:when test="self::bibliography">
 
 405                                         <xsl:when test="/set">
 
 406                                                 <!-- in a set, make sure we inherit the right book info... -->
 
 407                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 408                                                         <xsl:with-param name="recursive" select="true()"/>
 
 409                                                 </xsl:apply-templates>
 
 415                                 <xsl:text>bi</xsl:text>
 
 416                                 <xsl:number level="any" format="01" from="book"/>
 
 419                         <xsl:when test="self::glossary">
 
 421                                         <xsl:when test="/set">
 
 422                                                 <!-- in a set, make sure we inherit the right book info... -->
 
 423                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 424                                                         <xsl:with-param name="recursive" select="true()"/>
 
 425                                                 </xsl:apply-templates>
 
 431                                 <xsl:text>go</xsl:text>
 
 432                                 <xsl:number level="any" format="01" from="book"/>
 
 435                         <xsl:when test="self::index">
 
 437                                         <xsl:when test="/set">
 
 438                                                 <!-- in a set, make sure we inherit the right book info... -->
 
 439                                                 <xsl:apply-templates mode="recursive-chunk-id" select="parent::*">
 
 440                                                         <xsl:with-param name="recursive" select="true()"/>
 
 441                                                 </xsl:apply-templates>
 
 447                                 <xsl:text>ix</xsl:text>
 
 448                                 <xsl:number level="any" format="01" from="book"/>
 
 451                         <xsl:when test="self::setindex">
 
 452                                 <xsl:text>si</xsl:text>
 
 453                                 <xsl:number level="any" format="01" from="set"/>
 
 457                                 <xsl:text>chunk-filename-error-</xsl:text>
 
 458                                 <xsl:value-of select="name(.)"/>
 
 459                                 <xsl:number level="any" format="01" from="set"/>
 
 464         <!-- Main template that generates internal links -->
 
 465         <xsl:template name="href.target">
 
 466                 <xsl:param name="context" select="."/>
 
 467                 <xsl:param name="object" select="."/>
 
 468                 <xsl:param name="toc-context" select="."/>
 
 470                 <xsl:variable name="id">
 
 471                         <xsl:call-template name="get.id.from.pagename">
 
 472                                 <xsl:with-param name="target" select="$object"/>
 
 476                 <xsl:variable name="href">
 
 478                                 <xsl:when test="$use.mshelp.links">
 
 479                                         <!-- Generate a ms.help type link-->
 
 480                                         <xsl:if test="$product.name = ''">
 
 481                                                 <xsl:message terminate="yes">
 
 482                                                         $product.name needs to be set to generate ms.help style links
 
 485                                         <xsl:if test="$product.version = ''">
 
 486                                                 <xsl:message terminate="yes">
 
 487                                                         $product.version needs to be set to generate ms.help style links
 
 490                                         <xsl:if test="$product.locale = ''">
 
 491                                                 <xsl:message terminate="yes">
 
 492                                                         $product.locale needs to be set to generate ms.help style links
 
 496                                         <xsl:text>ms.help?method=page&id=</xsl:text>
 
 497                                         <xsl:value-of select="$id"/>
 
 498                                         <xsl:text>&product=</xsl:text>
 
 499                                         <xsl:value-of select="$product.name"/>
 
 500                                         <xsl:text>&productVersion=</xsl:text>
 
 501                                         <xsl:value-of select="$product.version"/>
 
 502                                         <xsl:text>&locale=</xsl:text>
 
 503                                         <xsl:value-of select="$product.locale"/>
 
 504                                         <!-- Append the jump id if the current object has an id-->
 
 505                                         <xsl:if test="$object[@id or @xml:id]">
 
 506                                                 <xsl:text>#</xsl:text>
 
 507                                                 <xsl:value-of select="$object/@id|$object/@xml:id"/>
 
 511                                         <!-- Generate ms-xhelp type links. Default-->
 
 512                                         <xsl:text>ms-xhelp:///?Id=</xsl:text>
 
 513                                         <xsl:value-of select="$id"/>
 
 517                 <xsl:value-of select="$href"/>
 
 520         <xsl:template match="*" mode="common.html.attributes">
 
 521                 <xsl:param name="class" select="local-name(.)"/>
 
 522                 <xsl:param name="inherit" select="0"/>
 
 525                         Workaround for known issue with HelpLibAgent
 
 526                         Comment from Bruce Belson:
 
 527                         <pre> tags get their whitespace mangled by the Help Library Agent,
 
 528                         unless the non-standard attribute xml:space="preserve" is added to the pre element.
 
 530                 <xsl:if test="$class = 'programlisting' or $class = 'verbatim' or $class = 'litterallayout' or $class = 'screen'">
 
 531                         <xsl:attribute name="xml:space">preserve</xsl:attribute>
 
 534                 <xsl:call-template name="generate.html.lang"/>
 
 535                 <xsl:call-template name="dir">
 
 536                         <xsl:with-param name="inherit" select="$inherit"/>
 
 538                 <xsl:apply-templates select="." mode="class.attribute">
 
 539                         <xsl:with-param name="class" select="$class"/>
 
 540                 </xsl:apply-templates>
 
 544         <xsl:template name="hv1.display.version">
 
 545                 <xsl:apply-templates mode="title.markup" select="ancestor-or-self::book"/>
 
 546                 <xsl:if test="ancestor-or-self::chapter">
 
 547                         <xsl:text> - </xsl:text>
 
 548                         <xsl:apply-templates mode="title.markup" select="ancestor-or-self::chapter"/>
 
 553         <!-- Generate a meta element for each keyword in chunk -->
 
 554         <xsl:template name="hv1.keywords">
 
 555                 <xsl:variable name="is.chunk">
 
 556                         <xsl:call-template name="chunk">
 
 557                                 <xsl:with-param name="node" select="."/>
 
 561                 <xsl:for-each select=".//indexterm[$is.chunk = '0'] |
 
 562                         (./indexterm | *[not(self::section or self::preface or self::book or self::chapter)]//indexterm)[$is.chunk = '1']">
 
 564                                 <xsl:when test="primary != ''">
 
 565                                         <meta name="Microsoft.Help.Keywords">
 
 566                                                 <xsl:attribute name="content">
 
 568                                                                 <!-- This concats the primary and secondary togheter, separated by colon if there exists
 
 569                                                                 a tertiary element -->
 
 570                                                                 <xsl:when test="tertiary">
 
 571                                                                         <xsl:value-of select="primary/text()" />
 
 572                                                                         <xsl:text>: </xsl:text>
 
 573                                                                         <xsl:value-of select="secondary/text()" />
 
 574                                                                         <xsl:text>, </xsl:text>
 
 575                                                                         <xsl:value-of select="tertiary/text()" />
 
 579                                                                         <xsl:for-each select="primary/text() | secondary/text()">
 
 580                                                                                 <xsl:value-of select="." />
 
 581                                                                                 <xsl:if test="not(position() = last())">, </xsl:if>
 
 593         <!-- Generate a F1 meta element for each indexterm with an ID (used as F1 id) -->
 
 594         <xsl:template name="hv1.f1">
 
 595                 <xsl:variable name="is.chunk">
 
 596                         <xsl:call-template name="chunk">
 
 597                                 <xsl:with-param name="node" select="."/>
 
 601                 <xsl:variable name="id">
 
 602                         <xsl:call-template name="hv1.toc.id"/>
 
 605                 <xsl:for-each select=".//indexterm[$is.chunk = '0'] |
 
 606                         (./indexterm | *[not(self::section or self::preface or self::book or self::chapter)]//indexterm)[$is.chunk = '1']">
 
 607                         <xsl:if test="@id|@xml:id">
 
 608                                 <meta name="Microsoft.Help.F1">
 
 609                                         <xsl:attribute name="content">
 
 610                                                 <xsl:value-of select="(@id|@xml:id)[1]" />
 
 617         <!-- ID used for to resolution. Using default ID -->
 
 618         <xsl:template name="hv1.toc.id">
 
 619                 <xsl:variable name="href">
 
 620                         <xsl:call-template name="get.id.from.pagename">
 
 621                                 <xsl:with-param name="target" select="."/>
 
 624                 <xsl:value-of select="$href"/>
 
 627         <!-- Determine parent id (if top level -> -1) -->
 
 628         <xsl:template name="hv1.toc.parent.id">
 
 629                 <xsl:param name="up" select="''"/>
 
 630                 <xsl:variable name="href">
 
 632                                 <xsl:when test="$up">
 
 633                                         <!-- I have a parent -->
 
 634                                         <xsl:call-template name="get.id.from.pagename">
 
 635                                                 <xsl:with-param name="target" select="$up"/>
 
 639                                         <xsl:text>-1</xsl:text>
 
 643                 <xsl:value-of select="$href"/>
 
 646         <xsl:template name="hv1.description">
 
 647                 <xsl:variable name="content">
 
 649                                 <xsl:when test="abstract|d:abstract|d:info/d:abstract|bookinfo/abstract|sectioninfo/abstract|articleinfo/abstract|partinfo/abstract">
 
 650                                         <xsl:value-of select="(abstract|d:abstract|d:info/d:abstract|bookinfo/abstract|sectioninfo/abstract|articleinfo/abstract|partinfo/abstract)[1]"/>
 
 652                                 <xsl:when test="child::para">
 
 653                                         <xsl:value-of select="substring(normalize-space(child::para[1]), 0, 150)"/>
 
 658                 <xsl:if test="$content != ''">
 
 659                         <xsl:value-of select="concat($content, '...')"/>