aboutsummaryrefslogtreecommitdiffstats
path: root/docs/xml-docs/style/stylesheets/faqs2document.xsl
blob: 4a9d3938e20d4f168769286da730a19ebc85bea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="faqs">
    <s1 title="{@title}">
      <s2 title="Questions">
        <ul>
          <xsl:apply-templates select="faq" mode="index"/>
        </ul>
      </s2>
      <s2 title="Answers">
        <br/>
        <xsl:apply-templates select="faq"/>
      </s2>
    </s1>
  </xsl:template>

  <xsl:template match="faq" mode="index">
    <li>
      <link anchor="faq-{position()}">
        <xsl:if test="string-length(@title)=0">
          <xsl:value-of select="q"/>
        </xsl:if>
        <xsl:if test="string-length(@title)>0">
          <xsl:value-of select="@title"/>
        </xsl:if>
      </link>
    </li>
  </xsl:template>

  <xsl:template match="faq">
    <anchor name="faq-{position()}"/>
    <s3 title="{q}">
      <xsl:apply-templates select="a"/>
    </s3>
  </xsl:template>

  <xsl:template match="a">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>