Ejemplo n.º 1
0
            // Function to resolve references to user-defined XPath
            // extension variables in XPath query.
            public override System.Xml.Xsl.IXsltContextVariable ResolveVariable(
                string prefix, string name)
            {
                if (this.LookupNamespace(prefix) == ExtensionsNamespaceUri || !prefix.Equals(string.Empty))
                {
                    throw new XPathException(string.Format("Variable '{0}:{1}' is not defined.", prefix, name));
                }

                // Verify name of function is defined.
                if (name.Equals("text") || name.Equals("charToCount") ||
                    name.Equals("right") || name.Equals("left"))
                {
                    // Create an instance of an XPathExtensionVariable
                    // (custom IXsltContextVariable implementation) object
                    //  by supplying the name of the user-defined variable to resolve.
                    XPathExtensionVariable var;
                    var = new XPathExtensionVariable(prefix, name);

                    // The Evaluate method of the returned object will be used at run time
                    // to resolve the user-defined variable that is referenced in the XPath
                    // query expression.
                    return(var);
                }
                return(null);
            }
Ejemplo n.º 2
0
Archivo: test.cs Proyecto: mono/gert
		// Function to resolve references to user-defined XPath extension variables in XPath query.
		public override System.Xml.Xsl.IXsltContextVariable ResolveVariable (string prefix, string name)
		{
			// Create an instance of an XPathExtensionVariable (custom IXsltContextVariable
			//  implementation) object by supplying the name of the user-defined variable to resolve.
			XPathExtensionVariable Var;
			Var = new XPathExtensionVariable (name);

			// Return the XPathExtensionVariable object instance that was created. The Evaluate method of the 
			// returned object will be used at run time to resolve the user-defined variable 
			// that is referenced in the XPath query expression. 
			return Var;
		}