1 package net.sf.saxon.functions; 2 import net.sf.saxon.expr.XPathContext; 3 import net.sf.saxon.om.Item; 4 import net.sf.saxon.om.NodeInfo; 5 import net.sf.saxon.style.StandardNames; 6 import net.sf.saxon.trans.XPathException; 7 import net.sf.saxon.type.Type; 8 import net.sf.saxon.value.BooleanValue; 9 10 13 14 public class Nilled extends SystemFunction { 15 16 19 20 public Item evaluateItem(XPathContext c) throws XPathException { 21 NodeInfo node = (NodeInfo)argument[0].evaluateItem(c); 22 return getNilledProperty(node); 23 } 24 25 32 33 public static BooleanValue getNilledProperty(NodeInfo node) { 34 if (node==null || node.getNodeKind() != Type.ELEMENT) { 35 return null; 36 } 37 if (node.getTypeAnnotation() == -1) { 38 return BooleanValue.FALSE; 39 } 40 String val = node.getAttributeValue(StandardNames.XSI_NIL); 41 if (val == null) { 42 return BooleanValue.FALSE; 43 } 44 if (val.trim().equals("1") || val.trim().equals("true")) { 45 return BooleanValue.TRUE; 46 } 47 return BooleanValue.FALSE; 48 } 49 50 54 55 public static boolean isNilled(NodeInfo node) { 56 BooleanValue b = getNilledProperty(node); 57 if (b == null) { 58 return false; 59 } else { 60 return b.getBooleanValue(); 61 } 62 } 63 } 64 65 | Popular Tags |