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"); } }
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; }
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)); }
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); }
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"); } }
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); }