public abstract class XsltContext : XmlNamespaceManager
|
ctor #1 | Overloaded:.ctor() Default constructor. This constructor is called by derived class constructors to initialize state in this type.Initializes a new instance of the XsltContext class. |
ctor #2 | Overloaded:.ctor(NameTable table) Initializes a new instance of the XsltContext class with the specified NameTable. |
DefaultNamespace (inherited from System.Xml.XmlNamespaceManager) |
Read-only See base class member description: System.Xml.XmlNamespaceManager.DefaultNamespace Gets the namespace URI for the default namespace. |
NameTable (inherited from System.Xml.XmlNamespaceManager) |
Read-only See base class member description: System.Xml.XmlNamespaceManager.NameTable Gets the XmlNameTable associated with this object. |
Whitespace | Read-only When overridden in a derived class, gets a value indicating whether to include white space nodes in the output. |
AddNamespace (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.AddNamespace Adds the given namespace to the collection. |
CompareDocument | When overridden in a derived class, compares the base URIs of two documents based upon the order the documents were loaded by the XSLT processor (that is the XslTransform class). |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetEnumerator (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.GetEnumerator Provides support for the "foreach" style iteration over the collection of namespaces in the XmlNamespaceManager. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
HasNamespace (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.HasNamespace Gets a value indicating whether the supplied prefix has a namespace defined for the current pushed scope. |
LookupNamespace (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.LookupNamespace Gets the namespace URI for the specified prefix. |
LookupPrefix (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.LookupPrefix Finds the prefix declared for the given namespace URI. |
PopScope (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.PopScope Pops a namespace scope off the stack. |
PreserveWhitespace | When overridden in a derived class, evaluates whether to preserve white space nodes or strip them for the given context. |
PushScope (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.PushScope Pushes a namespace scope onto the stack. |
RemoveNamespace (inherited from System.Xml.XmlNamespaceManager) |
See base class member description: System.Xml.XmlNamespaceManager.RemoveNamespace Removes the given namespace for the given prefix. |
ResolveFunction | When overridden in a derived class, resolves a function reference and returns an IXsltContextFunction representing the function. The IXsltContextFunction is used at execution time to get the return value of the function. |
ResolveVariable | When overridden in a derived class, resolves variable reference and returns an IXsltContextVariable representing the variable. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public XsltContext(); |
public XsltContext( |
table
public virtual string DefaultNamespace {get;}
|
if (nsmgr.HasNamespace(String.Empty)) Console.WriteLine(nsmgr.DefaultNamespace);
public XmlNameTable NameTable {get;}
|
public abstract bool Whitespace {get;}
|
prefix
uri
Exception Type | Condition |
---|---|
InvalidOperationException | The value for prefix is "xmlns". |
XmlReader checks names, including prefixes and namespaces, to ensure they are valid XML names according to the W3C specification.XmlNamespaceManager is used internally by XmlReader, so to avoid a duplication of efforts, XmlNamespaceManager assumes all prefixes and namespaces are valid.
If the prefix and namespace already exists within the current scope, it will replace the existing prefix/namespace combination. The same prefix and namespace combination can exist across different scopes.
The following prefix/namespace pairs are added by default to the XmlNamespaceManager. They can be determined at any scope.
Prefix | Namespace |
---|---|
xmlns | http://www.w3.org/2000/xmlns/ (the xmlns prefix namespace) |
xml | http://www.w3.org/XML/1998/namespace (The XML namespace) |
String.Empty | String.Empty (The empty namespace). This value can be reassigned a different prefix. For example, xmlns="" defines the default namespace to be the empty namespace |
using System; using System.IO; using System.Xml; //Reads an XML fragment public class Sample { public static void Main() { try { //The string containing the XML to read String xmlFrag="<book>" + "<title>Pride And Prejudice</title>" + "<author>" + "<first-name>Jane</first-name>" + "<last-name>Austen</last-name>" + "</author>" + "<curr:price>19.95</curr:price>" + "<misc>&h;</misc>" + "</book>"; ReadSample sample = new ReadSample(xmlFrag); sample.ReadIt(); } catch (Exception e) { Console.WriteLine ("Exception: {0}", e.ToString()); } } } // End class //Reads an XML fragment public class ReadSample { XmlValidatingReader reader = null; public ReadSample(String xmlFrag) { //create an XmlNamespaceManager to resolve namespaces NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace(String.Empty, "urn:samples"); //default namespace nsmgr.AddNamespace("curr", "urn:samples:dollar"); //Create an XmlParserContext. The XmlParserContext contains all the information //required to parse the XML fragment, including the entity information XmlParserContext context; String subset="<!ENTITY h 'hardcover'>"; context=new XmlParserContext(nt, nsmgr, "book", null, null, subset, null, null, XmlSpace.None); //create the reader reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context); } //Read the XML fragment public void ReadIt() { try { while(reader.Read()) { if (reader.HasValue) Console.WriteLine("{0} [{1}] = {2}",reader.NodeType, reader.Name, reader.Value); else Console.WriteLine("{0} [{1}]",reader.NodeType, reader.Name); } } catch (Exception e) { Console.WriteLine ("Exception: {0}", e.ToString()); } } } //End class
baseUri
nextbaseUri
~XsltContext(); |
public virtual IEnumerator GetEnumerator(); |
public virtual int GetHashCode(); |
public Type GetType(); |
prefix
if (nsmgr.HasNamespace(String.Empty)) Console.WriteLine(nsmgr.DefaultNamespace);
prefix
For more information on atomized strings, see XmlNameTable.
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { Sample test = new Sample(); } public Sample() { //Create the XmlNamespaceManager. NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); //Add prefix/namespace pairs to the XmlNamespaceManager. nsmgr.AddNamespace("", "www.wideworldimporters.com"); //Adds a default namespace. nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe"); nsmgr.PushScope(); //Pushes a namespace scope on the stack. nsmgr.AddNamespace("", "www.lucernepublishing.com"); //Adds another default namespace. nsmgr.AddNamespace("partners", "www.lucernepublishing.com/partners"); Console.WriteLine("Show all the prefix/namespace pairs in the XmlNamespaceManager..."); ShowAllNamespaces(nsmgr); } private void ShowAllNamespaces(XmlNamespaceManager nsmgr) { do{ foreach (String prefix in nsmgr) { Console.WriteLine("Prefix={0}, Namespace={1}", prefix,nsmgr.LookupNamespace(prefix)); } } while (nsmgr.PopScope()); } }
uri
The returned string is also atomized. For more information on atomized strings, see XmlNameTable.
String prefix = nsmgr.LookupPrefix("www.wideworldimporters.com/europe"); nsmgr.RemoveNamespace(prefix, "www.wideworldimporters.com/europe");
protected object MemberwiseClone(); |
public virtual bool PopScope(); |
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { Sample test = new Sample(); } public Sample() { //Create the XmlNamespaceManager. NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); //Add prefix/namespace pairs to the XmlNamespaceManager. nsmgr.AddNamespace("", "www.wideworldimporters.com"); //Adds a default namespace. nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe"); nsmgr.PushScope(); //Pushes a namespace scope on the stack. nsmgr.AddNamespace("", "www.lucernepublishing.com"); //Adds another default namespace. nsmgr.AddNamespace("partners", "www.lucernepublishing.com/partners"); Console.WriteLine("Show all the prefix/namespace pairs in the XmlNamespaceManager..."); ShowAllNamespaces(nsmgr); } private void ShowAllNamespaces(XmlNamespaceManager nsmgr) { do{ foreach (String prefix in nsmgr) { Console.WriteLine("Prefix={0}, Namespace={1}", prefix,nsmgr.LookupNamespace(prefix)); } } while (nsmgr.PopScope()); } }
public abstract bool PreserveWhitespace( |
node
public virtual void PushScope(); |
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { Sample test = new Sample(); } public Sample() { //Create the XmlNamespaceManager. NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); //Add prefix/namespace pairs to the XmlNamespaceManager. nsmgr.AddNamespace("", "www.wideworldimporters.com"); //Adds a default namespace. nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe"); nsmgr.PushScope(); //Pushes a namespace scope on the stack. nsmgr.AddNamespace("", "www.lucernepublishing.com"); //Adds another default namespace. nsmgr.AddNamespace("partners", "www.lucernepublishing.com/partners"); Console.WriteLine("Show all the prefix/namespace pairs in the XmlNamespaceManager..."); ShowAllNamespaces(nsmgr); } private void ShowAllNamespaces(XmlNamespaceManager nsmgr) { do{ foreach (String prefix in nsmgr) { Console.WriteLine("Prefix={0}, Namespace={1}", prefix,nsmgr.LookupNamespace(prefix)); } } while (nsmgr.PopScope()); } }
prefix
uri
public abstract IXsltContextFunction ResolveFunction( |
prefix
name
ArgTypes
public abstract IXsltContextVariable ResolveVariable( |
prefix
name
public virtual string ToString(); |