Exemplo n.º 1
0
  ///<summary>The entry point for the application.</summary>
  ///<param name="argv">A list of command line arguments</param>
  public static void Main
  (
   String[] argv
  )
  {
   Boolean                       booleanParseCommandLineArguments  =  false;
   String                        exceptionMessage                  =  null;

   ShaheedAliArgument            shaheedAliArgument                =  null;
   
   shaheedAliArgument = new ShaheedAliArgument();
   
   booleanParseCommandLineArguments =  UtilityParseCommandLineArgument.ParseCommandLineArguments
   ( 
    argv, 
    shaheedAliArgument
   );

   if ( booleanParseCommandLineArguments == false )
   {
    // error encountered in arguments. Display usage message
    System.Console.Write
    (
     UtilityParseCommandLineArgument.CommandLineArgumentsUsage( typeof ( ShaheedAliArgument ) )
    );
    return;
   }//if ( booleanParseCommandLineArguments  == false )

   #if (DEBUG)
    System.Console.WriteLine
    (
     "Argument filenameXMLDocument: {0} | filenameXMLSchema: {1} Files: {2}",
     shaheedAliArgument.filenameXMLDocument,
     shaheedAliArgument.filenameXMLSchema,
     shaheedAliArgument.files
    );
   #endif

   UtilityShaheedAli
   (
    ref FilenameConfigurationXml,
    ref DatabaseConnectionString,
    ref shaheedAliArgument,
    ref exceptionMessage
   );
   
  }//static void Main( String[] argv ) 
Exemplo n.º 2
0
  }//static void Main( String[] argv ) 

  ///<summary>UtilityShaheedAli</summary>
  public static void UtilityShaheedAli
  (
   ref String              filenameConfigurationXml,
   ref String              databaseConnectionString,
   ref ShaheedAliArgument  shaheedAliArgument,
   ref String              exceptionMessage
  )
  {
   
   string             title;
   string             uri;
   
   DateTime           dated;
   
   XmlReaderSettings  xmlReaderSettings  =  null;
   XmlReader          xmlReader          =  null;
   
   try
   {
    for ( int filenameXMLSchemaCount = 0; filenameXMLSchemaCount < shaheedAliArgument.filenameXMLSchema.Length; ++filenameXMLSchemaCount)
    {
     System.Console.WriteLine
     (
      "FilenameXMLSchema[{0}]: {1}",
      filenameXMLSchemaCount,
      shaheedAliArgument.filenameXMLSchema[ filenameXMLSchemaCount ]
     );
    }//for ( int filenameXMLSchemaCount = 0; filenameXMLSchemaCount < shaheedAliArgument.filenameXMLSchema.Length; ++filenameXMLSchemaCount)

    for ( int filenameXMLDocumentCount = 0; filenameXMLDocumentCount < shaheedAliArgument.filenameXMLDocument.Length; ++filenameXMLDocumentCount)
    {
     System.Console.WriteLine
     (
      "FilenameXMLDocument[{0}]: {1}",
      filenameXMLDocumentCount,
      shaheedAliArgument.filenameXMLDocument[ filenameXMLDocumentCount ]
     );
    }//for ( int filenameXMLDocumentCount = 0; filenameXMLDocumentCount < shaheedAliArgument.filenameXMLDocument.Length; ++filenameXMLDocumentCount)

    xmlReaderSettings = new XmlReaderSettings();
   
    foreach( string xmlSchema in shaheedAliArgument.filenameXMLSchema )
    {
   	 //xmlReaderSettings.Schemas.Add( xmlSchema );
    }
   
    //The XmlReader and XmlWriter implementations returned by the static Create methods are conformant by default. The XmlReader created by default has a ConformanceLevel set to "Document," meaning that it attempts to read the XML as a document. You can also set the ConformanceLevel to "Auto," meaning that it automatically attempts to either read the XML as a document or a fragment depending on the type of nodes encountered.
    xmlReaderSettings.ConformanceLevel = ConformanceLevel.Auto;

    //xmlReaderSettings.DtdValidate    = true;

    xmlReaderSettings.IgnoreWhitespace = true;
    
    //xmlReaderSettings.XsdValidate    = true;
    xmlReaderSettings.ValidationType   = ValidationType.Schema;
   
    xmlReaderSettings.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);

    /*
    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Indent=true;
    settings.NewLineOnAttributes=true;
    XmlWriter writer = XmlWriter.Create(@"c:\output.xml",settings);
    */

    foreach( string xmlDocument in shaheedAliArgument.filenameXMLDocument )
    {
     xmlReader = XmlReader.Create( xmlDocument );
     xmlReader = XmlReader.Create( xmlDocument, xmlReaderSettings );  

     /*
     while ( xmlReader.Read() ) 
     {
      if ( xmlReader.NodeType == XmlNodeType.Element )
      {
       switch ( xmlReader.Name )
       {
        case "uri":
         uri = xmlReader.ReadInnerXml();
         System.Console.WriteLine("uri: {0}", uri);
         break;
         
        case "title":
         title = xmlReader.ReadInnerXml();
         System.Console.WriteLine("title: {0}", title);
         break;
         
        case "dated":
         dated = XmlConvert.ToDateTime( xmlReader.ReadInnerXml() );
         System.Console.WriteLine("dated: {0}", dated);
         break;
       }//switch ( xmlReader.Name )  
      }//if ( xmlReader.NodeType == XmlNodeType.Element )
     }//while ( xmlReader.Read())
     */

     while ( xmlReader.Read() )
     {
      if (xmlReader.IsStartElement() && xmlReader.Name == "uri")
      {
       uri = xmlReader.ReadElementString();
       System.Console.WriteLine("uri: {0}", uri);
      } 

      if (xmlReader.IsStartElement() && xmlReader.Name == "title")
      {
       title = xmlReader.ReadElementString();
       System.Console.WriteLine("title: {0}", title);
      }

      if (xmlReader.IsStartElement() && xmlReader.Name == "dated")
      {
       dated = XmlConvert.ToDateTime( xmlReader.ReadElementString() );
       System.Console.WriteLine("dated: {0}", dated);
      }
       
     }//while ( xmlReader.Read() )
         	
    }//foreach( string xmlDocument in shaheedAliArgument.filenameXMLDocument )
   }//try
   catch (System.Xml.XmlException e) 
   {
    System.Console.WriteLine(e.Message);
   }
   catch (Exception e) 
   {
    System.Console.WriteLine(e.Message);
   }
  }//public static void UtilityShaheedAli