From: David Webber on

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:mmrkh5t8124ut0glkovs5sduuo024k51kk(a)4ax.com...

> Why would you need an open network connection to validate against a DTD?
>
> First, the DTD could be part of the XML file itself
>
> It could be in your resources
>
> It could be a file on the user's machine
>
> Personally, I'd vote for putting it in the resources.

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">

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
--
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

From: Joseph M. Newcomer on
See below...
On Sat, 5 Dec 2009 14:56:09 -0000, "David Webber" <dave(a)musical-dot-demon-dot-co.uk>
wrote:

>
>
>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:mmrkh5t8124ut0glkovs5sduuo024k51kk(a)4ax.com...
>
>> Why would you need an open network connection to validate against a DTD?
>>
>> First, the DTD could be part of the XML file itself
>>
>> It could be in your resources
>>
>> It could be a file on the user's machine
>>
>> Personally, I'd vote for putting it in the resources.
>
>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 mostly use it when I'm traveling, which means I'm at 35,000 feet over
Utah or I'm in some motel somewhere without connectivity. My world has to be completely
self-contained on my machine. I do not consider it reasonable to require Internet
connectivity for doing simple tasks. Such as opening and reading a file.

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

In fact, I question whether or not it EVER makes sense to allow my machine to go out to
connect to a URL. The server has to be able to support every request, and in any case, is
it not a violation of privacy?
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(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Giovanni Dicanio on
"Joseph M. Newcomer" <newcomer(a)flounder.com> ha scritto nel messaggio
news:kqloh5pu9butu1sd7qp0gsojgd75347ei6(a)4ax.com...

>><?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 mostly use it when I'm traveling, which means I'm at
> 35,000 feet over
> Utah or I'm in some motel somewhere without connectivity. My world has to
> be completely
> self-contained on my machine. I do not consider it reasonable to require
> Internet
> connectivity for doing simple tasks. Such as opening and reading a file.
>
> It makes no sense to put a remote URL into a file which is going to be
> used locally.

I completely agree with Joe's points (in fact, I'm not a big fan of those
modern trends like "cloud-computing: everything is on the web, just use dumb
machines only to connect to the web"; the web is good, but desktop and local
storage are good as well).

I believe that Dave could use XML catalogs to provide a mapping from a
generic address to specific local files on the machine.
For example, in the following Xerces web page:

http://xerces.apache.org/xerces-c/

I read:

> Features:
> ...
> Pluggable catalogs, validators and encodings


Giovanni


From: David Webber on

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:kqloh5pu9butu1sd7qp0gsojgd75347ei6(a)4ax.com...

>>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(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm

From: Giovanni Dicanio on
"David Webber" <dave(a)musical-dot-demon-dot-co.uk> ha scritto nel messaggio
news:Oil9GWydKHA.5228(a)TK2MSFTNGP06.phx.gbl...

> 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.
[...]
> I was using MSXML

Unfortunately, it seems to me that custom resolving for external resources
is not supported by MSXML:

http://social.msdn.microsoft.com/Forums/en/msxml/thread/af477368-6f40-4f10-b941-02853da8909e

But I would try with Xerces...


> (with all the horrible COM stuff).

The "horrible COM stuff" :) can be made less horrible thanks to smart
pointers like CComPtr, but they do have 'gotchas', too...
e.g.

"We're using a smart pointer, so we can't possibly be the source of the
leak"
http://blogs.msdn.com/oldnewthing/archive/2009/11/19/9924950.aspx

and the solution to the bug here:

http://blogs.msdn.com/oldnewthing/archive/2009/11/20/9925918.aspx


Giovanni