xslt test if a variable value is contained in a node set
Posted
by Aamir
on Stack Overflow
See other posts from Stack Overflow
or by Aamir
Published on 2009-04-26T14:35:31Z
Indexed on
2010/05/11
4:04 UTC
Read the original article
Hit count: 332
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.
© Stack Overflow or respective owner