tags:

views:

590

answers:

1

I have the following two files:

<?xml version="1.0" encoding="utf-8" ?> 
<!-- D E F A U L T H O S P I T A L P O L I C Y -->

<xas DefaultPolicy="open" DefaultSubjectsFile="subjects.xss">
<rule id="R1" access="deny" object="record" subject="roles/*[name()!='Staff']"/> 
<rule id="R2" access="deny" object="diagnosis" subject="roles//Nurse"/>
<rule id="R3" access="grant" object="record[@id=$user]" subject="roles/member[@id=$user]"/> 
</xas>

and the other xml file called subjects.xss is:

<?xml version="1.0" encoding="utf-8" ?> 
<subjects>

<users> 
<member id="dupont" password="4A-4E-E9-17-5D-CE-2C-DD-43-43-1D-F1-3F-5D-94-71">

<name>Pierre Dupont</name> 
</member>

 <member id="durand" password="3A-B6-1B-E8-C0-1F-CD-34-DF-C4-5E-BA-02-3C-04-61"> 
<name>Jacqueline Durand</name>

</member>

</users> 
<roles>

<Staff>

<Doctor> 
<member idref="dupont"/>

</Doctor> 
<Nurse>

<member idref="durand"/> 
</Nurse>

</Staff>

</roles> 
</subjects>

I am writing an xsl sheet which will read the subject value for each rule in policy.xas and if the currently logged in user (accessible as variable "user" in the stylesheet) is contained in that subject value (say roles//Nurse), then do something.

I am not being able to test whether the currently logged in user ($user which is equal to say "durand") is contained in roles//Nurse in the subjects file (which is a different xml file). Hope that clarifies my question. Any ideas? Thanks in advance.

A: 

I suspect your $user variable holds a member node, correct? In which case the test would be:-

/roles/Nurse[member/idref=$user/@id]

BTW, using tag names to carry data such as "Nurse" and "Doctor" is not a good practice. You are effectively saying that each new role is a new type. Better would be:-

<roles>
 <role>
  <name>Nurse</name>
  <member idref="durand" />
 </role>
... 
</roles>

Your test would be:-

/roles/role[name='Nurse' and member/idref=$user/@id]
AnthonyWJones