views:

449

answers:

2

Hey everyone,

I started using Visual Studio for writing my XUL, because it gives me intellisense and validation, as I use a special XUL xml-schema.

There are still some problems with this approach, that I want to fix to make VS a more usable XUL-IDE.

VS doesn't know anything about the chrome-protocol and gives me an error ("The URI prefix is not recognized") at the following piece of xml-code:

<!DOCTYPE window SYSTEM "chrome://myApp/locale/main.dtd">

This is not VS's fault. As it doesn't know the protocol, it can't interpret the URI, it doesn't know where the main.dtd lies and thus doesn't know the entities that are declared in there, which will give some other validation errors at other places.

My goal is to extend the XML parser or VS or whatever, so that it can interpret the URI. This shouldn't be a hard task, as all that chrome does is map the URI to a filepath based on the information in the "chrome.manifest" file, so

chrome://myApp/locale/main.dtd

is actually something like

file:///c:/somefolder/myapp/locale/main.dtd

I only need to know, how I can tell VS / the XML parser about the URI prefix and how to interpret it, so that it links to the real file.

Does anyone have any suggestions?

Thanks a lot!

+2  A: 

I would try the following:

  1. Use another Doctype tag on the next line below the Chrome one, except that this one uses the file:// URI scheme.
  2. If that does not work try using the file URI by itself replacing the chrome URI altogether.

There are situations where more than one doctype tag is allowed.

Jonas Gorauskas
thanks for your answer. this would of course be possible, but is unfortunately sub-optimal as it changes the source-files just for visual studio. also i may run into problems with the mozilla platform which would probably recognize both doctypes linking to the same file.thank you!
CodeSalad
+1  A: 

Dive into Program Files, under the Visual Studio installation directory appropriate for your installation.

You'll find a subdirectory for Xml, and within that one for Schemas.

For example, on my system the directory is:

C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas

Any schema file you put in here will be matched up to an XML file you edit, based on the URI of the schema.

I believe (but haven't tested) that DTDs are supported in the same way; just put your DTD in this directory, and make sure that the URI of the DTD matches.

Side note: schemas and DTDs use URIs (Universal Resource Identifiers), not URL (Universal Resource Locators). The URI actually doesn't give any information about where it is to be found. It's just a name.

Updated

Turns out that Visual Studio doesn't support DTDs, so my idea doesn't float.

Here's another possibility though: Since Visual Studio does support schemas, you might get some traction by converting the DTD into a schema. A quick google found DTD2Schema, a perl based tool on the W3 site itself. Possibly worth a try ...

Bevan
Unfortunately you can't do the same with DTD's. Compared to XML schemas, DTD's don't set a target namespace, which would be the given URL. There is a project called DTD++, which extends DTD and gives a target namespace, but you don't find that much about it in the net. Microsoft doesn't support that anyway. Thank you for your answer. It was a nice idea!
CodeSalad