XmlSchemaAppInfo.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. using System;
  24. using System.Xml;
  25. using System.Xml.Serialization;
  26. namespace System.Xml.Schema
  27. {
  28. /// <summary>
  29. /// Summary description for XmlSchemaAppInfo.
  30. /// </summary>
  31. public class XmlSchemaAppInfo : XmlSchemaObject
  32. {
  33. private XmlNode[] markup;
  34. private string source;
  35. public XmlSchemaAppInfo()
  36. {
  37. }
  38. [System.Xml.Serialization.XmlAttribute("source", DataType="anyURI")]
  39. public string Source
  40. {
  41. get{ return source; }
  42. set{ source = value; }
  43. }
  44. [XmlAnyElement]
  45. [XmlText]
  46. public XmlNode[] Markup
  47. {
  48. get{ return markup; }
  49. set{ markup = value; }
  50. }
  51. //<appinfo
  52. // source = anyURI>
  53. // Content: ({any})*
  54. //</appinfo>
  55. internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
  56. {
  57. skip = false;
  58. XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo();
  59. reader.MoveToElement();
  60. if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo")
  61. {
  62. error(h,"Should not happen :1: XmlSchemaAppInfo.Read, name="+reader.Name,null);
  63. reader.SkipToEnd();
  64. return null;
  65. }
  66. appinfo.LineNumber = reader.LineNumber;
  67. appinfo.LinePosition = reader.LinePosition;
  68. appinfo.SourceUri = reader.BaseURI;
  69. while(reader.MoveToNextAttribute())
  70. {
  71. if(reader.Name == "source")
  72. {
  73. appinfo.source = reader.Value;
  74. }
  75. else
  76. {
  77. error(h,reader.Name + " is not a valid attribute for appinfo",null);
  78. }
  79. }
  80. reader.MoveToElement();
  81. if(reader.IsEmptyElement)
  82. return appinfo;
  83. //Content {any}*
  84. //FIXME: This is a pure Quick Hack; There must be a another method;
  85. XmlDocument xmldoc = new XmlDocument();
  86. xmldoc.AppendChild(xmldoc.ReadNode(reader));
  87. XmlNode root = xmldoc.FirstChild;
  88. if(root != null && root.ChildNodes != null)
  89. {
  90. appinfo.Markup = new XmlNode[root.ChildNodes.Count];
  91. for(int i=0;i<root.ChildNodes.Count;i++)
  92. {
  93. appinfo.Markup[i] = root.ChildNodes[i];
  94. }
  95. }
  96. if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
  97. skip = true;
  98. return appinfo;
  99. }
  100. }
  101. }