From: Bob J. <Bob...@lb...> - 2007-11-27 20:11:16
|
I've been working on a small project to make it possible to see JMRI XML files in a web browser. This will reduce confusion when somebody says "I've put this file here....", and also can make it easier to figure out what's in a panel file. To do this, the browser needs two things. First, it needs formatting instructions, which it gets from a line at the top of the file that looks something like this: <?xml-stylesheet href="http://jmri.sourceforge.net/xml/XSLT/panelfile.xsl" type="text/xsl"?> (There are different formatting XSLT files for different types of JMRI files right now, just to make it easier to create them; panelfile.xsl is for panel files, etc) Where should that stylesheet be located? Putting it on the web (i.e. using an HTTP reference to the file instead of getting it from the local file system) means that users will get the most recent one when they use it; since these stylesheets are probably going to continually evolve for a while, this is a good thing. On the other hand, this will only work if the browser has an active web connection. That'll be unfortunate for some people, who don't have their railroad computers hooked to the Internet, but they're not losing something they ever had. The advantage to doing this is that it will work where-ever the file is, without having to have a local copy of the XSLT file in a specific location on that computer. The browser also needs to be able to find the file's content definition, the DTD. This is a little more problematic. Currently (1.9.1 and before), JMRI loads that DTD from a local file, even when it's not going to use it to check the format of the file. (There are good technical reasons for this to be the default, which I can explain if anybody needs to know them). That's because the files have this type of definition on them: <!DOCTYPE decoder-config SYSTEM "../DTD/decoder-config.dtd"> The "../DTD/decoder-config.dtd" is a path-relative location of the DTD file for e.g. a decoder file. You can probably see the problem: If we leave it like this, browsers won't be able to display the page in lots of cases, because they can't find the DTD, because it has to be in a magic relative place. On the other hand, if we change it to e.g. <!DOCTYPE decoder-config SYSTEM "http://jmri.sourceforge.net/xml/DTD/decoder-config.dtd"> browsers with Internet connections will be able to find it, but JMRI itself won't be able to find it without an Internet connection!!! The problem with JMRI not finding it can be fixed in the JMRI code using a fall-back method, and I just committed that fix. If the given DTD location doesn't work, JMRI will now look in it's own set of DTDs. So, for new files, we have a nice solution to finding the most up-to-date DTDs, displaying XML files as web pages, and still having JMRI able to work without a web connection. But, and here's the problem, that means that files written by JMRI 1.9.2 won't be directly readable (unless somebody replaces the lines at the top with the old ones). Is this a big deal? If you want to see this in action, take a look at this link: <http://jmri.sourceforge.net/xml/samples/LogixStateMachine.xml> You can also copy the first lines from that file onto your own panel files to see what they look like. Bob -- Bob Jacobsen, UC Berkeley jac...@be... +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG |