T
Tjerk Wolterink
Hello i've an xpath problem using sablatron in php.
In xsl i have the following code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlnsage="http://www.wolterinkwebdesign.com/xml/page"
xmlns:menu="http://www.wolterinkwebdesign.com/xml/menu"
xmlns:r="http://www.wolterinkwebdesign.com/xml/roles">
<xslaram name="absolute_url"/>
<xslaram name="upload_url"/>
<xslaram name="document_root"/>
<xslaram name="role"/>
<xslaram name="xcd_dir"/>
<xsl:variable name="menu" select="document(concat($document_root,
'/menu.xml'))"/>
<xsl:variable name="roles" select="document(concat('file://', $xcd_dir,
'/roles.xml'))"/>
[cut]
<xsl:copy-of
select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='edit']/@grant"/>
Well this xpath expression:
$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='edit']/@grant
With these variables:
$role="admin"
$roles:
Using this role file:
<?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>
<grants>
<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">
<action name="new" grant="true"/>
</for>
<for name="news">
<action name="new" grant="true"/>
</for>
</grants>
</role>
</roles>
Gives the following error using sablatron in php:
array(4) {
[0]=>
resource(134) of type (XSLT Processor)
[1]=>
int(3)
[2]=>
int(0)
[3]=>
array(6) {
["msgtype"]=>
string(5) "error"
["code"]=>
string(2) "55"
["module"]=>
string(9) "Sablotron"
["URI"]=>
string(33) "file://C:/webserver/xcd/roles.xml"
["line"]=>
string(2) "44"
["msg"]=>
string(54) "attribute 'grant' created after a child has been added"
}
}
But what am i doing wrong??
Please help me
In xsl i have the following code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlnsage="http://www.wolterinkwebdesign.com/xml/page"
xmlns:menu="http://www.wolterinkwebdesign.com/xml/menu"
xmlns:r="http://www.wolterinkwebdesign.com/xml/roles">
<xslaram name="absolute_url"/>
<xslaram name="upload_url"/>
<xslaram name="document_root"/>
<xslaram name="role"/>
<xslaram name="xcd_dir"/>
<xsl:variable name="menu" select="document(concat($document_root,
'/menu.xml'))"/>
<xsl:variable name="roles" select="document(concat('file://', $xcd_dir,
'/roles.xml'))"/>
[cut]
<xsl:copy-of
select="$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='edit']/@grant"/>
Well this xpath expression:
$roles/r:roles/r:role[@id=$role]/r:grants/r:for[@name='all']/r:action[@name='edit']/@grant
With these variables:
$role="admin"
$roles:
Using this role file:
<?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>
<grants>
<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">
<action name="new" grant="true"/>
</for>
<for name="news">
<action name="new" grant="true"/>
</for>
</grants>
</role>
</roles>
Gives the following error using sablatron in php:
array(4) {
[0]=>
resource(134) of type (XSLT Processor)
[1]=>
int(3)
[2]=>
int(0)
[3]=>
array(6) {
["msgtype"]=>
string(5) "error"
["code"]=>
string(2) "55"
["module"]=>
string(9) "Sablotron"
["URI"]=>
string(33) "file://C:/webserver/xcd/roles.xml"
["line"]=>
string(2) "44"
["msg"]=>
string(54) "attribute 'grant' created after a child has been added"
}
}
But what am i doing wrong??
Please help me