Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Schema with Entity -- Validating Error

Schema with Entity -- Validating Error

Scheduled Pinned Locked Moved XML / XSL
csharpxmldatabasehelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xfun556
    wrote on last edited by
    #1

    Hi, I wrote a Schema Validator in C#.NET. XmlTextReader R = new XmlTextReader(FileToParse); XmlValidatingReader V = new XmlValidatingReader(R); try { XmlSchemaCollection xsc = new XmlSchemaCollection(); xsc.Add("", SchemaFile); V.Schemas.Add(xsc); V.EntityHandling = EntityHandling.ExpandEntities; V.ValidationEventHandler += new ValidationEventHandler(ShowValidationErrors); while (V.Read()) { } //V.Close(); //MessageBox.Show("Validation Completed"); //R.Close(); } catch (XmlException xe) { //Display exceptions } catch (XmlSchemaException xse) { //Display exceptions } catch (Exception ee) { //Display exceptions } finally { V.Close(); MessageBox.Show("Validation Completed"); } This works fine if the xml file DOES NOT contain entity declarations. But, If the xml file contains any entity declaration (as below), the 'ValidationEventHandler' throws errors like "Validation Error: The 'mytest' element is not declared.Line : 8 Position : 2" "Validation Error: The 'articles' element is not declared.Line : 9 Position : 2", etc..... How do I overcome this in C#.NET ]>

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups