public static XS__schema[] Load_fromURI( XS__RootMetadata root_ref_in, params Uri[] filePath_in ) { XS__schema[] _output = new XS__schema[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { if (filePath_in[i].IsFile) { _output[i] = XS__schema.Load_fromFile( filePath_in[i].LocalPath )[0]; // no need! everything's been taken care at: XS__schema.Load_fromFile(...) //_output[i].root_schema_ = ROOT + "." + SCHEMA + "[" + i + "]"; //_output[i].parent_ref = root_ref_in; // ToDos: now! //if (root_ref_in != null) _output[i].root_ref = root_ref_in; } else { try { _output[i] = (XS__schema) new XmlSerializer(typeof(XS__schema)).Deserialize( OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL( filePath_in[i].ToString() ) ); } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS__schema).Namespace, typeof(XS__schema).Name, //(filePath_in[i].IsFile) // ? filePath_in[i].LocalPath // : filePath_in[i].ToString(), _ex.Message )); } _output[i].root_schema_ = ROOT + "." + SCHEMA + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output[i].root_ref = root_ref_in; } } } return(_output); }
public XS__RootMetadata( #endif string metadataFilePath_in ) { string _metadataPath = System.IO.Path.GetDirectoryName(metadataFilePath_in); this.metadatafiles_ = Metadatas.Load_fromFile(metadataFilePath_in); #region int _total_xxx = ...; int _total_metadata = 0; int _total_schema = 0; for (int f = 0; f < this.metadatafiles_.MetadataFiles.Count; f++) { switch (this.metadatafiles_.MetadataFiles[f].XMLFileType) { case XS__metadata.METADATA: _total_metadata++; break; case XS__schema.SCHEMA: _total_schema++; break; } } #endregion #region string[] _xxxFilePath = new string[_total_xxx]; string[] _metadataFilePath = new string[ _total_metadata ]; string[] _schemaFilePath = new string[ _total_schema ]; #endregion _total_metadata = 0; _total_schema = 0; for (int f = 0; f < this.metadatafiles_.MetadataFiles.Count; f++) { switch (this.metadatafiles_.MetadataFiles[f].XMLFileType) { case XS__metadata.METADATA: _metadataFilePath[_total_metadata] = System.IO.Path.Combine( _metadataPath, this.metadatafiles_.MetadataFiles[f].XMLFileName ); _total_metadata++; break; case XS__schema.SCHEMA: _schemaFilePath[_total_schema] = System.IO.Path.Combine( _metadataPath, this.metadatafiles_.MetadataFiles[f].XMLFileName ); _total_schema++; break; } } this.metadatacollection_ = new XS__metadataCollection( XS__metadata.Load_fromFile( (XS__RootMetadata)this, _metadataFilePath ) ); this.schemacollection_ = new XS__schemaCollection( XS__schema.Load_fromFile( (XS__RootMetadata)this, _schemaFilePath ) ); }
public static void Main(string[] args) { XS__RootMetadata _root = new XS__RootMetadata( System.IO.Path.Combine( #if !NET_1_1 System.Configuration.ConfigurationManager.AppSettings #else System.Configuration.ConfigurationSettings.AppSettings #endif ["ogenPath"], @"..\..\OGen-NTier\NTier_metadata\OGenXSD-metadatas\MD_NTier_metadata.OGenXSD-metadata.xml" ) ); string ntype = string.Empty; string name = string.Empty; bool must = false; OGen.XSD.Libraries.Metadata.Schema.ComplexTypeItem[] _complex = null; for (int c = 0; c < _root.SchemaCollection[0].ComplexTypeCollection.Count; c++) { must = _root.SchemaCollection[0].ComplexTypeCollection[c].mustImplementCollection( "metadataExtended", out _complex ); Console.WriteLine( "{0}:{1}", _root.SchemaCollection[0].ComplexTypeCollection[c].Name, must ); if (_complex != null) { for (int k = 0; k < _complex.Length; k++) { Console.WriteLine( "\t{0}:{1}:{2}", _complex[k].Name, _complex[k].NType, _complex[k].CaseSensitive ); } } } PressAnyKey(); return; #region //XmlSchema... // string _filepath = @"c:\test.xml"; // // FileStream _file = new FileStream( // _filepath, // FileMode.Create, // FileAccess.Write, // FileShare.ReadWrite // ); // // //ValidationEventHandler _eventHandler // // = new ValidationEventHandler(Program.ShowCompileErrors); // // XmlSerializerNamespaces _xmlserializernamespaces // = new XmlSerializerNamespaces(); // _xmlserializernamespaces.Add("PREFIX1", "NAMESPACE111"); // //_xmlserializernamespaces.Add("PREFIX2", "NAMESPACE222"); // // XmlSchema _xmlschema = new XmlSchema(); // //XmlSchema.Read( // // _file2, // // _eventHandler // //); // _xmlschema.ElementFormDefault = XmlSchemaForm.Qualified; // _xmlschema.Namespaces = _xmlserializernamespaces; // //_xmlschema.Elements; // // _xmlschema.Write(_file); // _file.Flush(); // _file.Close(); #endregion XS__schema _schema = new XS__schema(); // _schema.xmlNS_xs = "http://www.w3.org/2001/XMLSchema"; _schema.TargetNamespace = "http://ogen.berlios.de"; _schema.xmlNS = "http://ogen.berlios.de"; _schema.ElementFormDefault = "qualified"; XS_simpleTypeType _simpletype = new XS_simpleTypeType(); _simpletype.Name = "someEnum"; _simpletype.Restriction.Base = "xs:string"; _simpletype.Restriction.EnumerationCollection.Add( new XS_enumerationType("someenum1"), new XS_enumerationType("someenum2"), new XS_enumerationType("someenum3") ); _schema.SimpleTypeCollection.Add( _simpletype ); XS_attributeType _attrib1 = new XS_attributeType(); _attrib1.Name = "someAttrib1"; _attrib1.Type = "xs:string"; OGen.XSD.Libraries.Metadata.Schema.XS_complexTypeType _someType1 = new OGen.XSD.Libraries.Metadata.Schema.XS_complexTypeType(); _someType1.Name = "someType1"; _someType1.AttributeCollection.Add( _attrib1 ); XS_attributeType _attrib2 = new XS_attributeType(); _attrib2.Name = "someAttrib2"; _attrib2.Type = "xs:string"; XS_attributeType _attrib3 = new XS_attributeType(); _attrib3.Name = "someAttrib3"; _attrib3.Type = "xs:string"; OGen.XSD.Libraries.Metadata.Schema.XS_complexTypeType _someType2 = new OGen.XSD.Libraries.Metadata.Schema.XS_complexTypeType(); _someType2.Name = "someType2"; _someType2.AttributeCollection.Add( _attrib2, _attrib3 ); XS_elementType _element1 = new XS_elementType(); _element1.Name = "someCollection"; _element1.Type = "someType1"; _element1.MaxOccurs //= MaxOccursEnum.unbounded; = XS_MaxOccursType.unbounded; XS_elementType _element2 = new XS_elementType(); _element2.Name = "someItem"; _element2.Type = "someType1"; _someType2.Sequence.ElementCollection.Add( _element1, _element2 ); _schema.ComplexTypeCollection.Add( _someType1, _someType2 ); //XS_Element _someElement = new XS_Element(); //_someElement.Name = "someElement"; //_someElement.Type = "someType2"; //_schema.Element = _someElement; _schema.Element.Name = "someElement"; _schema.Element.Type = "someType2"; Console.WriteLine( "'{0}' == '{1}'", _schema.SimpleTypeCollection[0].Restriction.EnumerationCollection[2].Value, _schema.Read_fromRoot("ROOT.simpleType[0].restriction.enumeration[2].value") ); PressAnyKey(); //Console.WriteLine( // "'{0}' == '{1}'", // _schema.SimpleType[0].Restriction.Enumeration[2].XXX, // _schema.Read_fromRoot("ROOT.simpleType[0].restriction.enumeration[2].XXX") //); //Console.Write("Press any key to continue . . . "); //Console.ReadKey(true); Console.WriteLine(); //_schema.IterateThrough_fromRoot( // "ROOT.simpleType[n].restriction.enumeration[n]", // notifyme//cClaSSe.dIteration_found //); //PressAnyKey(); string _filepath = @"c:\test.xml"; _schema.SaveState_toFile(_filepath); Output(_schema); PressAnyKey(); _schema = XS__schema.Load_fromFile(_filepath)[0]; Output(_schema); PressAnyKey(); }