summaryrefslogtreecommitdiff
path: root/tests/general/bug-142.xsl
blob: 8e1a6ac0c71a5a60c3abd727f75b94397739ad24 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:g="http://glandium.org/" xmlns:日本語="http://glandium.org/nihongo/" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="g 日本語 date">

  <xsl:template match="g:posts">
    <html xml:lang="fr">
      <body>
        <xsl:apply-templates select="*"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="g:posts/g:post[g:date]">
    <xsl:variable name="id" select="@id"/>
    <xsl:variable name="date" select="concat(substring(g:date,1,4),'/',substring(g:date,5,2),'/',substring(g:date,7,2))"/>

    <div id="post{$id}">
      <xsl:if test="lang(ja)">
        <xsl:attribute name="xml:lang">ja</xsl:attribute>
      </xsl:if>
      <h3><a href="{$date}/{$id}">
        <xsl:apply-templates select="g:title"/>
      </a></h3>
      <xsl:apply-templates select="g:content"/>
    </div>
  </xsl:template>

  <xsl:template match="g:post/g:title">
    <xsl:apply-templates mode="日本語" select="."/>
  </xsl:template>

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

  <xsl:template match="g:content/g:para">
    <p><xsl:apply-templates mode="link" select="."/></p>
  </xsl:template>

  <xsl:template match="g:para/g:span|g:item/g:span|g:span/g:span">
    <xsl:apply-templates mode="link" select="."/>
  </xsl:template>

  <xsl:template match="g:content/g:list|g:item/g:list">
    <ul><xsl:apply-templates mode="link" select="."/></ul>
  </xsl:template>

  <xsl:template match="g:list/g:item">
    <li><xsl:apply-templates mode="link" select="."/></li>
  </xsl:template>

  <xsl:template match="g:span[@href]|g:para[@href]|g:item[@href]" mode="link">
    <a href="{@href}">
      <xsl:apply-templates mode="日本語" select="."/>
    </a>
  </xsl:template>

  <xsl:template match="*" mode="link">
    <xsl:apply-templates mode="日本語" select="."/>
  </xsl:template>

  <xsl:template match="*" mode="日本語">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="*[lang('ja') and not(ancestor::*[@xml:lang='ja'])]" mode="日本語">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="g:span[lang('ja') and not (ancestor::*[@xml:lang='ja'])][not(@href)]" mode="日本語">
    <span xml:lang="ja">
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  
  <xsl:template match="*[lang('fr')]" mode="日本語">
    <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="g:span[lang('fr')][not(@href)]" mode="日本語">
    <span xml:lang="fr">
      <xsl:apply-templates/>
    </span>
  </xsl:template>

</xsl:stylesheet>