home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _0EEE6174B8144CF6A8AFC66A1EF23566 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  14.2 KB  |  412 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4.                 exclude-result-prefixes="doc"
  5.                 version='1.0'>
  6.  
  7. <!-- ============================================================ -->
  8. <!-- title markup -->
  9.  
  10. <doc:mode mode="title.markup" xmlns="">
  11. <refpurpose>Provides access to element titles</refpurpose>
  12. <refdescription>
  13. <para>Processing an element in the
  14. <literal role="mode">title.markup</literal> mode produces the
  15. title of the element. This does not include the label.
  16. </para>
  17. </refdescription>
  18. </doc:mode>
  19.  
  20. <xsl:template match="*" mode="title.markup">
  21.   <xsl:param name="allow-anchors" select="0"/>
  22.   <xsl:param name="verbose" select="1"/>
  23.  
  24.   <xsl:choose>
  25.     <xsl:when test="title">
  26.       <xsl:apply-templates select="title[1]" mode="title.markup">
  27.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  28.       </xsl:apply-templates>
  29.     </xsl:when>
  30.     <xsl:when test="local-name(.) = 'partintro'">
  31.       <!-- partintro's don't have titles, use the parent (part or reference)
  32.            title instead. -->
  33.       <xsl:apply-templates select="parent::*" mode="title.markup"/>
  34.     </xsl:when>
  35.     <xsl:otherwise>
  36.       <xsl:if test="$verbose">
  37.         <xsl:message>
  38.           <xsl:text>Request for title of element with no title: </xsl:text>
  39.           <xsl:value-of select="name(.)"/>
  40.           <xsl:if test="@id">
  41.             <xsl:text> (id="</xsl:text>
  42.             <xsl:value-of select="@id"/>
  43.             <xsl:text>")</xsl:text>
  44.           </xsl:if>
  45.         </xsl:message>
  46.       </xsl:if>
  47.       <xsl:text>???TITLE???</xsl:text>
  48.     </xsl:otherwise>
  49.   </xsl:choose>
  50. </xsl:template>
  51.  
  52. <xsl:template match="title" mode="title.markup">
  53.   <xsl:param name="allow-anchors" select="0"/>
  54.  
  55.   <xsl:choose>
  56.     <xsl:when test="$allow-anchors != 0">
  57.       <xsl:apply-templates/>
  58.     </xsl:when>
  59.     <xsl:otherwise>
  60.       <xsl:apply-templates mode="no.anchor.mode"/>
  61.     </xsl:otherwise>
  62.   </xsl:choose>
  63. </xsl:template>
  64.  
  65. <xsl:template match="set" mode="title.markup">
  66.   <xsl:param name="allow-anchors" select="0"/>
  67.   <xsl:apply-templates select="(setinfo/title|title)[1]"
  68.                        mode="title.markup">
  69.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  70.   </xsl:apply-templates>
  71. </xsl:template>
  72.  
  73. <xsl:template match="book" mode="title.markup">
  74.   <xsl:param name="allow-anchors" select="0"/>
  75.   <xsl:apply-templates select="(bookinfo/title|title)[1]"
  76.                        mode="title.markup">
  77.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  78.   </xsl:apply-templates>
  79. </xsl:template>
  80.  
  81. <xsl:template match="part" mode="title.markup">
  82.   <xsl:param name="allow-anchors" select="0"/>
  83.   <xsl:apply-templates select="(partinfo/title|docinfo/title|title)[1]"
  84.                        mode="title.markup">
  85.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  86.   </xsl:apply-templates>
  87. </xsl:template>
  88.  
  89. <xsl:template match="preface|chapter|appendix" mode="title.markup">
  90.   <xsl:param name="allow-anchors" select="0"/>
  91.  
  92. <!--
  93.   <xsl:message>
  94.     <xsl:value-of select="name(.)"/>
  95.     <xsl:text> </xsl:text>
  96.     <xsl:value-of select="$allow-anchors"/>
  97.   </xsl:message>
  98. -->
  99.  
  100.   <xsl:variable name="title" select="(docinfo/title
  101.                                       |prefaceinfo/title
  102.                                       |chapterinfo/title
  103.                                       |appendixinfo/title
  104.                                       |title)[1]"/>
  105.   <xsl:apply-templates select="$title" mode="title.markup">
  106.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  107.   </xsl:apply-templates>
  108. </xsl:template>
  109.  
  110. <xsl:template match="dedication" mode="title.markup">
  111.   <xsl:param name="allow-anchors" select="0"/>
  112.   <xsl:choose>
  113.     <xsl:when test="title">
  114.       <xsl:apply-templates select="title" mode="title.markup">
  115.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  116.       </xsl:apply-templates>
  117.     </xsl:when>
  118.     <xsl:otherwise>
  119.       <xsl:call-template name="gentext">
  120.         <xsl:with-param name="key" select="'Dedication'"/>
  121.       </xsl:call-template>
  122.     </xsl:otherwise>
  123.   </xsl:choose>
  124. </xsl:template>
  125.  
  126. <xsl:template match="colophon" mode="title.markup">
  127.   <xsl:param name="allow-anchors" select="0"/>
  128.   <xsl:choose>
  129.     <xsl:when test="title">
  130.       <xsl:apply-templates select="title" mode="title.markup">
  131.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  132.       </xsl:apply-templates>
  133.     </xsl:when>
  134.     <xsl:otherwise>
  135.       <xsl:call-template name="gentext">
  136.         <xsl:with-param name="key" select="'Colophon'"/>
  137.       </xsl:call-template>
  138.     </xsl:otherwise>
  139.   </xsl:choose>
  140. </xsl:template>
  141.  
  142. <xsl:template match="article" mode="title.markup">
  143.   <xsl:param name="allow-anchors" select="0"/>
  144.   <xsl:variable name="title" select="(artheader/title
  145.                                       |articleinfo/title
  146.                                       |title)[1]"/>
  147.  
  148.   <xsl:apply-templates select="$title" mode="title.markup">
  149.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  150.   </xsl:apply-templates>
  151. </xsl:template>
  152.  
  153. <xsl:template match="reference" mode="title.markup">
  154.   <xsl:param name="allow-anchors" select="0"/>
  155.   <xsl:apply-templates select="(referenceinfo/title|docinfo/title|title)[1]"
  156.                        mode="title.markup">
  157.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  158.   </xsl:apply-templates>
  159. </xsl:template>
  160.  
  161. <xsl:template match="refentry" mode="title.markup">
  162.   <xsl:param name="allow-anchors" select="0"/>
  163.   <xsl:variable name="refmeta" select=".//refmeta"/>
  164.   <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
  165.   <xsl:variable name="refnamediv" select=".//refnamediv"/>
  166.   <xsl:variable name="refname" select="$refnamediv//refname"/>
  167.  
  168.   <xsl:variable name="title">
  169.     <xsl:choose>
  170.       <xsl:when test="$refentrytitle">
  171.         <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
  172.       </xsl:when>
  173.       <xsl:when test="$refname">
  174.         <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
  175.       </xsl:when>
  176.       <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
  177.     </xsl:choose>
  178.   </xsl:variable>
  179.  
  180.   <xsl:copy-of select="$title"/>
  181. </xsl:template>
  182.  
  183. <xsl:template match="refentrytitle|refname" mode="title.markup">
  184.   <xsl:param name="allow-anchors" select="0"/>
  185.   <xsl:choose>
  186.     <xsl:when test="$allow-anchors != 0">
  187.       <xsl:apply-templates/>
  188.     </xsl:when>
  189.     <xsl:otherwise>
  190.       <xsl:apply-templates mode="no.anchor.mode"/>
  191.     </xsl:otherwise>
  192.   </xsl:choose>
  193. </xsl:template>
  194.  
  195. <xsl:template match="section
  196.                      |sect1|sect2|sect3|sect4|sect5
  197.                      |refsect1|refsect2|refsect3
  198.                      |simplesect"
  199.               mode="title.markup">
  200.   <xsl:param name="allow-anchors" select="0"/>
  201.   <xsl:variable name="title" select="(sectioninfo/title
  202.                                       |sect1info/title
  203.                                       |sect2info/title
  204.                                       |sect3info/title
  205.                                       |sect4info/title
  206.                                       |sect5info/title
  207.                                       |refsect1info/title
  208.                                       |refsect2info/title
  209.                                       |refsect3info/title
  210.                                       |title)[1]"/>
  211.  
  212.   <xsl:apply-templates select="$title" mode="title.markup">
  213.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  214.   </xsl:apply-templates>
  215. </xsl:template>
  216.  
  217. <xsl:template match="bridgehead" mode="title.markup">
  218.   <xsl:apply-templates mode="title.markup"/>
  219. </xsl:template>
  220.  
  221. <xsl:template match="refsynopsisdiv" mode="title.markup">
  222.   <xsl:param name="allow-anchors" select="0"/>
  223.   <xsl:choose>
  224.     <xsl:when test="title">
  225.       <xsl:apply-templates select="title" mode="title.markup">
  226.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  227.       </xsl:apply-templates>
  228.     </xsl:when>
  229.     <xsl:otherwise>
  230.       <xsl:call-template name="gentext">
  231.         <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
  232.       </xsl:call-template>
  233.     </xsl:otherwise>
  234.   </xsl:choose>
  235. </xsl:template>
  236.  
  237. <xsl:template match="bibliography" mode="title.markup">
  238.   <xsl:param name="allow-anchors" select="0"/>
  239.   <xsl:variable name="title" select="(bibliographyinfo/title|title)[1]"/>
  240.   <xsl:choose>
  241.     <xsl:when test="$title">
  242.       <xsl:apply-templates select="$title" mode="title.markup">
  243.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  244.       </xsl:apply-templates>
  245.     </xsl:when>
  246.     <xsl:otherwise>
  247.       <xsl:call-template name="gentext">
  248.         <xsl:with-param name="key" select="'Bibliography'"/>
  249.       </xsl:call-template>
  250.     </xsl:otherwise>
  251.   </xsl:choose>
  252. </xsl:template>
  253.  
  254. <xsl:template match="glossary" mode="title.markup">
  255.   <xsl:param name="allow-anchors" select="0"/>
  256.   <xsl:variable name="title" select="(glossaryinfo/title|title)[1]"/>
  257.   <xsl:choose>
  258.     <xsl:when test="$title">
  259.       <xsl:apply-templates select="$title" mode="title.markup">
  260.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  261.       </xsl:apply-templates>
  262.     </xsl:when>
  263.     <xsl:otherwise>
  264.       <xsl:call-template name="gentext.element.name">
  265.         <xsl:with-param name="element.name" select="name(.)"/>
  266.       </xsl:call-template>
  267.     </xsl:otherwise>
  268.   </xsl:choose>
  269. </xsl:template>
  270.  
  271. <xsl:template match="index" mode="title.markup">
  272.   <xsl:param name="allow-anchors" select="0"/>
  273.   <xsl:variable name="title" select="(indexinfo/title|title)[1]"/>
  274.   <xsl:choose>
  275.     <xsl:when test="$title">
  276.       <xsl:apply-templates select="$title" mode="title.markup">
  277.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  278.       </xsl:apply-templates>
  279.     </xsl:when>
  280.     <xsl:otherwise>
  281.       <xsl:call-template name="gentext">
  282.         <xsl:with-param name="key" select="'Index'"/>
  283.       </xsl:call-template>
  284.     </xsl:otherwise>
  285.   </xsl:choose>
  286. </xsl:template>
  287.  
  288. <xsl:template match="figure|table|example|equation" mode="title.markup">
  289.   <xsl:param name="allow-anchors" select="0"/>
  290.   <xsl:apply-templates select="title" mode="title.markup">
  291.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  292.   </xsl:apply-templates>
  293. </xsl:template>
  294.  
  295. <xsl:template match="procedure" mode="title.markup">
  296.   <xsl:param name="allow-anchors" select="0"/>
  297.   <xsl:apply-templates select="title" mode="title.markup">
  298.     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  299.   </xsl:apply-templates>
  300. </xsl:template>
  301.  
  302. <xsl:template match="abstract" mode="title.markup">
  303.   <xsl:param name="allow-anchors" select="0"/>
  304.   <xsl:choose>
  305.     <xsl:when test="title">
  306.       <xsl:apply-templates select="title" mode="title.markup">
  307.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  308.       </xsl:apply-templates>
  309.     </xsl:when>
  310.     <xsl:otherwise>
  311.       <xsl:call-template name="gentext">
  312.         <xsl:with-param name="key" select="'Abstract'"/>
  313.       </xsl:call-template>
  314.     </xsl:otherwise>
  315.   </xsl:choose>
  316. </xsl:template>
  317.  
  318. <xsl:template match="caution|tip|warning|important|note" mode="title.markup">
  319.   <xsl:param name="allow-anchors" select="0"/>
  320.   <xsl:variable name="title" select="title[1]"/>
  321.   <xsl:choose>
  322.     <xsl:when test="$title">
  323.       <xsl:apply-templates select="$title" mode="title.markup">
  324.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  325.       </xsl:apply-templates>
  326.     </xsl:when>
  327.     <xsl:otherwise>
  328.       <xsl:call-template name="gentext">
  329.         <xsl:with-param name="key">
  330.           <xsl:choose>
  331.             <xsl:when test="local-name(.)='note'">Note</xsl:when>
  332.             <xsl:when test="local-name(.)='important'">Important</xsl:when>
  333.             <xsl:when test="local-name(.)='caution'">Caution</xsl:when>
  334.             <xsl:when test="local-name(.)='warning'">Warning</xsl:when>
  335.             <xsl:when test="local-name(.)='tip'">Tip</xsl:when>
  336.           </xsl:choose>
  337.         </xsl:with-param>
  338.       </xsl:call-template>
  339.     </xsl:otherwise>
  340.   </xsl:choose>
  341. </xsl:template>
  342.  
  343. <xsl:template match="question" mode="title.markup">
  344.   <!-- questions don't have titles -->
  345.   <xsl:text>Question</xsl:text>
  346. </xsl:template>
  347.  
  348. <xsl:template match="answer" mode="title.markup">
  349.   <!-- answers don't have titles -->
  350.   <xsl:text>Answer</xsl:text>
  351. </xsl:template>
  352.  
  353. <xsl:template match="qandaentry" mode="title.markup">
  354.   <!-- qandaentrys are represented by the first question in them -->
  355.   <xsl:text>Question</xsl:text>
  356. </xsl:template>
  357.  
  358. <xsl:template match="legalnotice" mode="title.markup">
  359.   <xsl:param name="allow-anchors" select="0"/>
  360.   <xsl:choose>
  361.     <xsl:when test="title">
  362.       <xsl:apply-templates select="title" mode="title.markup">
  363.         <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  364.       </xsl:apply-templates>
  365.     </xsl:when>
  366.     <xsl:otherwise>
  367.       <xsl:call-template name="gentext">
  368.         <xsl:with-param name="key" select="'LegalNotice'"/>
  369.       </xsl:call-template>
  370.     </xsl:otherwise>
  371.   </xsl:choose>
  372. </xsl:template>
  373.  
  374. <!-- ============================================================ -->
  375.  
  376. <xsl:template match="*" mode="no.anchor.mode">
  377.   <xsl:apply-templates mode="no.anchor.mode"/>
  378. </xsl:template>
  379.  
  380. <xsl:template match="footnote" mode="no.anchor.mode">
  381.   <!-- nop, suppressed -->
  382. </xsl:template>
  383.  
  384. <xsl:template match="anchor" mode="no.anchor.mode">
  385.   <!-- nop, suppressed -->
  386. </xsl:template>
  387.  
  388. <xsl:template match="ulink" mode="no.anchor.mode">
  389.   <xsl:apply-templates/>
  390. </xsl:template>
  391.  
  392. <xsl:template match="link" mode="no.anchor.mode">
  393.   <xsl:apply-templates/>
  394. </xsl:template>
  395.  
  396. <xsl:template match="olink" mode="no.anchor.mode">
  397.   <xsl:apply-templates/>
  398. </xsl:template>
  399.  
  400. <xsl:template match="indexterm" mode="no.anchor.mode">
  401.   <!-- nop, suppressed -->
  402. </xsl:template>
  403.  
  404. <xsl:template match="xref" mode="no.anchor.mode">
  405.   <!-- FIXME: this should generate the text without the link... -->
  406. </xsl:template>
  407.  
  408. <!-- ============================================================ -->
  409.  
  410. </xsl:stylesheet>
  411.  
  412.