XmlSchemaDocumentation.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 XmlSchemaDocumentation.
  10. /// </summary>
  11. public class XmlSchemaDocumentation : XmlSchemaObject
  12. {
  13. private string language;
  14. private XmlNode[] markup;
  15. private string source;
  16. public XmlSchemaDocumentation()
  17. {
  18. }
  19. [XmlAnyElement]
  20. [XmlText]
  21. public XmlNode[] Markup
  22. {
  23. get{ return markup; }
  24. set{ markup = value; }
  25. }
  26. [System.Xml.Serialization.XmlAttribute("source")]
  27. public string Source
  28. {
  29. get{ return source; }
  30. set{ source = value; }
  31. }
  32. [System.Xml.Serialization.XmlAttribute("xml:lang")]
  33. public string Language
  34. {
  35. get{ return language; }
  36. set{ language = value; }
  37. }
  38. //<documentation
  39. // source = anyURI
  40. // xml:lang = language>
  41. // Content: ({any})*
  42. //</documentation>
  43. internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
  44. {
  45. skip = false;
  46. XmlSchemaDocumentation doc = new XmlSchemaDocumentation();
  47. reader.MoveToElement();
  48. if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "documentation")
  49. {
  50. error(h,"Should not happen :1: XmlSchemaDocumentation.Read, name="+reader.Name,null);
  51. reader.Skip();
  52. return null;
  53. }
  54. doc.LineNumber = reader.LineNumber;
  55. doc.LinePosition = reader.LinePosition;
  56. doc.SourceUri = reader.BaseURI;
  57. while(reader.MoveToNextAttribute())
  58. {
  59. if(reader.Name == "source")
  60. {
  61. doc.source = reader.Value;
  62. }
  63. else if(reader.Name == "xml:lang")
  64. {
  65. doc.language = reader.Value;
  66. }
  67. else
  68. {
  69. error(h,reader.Name + " is not a valid attribute for documentation",null);
  70. }
  71. }
  72. reader.MoveToElement();
  73. if(reader.IsEmptyElement)
  74. return doc;
  75. //Content {any}*
  76. XmlDocument xmldoc = new XmlDocument();
  77. xmldoc.AppendChild(xmldoc.ReadNode(reader));
  78. XmlNode root = xmldoc.FirstChild;
  79. if(root != null && root.ChildNodes != null)
  80. {
  81. doc.Markup = new XmlNode[root.ChildNodes.Count];
  82. for(int i=0;i<root.ChildNodes.Count;i++)
  83. {
  84. doc.Markup[i] = root.ChildNodes[i];
  85. }
  86. }
  87. if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
  88. skip = true;
  89. return doc;
  90. }
  91. }
  92. }