XmlSchemaAppInfo.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml;
  5. using System.Xml.Serialization;
  6. namespace System.Xml.Schema
  7. {
  8. /// <summary>
  9. /// Summary description for XmlSchemaAppInfo.
  10. /// </summary>
  11. public class XmlSchemaAppInfo : XmlSchemaObject
  12. {
  13. private XmlNode[] markup;
  14. private string source;
  15. public XmlSchemaAppInfo()
  16. {
  17. }
  18. [System.Xml.Serialization.XmlAttribute("source")]
  19. public string Source
  20. {
  21. get{ return source; }
  22. set{ source = value; }
  23. }
  24. [XmlAnyElement]
  25. [XmlText]
  26. public XmlNode[] Markup
  27. {
  28. get{ return markup; }
  29. set{ markup = value; }
  30. }
  31. //<appinfo
  32. // source = anyURI>
  33. // Content: ({any})*
  34. //</appinfo>
  35. internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
  36. {
  37. skip = false;
  38. XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo();
  39. reader.MoveToElement();
  40. if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo")
  41. {
  42. error(h,"Should not happen :1: XmlSchemaAppInfo.Read, name="+reader.Name,null);
  43. reader.SkipToEnd();
  44. return null;
  45. }
  46. appinfo.LineNumber = reader.LineNumber;
  47. appinfo.LinePosition = reader.LinePosition;
  48. appinfo.SourceUri = reader.BaseURI;
  49. while(reader.MoveToNextAttribute())
  50. {
  51. if(reader.Name == "source")
  52. {
  53. appinfo.source = reader.Value;
  54. }
  55. else
  56. {
  57. error(h,reader.Name + " is not a valid attribute for appinfo",null);
  58. }
  59. }
  60. reader.MoveToElement();
  61. if(reader.IsEmptyElement)
  62. return appinfo;
  63. //Content {any}*
  64. //FIXME: This is a pure Quick Hack; There must be a another method;
  65. XmlDocument xmldoc = new XmlDocument();
  66. xmldoc.AppendChild(xmldoc.ReadNode(reader));
  67. XmlNode root = xmldoc.FirstChild;
  68. if(root != null && root.ChildNodes != null)
  69. {
  70. appinfo.Markup = new XmlNode[root.ChildNodes.Count];
  71. for(int i=0;i<root.ChildNodes.Count;i++)
  72. {
  73. appinfo.Markup[i] = root.ChildNodes[i];
  74. }
  75. }
  76. if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
  77. skip = true;
  78. return appinfo;
  79. }
  80. }
  81. }