// Author: Dwivedi, Ajay kumar
// Adwiv@Yahoo.com
using System;
using System.Xml;
using System.Xml.Serialization;
namespace System.Xml.Schema
{
///
/// Summary description for XmlSchemaSimpleContentExtension.
///
public class XmlSchemaSimpleContentExtension : XmlSchemaContent
{
private XmlSchemaAnyAttribute any;
private XmlSchemaObjectCollection attributes;
private XmlQualifiedName baseTypeName;
private int errorCount=0;
public XmlSchemaSimpleContentExtension()
{
baseTypeName = XmlQualifiedName.Empty;
attributes = new XmlSchemaObjectCollection();
}
[XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
public XmlSchemaAnyAttribute AnyAttribute
{
get{ return any; }
set{ any = value; }
}
[XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
[XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
public XmlSchemaObjectCollection Attributes
{
get{ return attributes; }
}
[System.Xml.Serialization.XmlAttribute("base")]
public XmlQualifiedName BaseTypeName
{
get{ return baseTypeName; }
set{ baseTypeName = value; }
}
///
/// 1. Base must be present and a QName
///
[MonoTODO]
internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
{
if(BaseTypeName == null || BaseTypeName.IsEmpty)
{
error(h, "base must be present and a QName");
}
if(this.AnyAttribute != null)
{
AnyAttribute.Compile(h,info);
}
foreach(XmlSchemaObject obj in Attributes)
{
if(obj is XmlSchemaAttribute)
{
XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
attr.Compile(h,info);
}
else if(obj is XmlSchemaAttributeGroup)
{
XmlSchemaAttributeGroup atgrp = (XmlSchemaAttributeGroup) obj;
atgrp.Compile(h,info);
}
else
error(h,"object is not valid in this place");
}
if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
error(h, "id must be a valid ID");
return errorCount;
}
[MonoTODO]
internal int Validate(ValidationEventHandler h)
{
return errorCount;
}
internal void error(ValidationEventHandler handle,string message)
{
ValidationHandler.RaiseValidationError(handle,this,message);
}
}
}