XsltContext.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // System.Xml.Xsl.XsltContext
  2. //
  3. // Author: Tim Coleman <[email protected]>
  4. // (C) Copyright 2002 Tim Coleman
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining
  7. // a copy of this software and associated documentation files (the
  8. // "Software"), to deal in the Software without restriction, including
  9. // without limitation the rights to use, copy, modify, merge, publish,
  10. // distribute, sublicense, and/or sell copies of the Software, and to
  11. // permit persons to whom the Software is furnished to do so, subject to
  12. // the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be
  15. // included in all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  21. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. //
  25. using System;
  26. using System.Xml;
  27. using System.Xml.XPath;
  28. namespace System.Xml.Xsl
  29. {
  30. public abstract class XsltContext : XmlNamespaceManager
  31. {
  32. #region Constructors
  33. #if NET_2_0
  34. protected
  35. #else
  36. public
  37. #endif
  38. XsltContext ()
  39. : base (new NameTable ())
  40. {
  41. }
  42. #if NET_2_0
  43. protected
  44. #else
  45. public
  46. #endif
  47. XsltContext (NameTable table)
  48. : base (table)
  49. {
  50. }
  51. #endregion
  52. #region Properties
  53. public abstract bool Whitespace { get; }
  54. public abstract bool PreserveWhitespace (XPathNavigator nav);
  55. #endregion
  56. #region Methods
  57. public abstract int CompareDocument (string baseUri, string nextbaseUri);
  58. public abstract IXsltContextFunction ResolveFunction (string prefix, string name, XPathResultType [] argTypes);
  59. public abstract IXsltContextVariable ResolveVariable (string prefix, string name);
  60. #endregion
  61. #region XSLT Internal Calls
  62. internal virtual IXsltContextVariable ResolveVariable (XmlQualifiedName name)
  63. {
  64. return ResolveVariable (name.Name, name.Namespace);
  65. }
  66. internal virtual IXsltContextFunction ResolveFunction (XmlQualifiedName name, XPathResultType [] argTypes)
  67. {
  68. return ResolveFunction (name.Name, name.Namespace, argTypes);
  69. }
  70. #endregion
  71. }
  72. // The static XSLT context, will try to simplify what it can
  73. internal interface IStaticXsltContext
  74. {
  75. Expression TryGetVariable (string nm);
  76. Expression TryGetFunction (XmlQualifiedName nm, FunctionArguments args);
  77. XmlQualifiedName LookupQName (string s);
  78. string LookupNamespace (string prefix);
  79. }
  80. }