Subversion Repositories bacoAlunos

Rev

Rev 1081 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?xml version="1.0" encoding="UTF-8"?>
<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" >
        <xsl:param name="dirStartPath"><xsl:value-of select="$contextPath"/>/dir</xsl:param>
       
        <xsl:template match="d:directory" mode="link">
                <a>
                        <xsl:attribute name="href">
                                <xsl:value-of select="$dirStartPath"/>/<xsl:value-of select="@id"/>?role=<xsl:value-of select="@targetRole"/>&amp;menu=<xsl:value-of select="@menuKey"/>
                        </xsl:attribute>
                        <xsl:apply-templates select="." mode="label"/>
                </a>
        </xsl:template>
       
        <xsl:template match="d:leaf[@node='true']" mode="link">
                <a>
                        <xsl:attribute name="href">
                                <xsl:choose>
                                        <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>
                                        <xsl:otherwise>
                                                <xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>                                                
                                        </xsl:otherwise>
                                </xsl:choose>
                        </xsl:attribute>
                        <xsl:apply-templates select="." mode="label"/>
                </a>
        </xsl:template>
        <xsl:template match="d:leaf[@node='false']" mode="link">
                <a>
                        <xsl:attribute name="href">
                                <xsl:choose>
                                        <xsl:when test="string(@absolute)='true'">                                             
                                                <xsl:value-of select="@url"/>
                                        </xsl:when>
                    <xsl:when test="@proxy='local'">
                        <xsl:value-of select="$contextPath"/><xsl:value-of select="@url"/>
                    </xsl:when>
                                        <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>
                                        <xsl:when test="@remoteExtensionRoot='true'"><xsl:value-of select="$dirStartPath"/><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/></xsl:when>
                                        <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>
                                </xsl:choose>
                        </xsl:attribute>                               
                        <xsl:apply-templates select="." mode="label"/>
                </a>
        </xsl:template>

    <!--
       - A variavel de ambiente dirStartPath é o contextPath + /dir
       - Os templates linkparent tem por objectivo escrever toda a hierarquia de ID's até ao elemento directory
       - Todos os nós que trazem o atributo idPrefixSize significa que foram extendidos a partir de um FTP
         não são orginais do XML do directório
          - por exemplo para o id gerado FTP_4_DTP será
          um elemento representativo de uma pasta DTP, o id é unico porque 4 é a profundidade onde ele
          está logo o par 4 + DTP é único supostamente a menos que alguém vá criar uma pasta com este nome
          o que é quase impossivel
          substring(@id,@idPrefixSize+1) este código com o id de exemplo vai originar DTP no link

   -->
       
       
        <xsl:template match="d:directory" mode="linkParent">/<xsl:value-of select="@id"/></xsl:template>
       
        <xsl:template match="d:leaf[@node='true']" mode="linkParent">
                <xsl:choose>
                        <xsl:when test="@idPrefixSize"><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="substring(@id,@idPrefixSize+1)"/></xsl:when>
                        <xsl:otherwise><xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/></xsl:otherwise>
                </xsl:choose>
        </xsl:template>


       
        <xsl:template match="d:leaf[@node='false']" mode="linkParent">
                <xsl:apply-templates select=".." mode="linkParent"/>/<xsl:value-of select="@id"/>
        </xsl:template>
       
        <xsl:template match="d:leaf[@node='false']" mode="bodyContent">
                <xsl:choose>
                        <xsl:when test="string(@xml) = 'true'">
                                <xsl:variable name="bodyDoc" select="document($includeXML)"/>
                                <xsl:apply-templates select="$bodyDoc/*"/>     
                        </xsl:when>
                        <xsl:otherwise>
                                @@BODY_CONTENT@@
                        </xsl:otherwise>
                </xsl:choose>
        </xsl:template>

        <xsl:template match="d:directory" mode="label">
                <xsl:value-of select="@label"/>
        </xsl:template>
        <xsl:template match="d:leaf[@node='true']" mode="label">
                <xsl:value-of select="@label"/>
        </xsl:template>
        <xsl:template match="d:leaf[@node='false']" mode="label">
                <xsl:value-of select="@label"/>
        </xsl:template>
       
       
        <!--Static templates-->
        <xsl:template name="leafsBlockLabel">
                Links
        </xsl:template>
        <xsl:template name="homeLink">
                <a>
                        <xsl:attribute name="href">/</xsl:attribute>
                        Home
                </a>
        </xsl:template>
   
</xsl:stylesheet>