Re: How to read an XML file in Visual C++ 6

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message news:kqloh5pu9butu1sd7qp0gsojgd75347ei6@xxxxxxxxxx

Because the musicXML data files, which are passed over the internet, start
with things like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0
Partwise//EN"

"http://www.musicxml.org/dtds/partwise.dtd";>

****
It is really critical that a program I use (such as yours) be usable in any venue under
any conditions...

I agree 100%.

It makes no sense to put a remote URL into a file which is going to be used locally.

But MusicXML is a music notation exchange format to enable different programs to exchange data: one exports in this format, another imports. Such files are designed to be circulated across the internet.

Therefore, given that a doctype statement is required and refers to a DTD for validation, what other option is there than to refer to the DTD maintained by the originators of the format?

It would seem reasonable that a method should exist to validate the document witha replacement DTD - ie tell it to use a version of the .dtd file to be found in a specified place on the local computer.

Going back to my attempts, done a couple or more years ago, to prove I could parse XML:

I was using MSXML (with all the horrible COM stuff). Roughly:

====
MSXML2::IXMLDOMDocumentPtr xd_pDom;
HRESULT hr = xd_pDom.CreateInstance(__uuidof(DOMDocument40));

And then if success so far:

BOOL bResult = TRUE;

xd_pDom->async = VARIANT_FALSE; // default - true,
xd_pDom->validateOnParse = VARIANT_FALSE; // don't check the DTD?

if( xd_pDom->load( _T("MyXMLfile.xml") )!=VARIANT_TRUE )
{
bResult = FALSE;
// .....Cope with failure.......
xd_pDom.Release();
}
else
{
// Successfully loaded:

bResult = TRUE;
}
====

Now it all works, and the pointer to the DOM is usable, if I have an open internet connection, but the load call fails if I haven't.
Even with validateOnParse = VARIANT_FALSE.

A few years ago I started all this to prove the concept of reading and parsing the XML. This was the only showstopper I found. Logic tells me taht somewhere there *must* be a way around demanding validation using the DTD file referenced in the document!

Nowadays, I could probably acept that there's a better chance that anyone doing this has an open broadband connection but i don't want to - for all the reasons you give, and just because it is so inelegant relying on the internet when all I want to do is read a local file.

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm














joe
****
I'd be very happy to keep a local copy of the DTD in the resources of the
DLL import module, but I didn't find a way to tell it to use that instead of
the DTD prescribed in the XML file. Am I missing something obvious?

Dave
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

.



Relevant Pages

  • Re: XPath to Line Number?
    ... how can I find the line-number of that node in the original XML ... bunch of validation rules, and outputs any errors and/or warnings. ... I am having trouble with finding a good DTD or Schema ... think it just makes DTD information available in the tree. ...
    (comp.lang.perl.modules)
  • Re: XPath to Line Number?
    ... how can I find the line-number of that node in the original XML ... bunch of validation rules, and outputs any errors and/or warnings. ... I am having trouble with finding a good DTD or Schema ...
    (comp.lang.perl.modules)
  • Re: 2 Questions about validations
    ... Validation is a process of checking validity. ... There are often rules that are clearly syntactic in nature but cannot be expressed in a DTD, or just have not been expressed in a DTD. ... Moreover, in some areas other than HTML, but pragmatically related to HTML, "validity" or "validation" is a technical term, with a meaning that is sufficiently similar to SGML or XML validity to confuse people. ...
    (comp.infosystems.www.authoring.html)
  • Re: XmlValidatingReader DTD validation
    ... Your document has to have DOCTYPE to perform DTD validation. ... being used to resolve external entities, ... > I have a local copy of the DTD that I need to validate incoming XML ...
    (microsoft.public.dotnet.xml)
  • Re: Extended Markup?
    ... HTML _isn't_ that hard. ... Validation is based on measuring compliance with the DTD There's no ... "Not common practice 10 years ago" ...
    (alt.html)