Listing 4: Subscription filter used by the healthcare application |
1 |
function evaluate(XMLdocument) { |
2 |
importPackage(javax.xml.xpath); |
3 |
var XPath = XPathFactory.newInstance().newXPath(); |
4 |
if((XPath.evaluate(“⫽observable[uri=‘/location’ and unit=‘title’]”, |
5 |
XMLdocument, XPathConstants.NODESET).length == 0) && |
6 |
(XPath.evaluate(“⫽observation[uri=‘/pollution-level’ and unit=‘AQI’]”, |
7 |
XMLdocument, XPathConstants.NODESET).length == 0)) { |
8 |
return false; |
9 |
} |
10 |
if((XPath.evaluate(“⫽QoCIndicator[@id=‘17’ and |
11 |
QoCCriterion[@id=‘[17.1]’]/QoCMetricDefinition[@id=‘17.1’] and QoCMetricValue[@name=‘High’]]”, |
12 |
XMLdocument, XPathConstants.NODESET).length == 0) ) { |
13 |
return false; |
14 |
} |
15 |
return true; |
16 |
} |