XmlSchemaDocumentation.cs 3.5 KB

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