Subversion Repositories bacoAlunos

Rev

Rev 1310 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
368 jmachado 1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet version="1.0" xmlns:d="http://www.estgp.pt/baco/directory/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
3
        <xsl:param name="dirStartPath"><xsl:value-of select="$contextPath"/>/dir</xsl:param>
4
 
5
        <xsl:template match="d:directory" mode="link">
6
                <a>
7
                        <xsl:attribute name="href">
8
                                <xsl:value-of select="$dirStartPath"/>/<xsl:value-of select="@id"/>?role=<xsl:value-of select="@targetRole"/>&amp;menu=<xsl:value-of select="@menuKey"/>
9
                        </xsl:attribute>
10
                        <xsl:apply-templates select="." mode="label"/>
11
                </a>
12
        </xsl:template>
381 jmachado 13
 
1067 jmachado 14
        <xsl:template match="d:leaf[@node='true']" mode="link">
368 jmachado 15
                <a>
16
                        <xsl:attribute name="href">
380 jmachado 17
                                <xsl:choose>
18
                                        <xsl:when test="@idPrefixSize">
19
                                                <xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/>                                                     
20
                                        </xsl:when>
21
                                        <xsl:otherwise>
22
                                                <xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>                                                
23
                                        </xsl:otherwise>
24
                                </xsl:choose>
368 jmachado 25
                        </xsl:attribute>
26
                        <xsl:apply-templates select="." mode="label"/>
27
                </a>
28
        </xsl:template>
1067 jmachado 29
        <xsl:template match="d:leaf[@node='false']" mode="link">
368 jmachado 30
                <a>
31
                        <xsl:attribute name="href">
32
                                <xsl:choose>
33
                                        <xsl:when test="string(@absolute)='true'">                                             
1081 jmachado 34
                                                <xsl:value-of select="@url"/>
35
                                        </xsl:when>
36
                    <xsl:when test="@proxy='local'">
37
                        <xsl:value-of select="$contextPath"/><xsl:value-of select="@url"/>
38
                    </xsl:when>
1069 jmachado 39
                                        <xsl:when test="@idPrefixSize"><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/></xsl:when>
381 jmachado 40
                                        <xsl:when test="@remoteExtensionRoot='true'"><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/></xsl:when>
41
                                        <xsl:otherwise><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/><xsl:value-of select="@url"/></xsl:otherwise>
368 jmachado 42
                                </xsl:choose>
43
                        </xsl:attribute>                               
44
                        <xsl:apply-templates select="." mode="label"/>
45
                </a>
46
        </xsl:template>
1069 jmachado 47
 
48
    <!--
49
        - A variavel de ambiente dirStartPath é o contextPath + /dir
50
        - Os templates linkparent tem por objectivo escrever toda a hierarquia de ID's até ao elemento directory
51
        - Todos os nós que trazem o atributo idPrefixSize significa que foram extendidos a partir de um FTP
52
          não são orginais do XML do directório
53
           - por exemplo para o id gerado FTP_4_DTP será
54
           um elemento representativo de uma pasta DTP, o id é unico porque 4 é a profundidade onde ele
55
           está logo o par 4 + DTP é único supostamente a menos que alguém vá criar uma pasta com este nome
56
           o que é quase impossivel
57
           substring(@id,@idPrefixSize+1) este código com o id de exemplo vai originar DTP no link
58
 
59
    -->
368 jmachado 60
 
381 jmachado 61
 
368 jmachado 62
        <xsl:template match="d:directory" mode="linkParent">/<xsl:value-of select="@id"/></xsl:template>
380 jmachado 63
 
1067 jmachado 64
        <xsl:template match="d:leaf[@node='true']" mode="linkParent">
380 jmachado 65
                <xsl:choose>
66
                        <xsl:when test="@idPrefixSize"><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/></xsl:when>
381 jmachado 67
                        <xsl:otherwise><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/></xsl:otherwise>
380 jmachado 68
                </xsl:choose>
69
        </xsl:template>
381 jmachado 70
 
71
 
380 jmachado 72
 
1067 jmachado 73
        <xsl:template match="d:leaf[@node='false']" mode="linkParent">
368 jmachado 74
                <xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>
75
        </xsl:template>
76
 
1067 jmachado 77
        <xsl:template match="d:leaf[@node='false']" mode="bodyContent">
368 jmachado 78
                <xsl:choose>
79
                        <xsl:when test="string(@xml) = 'true'">
80
                                <xsl:variable name="bodyDoc" select="document($includeXML)"/>
81
                                <xsl:apply-templates select="$bodyDoc/*"/>     
82
                        </xsl:when>
83
                        <xsl:otherwise>
1312 jmachado 84
                                    @@BODY_CONTENT@@
368 jmachado 85
                        </xsl:otherwise>
86
                </xsl:choose>
87
        </xsl:template>
88
 
89
        <xsl:template match="d:directory" mode="label">
1312 jmachado 90
        <xsl:choose>
91
            <xsl:when test="$language = 'en' and @label_en and @label_en != ''">
92
                <xsl:value-of select="@label_en"/>
93
            </xsl:when>
94
            <xsl:when test="$language = 'es' and @label_es and @label_es != ''">
95
                <xsl:value-of select="@label_es"/>
96
            </xsl:when>
97
            <xsl:otherwise>
98
                <xsl:value-of select="@label"/>
99
            </xsl:otherwise>
100
        </xsl:choose>
368 jmachado 101
        </xsl:template>
1067 jmachado 102
        <xsl:template match="d:leaf[@node='true']" mode="label">
1312 jmachado 103
        <xsl:choose>
104
            <xsl:when test="$language = 'en' and @label_en and @label_en != ''">
105
                <xsl:value-of select="@label_en"/>
106
            </xsl:when>
107
            <xsl:when test="$language = 'es' and @label_es and @label_es != ''">
108
                <xsl:value-of select="@label_es"/>
109
            </xsl:when>
110
            <xsl:otherwise>
111
                <xsl:value-of select="@label"/>
112
            </xsl:otherwise>
113
        </xsl:choose>
368 jmachado 114
        </xsl:template>
1067 jmachado 115
        <xsl:template match="d:leaf[@node='false']" mode="label">
1312 jmachado 116
        <xsl:choose>
117
            <xsl:when test="$language = 'en' and @label_en and @label_en != ''">
118
                <xsl:value-of select="@label_en"/>
119
            </xsl:when>
120
            <xsl:when test="$language = 'es' and @label_es and @label_es != ''">
121
                <xsl:value-of select="@label_es"/>
122
            </xsl:when>
123
            <xsl:otherwise>
124
                <xsl:value-of select="@label"/>
125
            </xsl:otherwise>
126
        </xsl:choose>
368 jmachado 127
        </xsl:template>
128
 
129
 
130
        <!--Static templates-->
131
        <xsl:template name="leafsBlockLabel">
132
                Links
133
        </xsl:template>
134
        <xsl:template name="homeLink">
135
                <a>
539 jmachado 136
                        <xsl:attribute name="href">/</xsl:attribute>
137
                        Home
368 jmachado 138
                </a>
139
        </xsl:template>
140
 
141
</xsl:stylesheet>