T
Tjerk Wolterink
I've xml code like this:
roles.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<roles xmlns="http://www.wolterinkwebdesign.com/xml/roles">
<!--
! The admin role.
! And admin should have all permisions to do its task
!
!-->
<role id="admin" isadmin="true">
<name>Administrator</name>
<description>De Administrator kan alles verwijderen, toevoegen en bewerken op de site.</description>
<grants>
<for name="all">
<action name="edit" grant="true" />
<action name="new" grant="true" />
<action name="read" grant="true" />
</for>
</grants>
</role>
<!--
! A generic visitor role.
! Anybody who is not given a role explicit is a visitor
!-->
<role id="visitor" isvisitor="true">
<name>Bezoeker</name>
<description>Bezoeker van de site</description>
a
<grants>
b
<for name="all">
<action name="read" grant="true" />
<action name="edit" grant="true" />
</for>
<for name="gastenboek">
<action name="new" grant="true"/>
<action name="edit" grant="true" />
</for>
<for name="medewerkers">
<action name="new" grant="true"/>
</for>
<for name="files">
y
<action name="new" grant="true">d</action>
</for>
<for name="news">
<action name="new" grant="true"/>
</for>
</grants>
</role>
</roles>
XSL code like this:
ps, $roles is always the above roles.xml
<!--
This template below works on for example
<page:button-edit-delete module="files" id="3"/>
-->
<xsl:template match="page:button-edit-delete">
<xsl:if test="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]/r:action[@name='edit']/@grant='true' or $roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='edit']/@grant='true'">
<[cut]
</xsl:if>
</xsl:template>
<!--
This template below does NOT work on for example
<page:button-new module="files" id="3"/>
-->
<xsl:template match="page:button-new">
<!-- debug code -->
BUTTON NEW MATCHED!
<xsl:value-of select="./@module"/>
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]"/>
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='files']"/>
<!-- end debug code -->
<xsl:if test="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]/r:action[@name='new']/@grant='true' or $roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='new']/@grant='true'">
[cut]
</xsl:if>
</xsl:template>
Strange enough:
this works: <xsl:value-of select="./@module"/> output:files
this does not work:
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]"/> output= ""
and this does work:
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='files']"/>
I do not understend the if test in the second template is almost the same as in the first template, but the first template always works and
the second not..... i cannot find the error
roles.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<roles xmlns="http://www.wolterinkwebdesign.com/xml/roles">
<!--
! The admin role.
! And admin should have all permisions to do its task
!
!-->
<role id="admin" isadmin="true">
<name>Administrator</name>
<description>De Administrator kan alles verwijderen, toevoegen en bewerken op de site.</description>
<grants>
<for name="all">
<action name="edit" grant="true" />
<action name="new" grant="true" />
<action name="read" grant="true" />
</for>
</grants>
</role>
<!--
! A generic visitor role.
! Anybody who is not given a role explicit is a visitor
!-->
<role id="visitor" isvisitor="true">
<name>Bezoeker</name>
<description>Bezoeker van de site</description>
a
<grants>
b
<for name="all">
<action name="read" grant="true" />
<action name="edit" grant="true" />
</for>
<for name="gastenboek">
<action name="new" grant="true"/>
<action name="edit" grant="true" />
</for>
<for name="medewerkers">
<action name="new" grant="true"/>
</for>
<for name="files">
y
<action name="new" grant="true">d</action>
</for>
<for name="news">
<action name="new" grant="true"/>
</for>
</grants>
</role>
</roles>
XSL code like this:
ps, $roles is always the above roles.xml
<!--
This template below works on for example
<page:button-edit-delete module="files" id="3"/>
-->
<xsl:template match="page:button-edit-delete">
<xsl:if test="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]/r:action[@name='edit']/@grant='true' or $roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='edit']/@grant='true'">
<[cut]
</xsl:if>
</xsl:template>
<!--
This template below does NOT work on for example
<page:button-new module="files" id="3"/>
-->
<xsl:template match="page:button-new">
<!-- debug code -->
BUTTON NEW MATCHED!
<xsl:value-of select="./@module"/>
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]"/>
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='files']"/>
<!-- end debug code -->
<xsl:if test="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]/r:action[@name='new']/@grant='true' or $roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='new']/@grant='true'">
[cut]
</xsl:if>
</xsl:template>
Strange enough:
this works: <xsl:value-of select="./@module"/> output:files
this does not work:
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name=./@module]"/> output= ""
and this does work:
<xsl:copy-of select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='files']"/>
I do not understend the if test in the second template is almost the same as in the first template, but the first template always works and
the second not..... i cannot find the error