Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 127151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:25:52+00:00 2026-05-11T05:25:52+00:00

I’m trying to validate an XML file against the schemas it references. (Using Delphi

  • 0

I’m trying to validate an XML file against the schemas it references. (Using Delphi and MSXML2_TLB.) The (relevant part of the) code looks something like this:

procedure TfrmMain.ValidateXMLFile; var     xml: IXMLDOMDocument2;     err: IXMLDOMParseError;     schemas: IXMLDOMSchemaCollection; begin     xml := ComsDOMDocument.Create;     if xml.load('Data/file.xml') then     begin         schemas := xml.namespaces;         if schemas.length > 0 then         begin             xml.schemas := schemas;             err := xml.validate;         end;     end; end; 

This has the result that cache is loaded (schemas.length > 0), but then the next assignment raises an exception: ‘only XMLSchemaCache-schemacollections can be used.’

How should I go about this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:25:52+00:00Added an answer on May 11, 2026 at 5:25 am

    I’ve come up with an approach that seems to work. I first load the schema’s explicitly, then add themn to the schemacollection. Next I load the xml-file and assign the schemacollection to its schemas property. The solution now looks like this:

    uses MSXML2_TLB   That is:   // Type Lib: C:\Windows\system32\msxml4.dll   // LIBID: {F5078F18-C551-11D3-89B9-0000F81FE221}  function TfrmMain.ValidXML(     const xmlFile: String;      out err: IXMLDOMParseError): Boolean; var     xml, xsd: IXMLDOMDocument2;     cache: IXMLDOMSchemaCollection; begin     xsd := CoDOMDocument40.Create;     xsd.Async := False;     xsd.load('http://the.uri.com/schemalocation/schema.xsd');      cache := CoXMLSchemaCache40.Create;     cache.add('http://the.uri.com/schemalocation', xsd);      xml := CoDOMDocument40.Create;     xml.async := False;     xml.schemas := cache;      Result := xml.load(xmlFile);     if not Result then       err := xml.parseError     else       err := nil; end; 

    It is important to use XMLSchemaCache40 or later. Earlier versions don’t follow the W3C XML Schema standard, but only validate against XDR Schema, a MicroSoft specification.

    The disadvantage of this solution is that I need to load the schema’s explicitly. It seems to me that it should be possible to retrieve them automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.