示例#1
0
 public TipoSimpleXsd(XmlNode source)
 {
     try{
         nombre      = source.Attributes["nombre"].Value;
         restriccion = new RestriccionXsd(source["restriccion"]);
     }catch {
         throw new XsdException("El nodo no es de un TipoSimpleXsd valido");
     }
 }
示例#2
0
 public TipoSimpleXsd(string nombre, RestriccionXsd restriccion)
 {
     Restriccion = restriccion;
     if (nombre != null)
     {
         nombre = nombre.Trim(new char[] { ' ', '\r', '\t', '\n', '"' });           //poner caracteres prohibidos
     }
     Nombre      = nombre;
     Restriccion = restriccion;
 }
示例#3
0
        public override bool Equals(object obj)
        {
            RestriccionXsd other = obj as RestriccionXsd;

            if (other == null)
            {
                return(false);
            }
            return(object.Equals(this.tipoBaseRestriccion, other.tipoBaseRestriccion) && object.Equals(this.restricciones, other.restricciones) && object.Equals(this.elementosEnumerados, other.elementosEnumerados));
        }
示例#4
0
        public dynamic Clon()
        {
            RestriccionXsd clon = new RestriccionXsd(tipoBaseRestriccion);

            foreach (KeyValuePair <Restricciones, string> restriccion in restricciones)
            {
                clon.restricciones.Afegir(restriccion.Key, restriccion.Value);
            }
            clon.elementosEnumerados.AfegirMolts(elementosEnumerados);
            return(clon);
        }
示例#5
0
        public TipoComplejoXsd(XmlNode source) : this()
        {
            string orden = "sequence";

            try{
                nombre  = source.Attributes["name"].Value;
                isEmpty = source.HasChildNodes;
                if (!isEmpty)
                {
                    if (source["simpleContent"] != null)
                    {
                        //simple
                        simpleContent = new RestriccionXsd(source["simpleContent"]["restriccion"]);
                    }
                    else
                    {
                        //complejo
                        mixed = bool.Parse(source.Attributes["mixed"].Value);
                        if (source["extension"] != null)
                        {
                            isExtensibleElements = source["extension"]["any"] != null;
                            tipoXsdBase          = source["extension"].Attributes["base"].Value;
                            if (source["extension"]["all"] != null)
                            {
                                orden = "all";
                            }
                            else if (source["extension"]["choice"] != null)
                            {
                                orden = "choice";
                            }
                            else if (source["extension"]["sequence"] == null)
                            {
                                throw new Exception();
                            }

                            foreach (XmlNode elemento in source["extension"][orden].ChildNodes)
                            {
                                Añadir(new ElementoXsd(elemento), elemento.Attributes["ref"] != null, int.Parse(elemento.Attributes["minOccurs"].Value), int.Parse(elemento.Attributes["maxOccurs"].Value));
                            }
                        }
                        else
                        {
                            isExtensibleElements = source["any"] != null;
                            if (source["all"] != null)
                            {
                                orden = "all";
                            }
                            else if (source["choice"] != null)
                            {
                                orden = "choice";
                            }
                            else if (source["sequence"] == null)
                            {
                                throw  new Exception();
                            }

                            foreach (XmlNode elemento in source[orden].ChildNodes)
                            {
                                Añadir(new ElementoXsd(elemento), elemento.Attributes["ref"] != null, int.Parse(elemento.Attributes["minOccurs"].Value), int.Parse(elemento.Attributes["maxOccurs"].Value));
                            }
                        }
                    }
                    //atributos
                    foreach (XmlNode atributo in source["attribute"])
                    {
                        Añadir(new AtributoXsd(atributo), atributo["ref"] != null);
                    }
                    isExtensibleAttribute = source["anyAttribute"] != null;
                }
            }catch {
                throw new XsdException("el nodo no es un TipoComplejoXsd valido");
            }
        }
示例#6
0
        public override string ToString()
        {
            text elementoComplejo = "";
            text simpleContent    = "";

            elementoComplejo = "<xs:complexType";
            if (Nombre != null)
            {
                elementoComplejo &= " name=\"" + nombre + "\"";
            }
            elementoComplejo &= ">";
            if (IsTextOnly)
            {
                elementoComplejo &= "xs:simpleContent>";
                simpleContent     = SimpleContent.ToString();
                simpleContent.Remove("</xs:restriccion>");
                elementoComplejo &= simpleContent;                //con sus restricciones
            }
            else if (!IsEmpty)
            {
                elementoComplejo = "<xs:complexType";
                if (Nombre != null)
                {
                    elementoComplejo &= " name=\"" + nombre + "\"";
                }
                elementoComplejo &= " mixed=\"" + mixed.ToString().ToLower() + "\"><xs:complexContent>";
                if (tipoXsdBase != null)
                {
                    elementoComplejo &= "<xs:extension base=\"" + tipoXsdBase + "\">";
                }
                elementoComplejo &= "<" + orden.ToString().ToLower() + ">";
                foreach (KeyValuePair <ElementoXsdOrdenado, string> elemento in elementos)
                {
                    elementoComplejo &= elemento.Value;
                }
                elementoComplejo &= "</" + orden.ToString().ToLower() + ">";
                if (IsExtensibleElement)
                {
                    elementoComplejo &= "<xs:any minOccurs=\"0\"/>";
                }
            }
            foreach (KeyValuePair <AtributoXsd, string> atributo in atributos)
            {
                elementoComplejo &= atributo.Value;
            }
            if (tipoXsdBase != null && !IsEmpty && !IsTextOnly)
            {
                elementoComplejo &= "</xs:extension>";
            }
            if (IsExtensibleAttribute)
            {
                elementoComplejo &= "<xs:anyAttribute/>";
            }
            if (!IsEmpty && !IsTextOnly)
            {
                elementoComplejo &= "</xs:complexContent>";
            }
            if (IsTextOnly)
            {
                elementoComplejo &= "</xs:restriccion>";
                elementoComplejo &= "</xs:simpleContent>";
            }
            elementoComplejo &= "</xs:complexType>";

            return(elementoComplejo);
        }