public object path(XPathNodeIterator arg) { // fn:path($arg as node()?) as xs:string? XPathNavigator node = ExtensionObjectConvert.ToXPathNavigator(arg); if (node == null) { return(ExtensionObjectConvert.EmptyIterator); } var reverseBuffer = new List <string>(); XPathNavigator clone = node.Clone(); path_impl(clone, reverseBuffer); if (reverseBuffer.Count == 1) { return(reverseBuffer[0]); } // replace document-node path expr with empty string // so join operation doesn't create // if (reverseBuffer[reverseBuffer.Count - 1] == "/") { reverseBuffer[reverseBuffer.Count - 1] = ""; } return(String.Join("/", Enumerable.Reverse(reverseBuffer))); }
protected object base_uri(XPathNodeIterator arg) { // fn:base-uri($arg as node()?) as xs:anyURI? XPathNavigator node = ExtensionObjectConvert.ToXPathNavigator(arg); if (node == null) { return(ExtensionObjectConvert.EmptyIterator); } return(node.BaseURI); }
protected bool has_children(XPathNodeIterator arg) { //fn:has-children($node as node()?) as xs:boolean XPathNavigator node = ExtensionObjectConvert.ToXPathNavigator(arg); if (node == null) { return(false); } return(node.HasChildren); }
public object root(XPathNodeIterator arg) { // fn:root($arg as node()?) as node()? XPathNavigator node = ExtensionObjectConvert.ToXPathNavigator(arg); if (node == null) { return(ExtensionObjectConvert.EmptyIterator); } XPathNavigator clone = node.Clone(); clone.MoveToRoot(); return(clone); }
public object nilled(XPathNodeIterator iter) { // fn:nilled($arg as node()?) as xs:boolean? XPathNavigator node = ExtensionObjectConvert.ToXPathNavigator(iter); if (node == null || node.NodeType != XPathNodeType.Element) { return(ExtensionObjectConvert.EmptyIterator); } IXmlSchemaInfo schemaInfo = node.SchemaInfo; return(schemaInfo != null && schemaInfo.IsNil); }
public object head(object arg) { // fn:head($arg as item()*) as item()? XPathNodeIterator iter = arg as XPathNodeIterator; if (iter == null) { // if not iterator then it's a single item return(arg); } if (ExtensionObjectConvert.IsEmpty(iter)) { return(ExtensionObjectConvert.EmptyIterator); } return(ExtensionObjectConvert.ToXPathNavigator(iter)); }