Subversion Repositories bacoAlunos

Rev

Rev 1081 | 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>
84
                                @@BODY_CONTENT@@
85
                        </xsl:otherwise>
86
                </xsl:choose>
87
        </xsl:template>
88
 
89
        <xsl:template match="d:directory" mode="label">
90
                <xsl:value-of select="@label"/>
91
        </xsl:template>
1067 jmachado 92
        <xsl:template match="d:leaf[@node='true']" mode="label">
368 jmachado 93
                <xsl:value-of select="@label"/>
94
        </xsl:template>
1067 jmachado 95
        <xsl:template match="d:leaf[@node='false']" mode="label">
368 jmachado 96
                <xsl:value-of select="@label"/>
97
        </xsl:template>
98
 
99
 
100
        <!--Static templates-->
101
        <xsl:template name="leafsBlockLabel">
102
                Links
103
        </xsl:template>
104
        <xsl:template name="homeLink">
105
                <a>
539 jmachado 106
                        <xsl:attribute name="href">/</xsl:attribute>
107
                        Home
368 jmachado 108
                </a>
109
        </xsl:template>
110
 
111
</xsl:stylesheet>