Exemple #1
0
		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.lib.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.lib.metadata.schema.XS_complexTypeType _someType1 = new OGen.XSD.lib.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.lib.metadata.schema.XS_complexTypeType _someType2 = new OGen.XSD.lib.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();
		}
Exemple #2
0
        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.lib.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.lib.metadata.schema.XS_complexTypeType _someType1 = new OGen.XSD.lib.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.lib.metadata.schema.XS_complexTypeType _someType2 = new OGen.XSD.lib.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();
        }