Jump to content

Yet another way to play with GPX files


parkrrrr

Recommended Posts

I've been playing with yet another tool that's available on everyone's computer already that makes processing GPX files fun, and I finally have some somewhat-interesting results to share.

 

If you go here you will see what looks like a webpage with a bunch of Indiana caches in it. What it really is is a GPX file, formatted with this stylesheet. The only modification to the GPX file was to add a line that says

<?xml-stylesheet type="text/xsl" href="http://parkrrrr.com/News/test.xsl" ?>
just after the first line.

 

Some web browsers would let you do the stylesheet association without editing the XML file, but I don't think IE is one of them (or at least, I can't find where you'd do that.) If I find time, I'll try to whip up a quicky little program that lets you apply a stylesheet to a gpx file and save the result.

 

If you like it, consider the .xsl file my gift to you, and feel free to share your new, improved versions.

 

warm.gif

Link to comment

I got it to work on Sissy's machine that has MSIE 6.0 on it, but my machine won't and it is running MSIE 5.5.

 

I'm sure there's just some switch or something, but I haven't been about to find it yet.

 

Can something like this be embedded in an HTML file? Something like an Include or something? Or could it generate an HTML file? The reason I ask, I'd like to create a pocket query for the caches I've done and the caches I've placed and have something like this generate the list so I can insert it into my homepage--when I get a "round tuit."

 

I've looked at the XSL file and I can kind of engineer it to produce a page to my liking, but I don't know how to include it in another page or produce the HTML.

 

Looks cool though.

 

CR

 

72057_2000.gif

Link to comment

quote:
Originally posted by Sissy-n-CR:

Can something like this be embedded in an HTML file? Something like an Include or something? Or could it generate an HTML file?


 

There are scripting interfaces to the MSXML parser, so you could create Javascript or VBScript that does the transformation for you. (View source on that "vbscript" link to see how it's done.)

 

(Edit: I just noticed that that page says "access is denied" when you try to run the transformation. That's a security zones thing; if you save it to your own computer first that error will go away.)

 

warm.gif

 

[This message was edited by Warm Fuzzies - Fuzzy on January 08, 2003 at 06:19 AM.]

Link to comment

quote:
Originally posted by BigNick:

quote:
Originally posted by fizzymagic:

Doesn't work in Mozilla 1.2.1


Or IE and Safari for OSX


 

I never replied to either of these, so I suppose I should: your browser has to know what to do with XML and XSLT. That's technically not something browsers are required to be able to do, so it's unlikely that they're the best tools for the job. If you want to see what it looks like, get an XSLT processor and use it to view the results.

 

warm.gif

Link to comment

quote:
Originally posted by Warm Fuzzies - Fuzzy:

I never replied to either of these, so I suppose I should: your browser has to know what to do with XML and XSLT.


 

That's why I replied in the first place; if there is any browser that knows what to do with XSLT, it's Mozilla, of which I have the newest version. I'm sorry I didn't elaborate. I haven't had the time to track down the problem, but I am pretty sure it is some minor syntax error in the XSL, as Mozilla is also notoriously picky, while IE is notoriously lax.

 

The XSL solution for GPX to HTML would need some modification to make it useful for palmable geocaching, since ideally you want a separate page for each cache, along with an index page. But I can see a way to do much of that.

 

The one new feature I am working on adding to my (now working) HTML-page-converter is adding "nearest caches" to each HTML page for easy navigation. I can't immediately see an way to do that in XSL, but, then again, I am hardly an XSL expert.

Link to comment

quote:
Originally posted by fizzymagic:

I haven't had the time to track down the problem, but I am pretty sure it is some minor syntax error in the XSL, as Mozilla is also notoriously picky, while IE is notoriously lax.


 

But the XSL was developed with libxslt on Linux, and xslproc didn't complain. I'll download the latest Mozilla and see what I can see.

 

quote:

The XSL solution for GPX to HTML would need some modification to make it useful for palmable geocaching, since ideally you want a separate page for each cache, along with an index page. But I can see a way to do much of that.


 

Yes, that's the one thing I want to do too. XSL can't do it, as far as I know. I'm thinking of creating an XML schema for "bundled HTML pages" that can then be split by a simple parser.

 

quote:

The one new feature I am working on adding to my (now working) HTML-page-converter is adding "nearest caches" to each HTML page for easy navigation. I can't immediately see an way to do that in XSL, but, then again, I am hardly an XSL expert.


 

Nope, XSL doesn't support any transcendental functions (except possibly through extensions), so you can't compute the distance.

 

warm.gif

Link to comment

quote:
Originally posted by Warm Fuzzies - Fuzzy:

 

But the XSL was developed with libxslt on Linux, and xslproc didn't complain. I'll download the latest Mozilla and see what I can see.


 

I'm feeling like the emporer sitting here in my underoos. Mozilla 1.1 rendered the page as dogmeat. I just installed 1.3a and it churns for a minute or two and then hocks up a blank page.

 

While I have xsltproc, it's alien to me. Can you provide an example invocation that's sure to impress us? This sounds like neat stuff, but I just can't seem to get the entry ticket.

Link to comment

quote:
Originally posted by robertlipe:

I'm feeling like the emporer sitting here in my underoos. Mozilla 1.1 rendered the page as dogmeat. I just installed 1.3a and it churns for a minute or two and then hocks up a blank page.


 

Same for me. So I copied the xml file locally and deleted all but a couple of caches. Now it generates the blank page much more quickly. But it's not a normal blank page; it is dark. So something is happening, but I don't know quite what.

 

quote:
While I have xsltproc, it's alien to me. Can you provide an example invocation that's sure to impress us?

 

I, too, know practically nothing about XSLT. But there is a test page for Mozilla here, and it works with mine.

 

Fuzzy: making multiple HTML pages from an XSLT-parsed XML file should be pretty easy. I'd just put in marker text with a file name in it and use Perl to split it into files. But, as I said, my main issue is with the "nearest caches" feature.

 

I have a working GPX-to-HTML app now, and I am going to try to add the nearest cache feature to it tonight. Takes two passes; one for the positions, and another to generate the pages. I'm going to initially do it all in Perl, making a big associative array of names and positions, but eventually I want to move it to SQL so I can do nifty queries on it. So here's the question: should I do the DB stuff using ODBC, in which case it's easy for Windows people but a pain for Linux people, or use MySQL, in which case everyone would have to install a DB?

Link to comment

quote:
Originally posted by fizzymagic:

quote:
While I have xsltproc, it's alien to me. Can you provide an example invocation that's sure to impress us?

 

I, too, know practically nothing about XSLT. But there is a test page for Mozilla http://www.mozilla.org/projects/xslt/test.xml, and it works with mine.


 

$ xsltproc test.xsl 4548.xml >4548-proc.html

 

spits out this (there was something incompatible with the way it generates the table of contents whitespace; that part worked on IE but not on xsltproc. However, that part wasn't there when I first posted this, so whatever is broken, it's something else.)

 

quote:

Fuzzy: making multiple HTML pages from an XSLT-parsed XML file should be pretty easy. I'd just put in marker text with a file name in it and use Perl to split it into files.


 

Ah, but I want to do this on an arbitrary Joe Geocacher's machine, so Perl is not really an option. Obviously, whatever application runs the stylesheet could also do the "split" process, but if you switch away from XML or HTML output, you lose a lot of validation opportunities. So, similar to what you're suggesting, I'd spit it out as XML where you have a element containing a bunch of elements, each of which contains a webpage.

 

quote:

But, as I said, my main issue is with the "nearest caches" feature.


 

I think I have that handled for myself; it's just a matter of implementing an xpath extension function, but I need to read up on how to make extension functions available to MSXML. However, by its very nature an extension function makes the whole thing a lot less cross-platform.

 

quote:

but eventually I want to move it to SQL so I can do nifty queries on it. So here's the question: should I do the DB stuff using ODBC, in which case it's easy for Windows people but a pain for Linux people, or use MySQL, in which case everyone would have to install a DB?


 

Why not use DBI so the end-user can just switch to his or her database of choice?

 

warm.gif

Link to comment

I think we've found a Mozilla problem, not an XSL problem. Sorry for doubting you, Fuzzy.

 

quote:
Originally posted by Warm Fuzzies - Fuzzy:

Why not use DBI so the end-user can just switch to his or her database of choice?


 

Duh. (sound of head hitting keyboard).

 

Of course.

 

Thanks!

Link to comment

quote:
Originally posted by fizzymagic:

I think we've found a Mozilla problem, not an XSL problem. Sorry for doubting you, Fuzzy.


 

I think this bug is related, at least partially. I fixed my Apache config to serve the right MIME types for .xml and .xsl files, though, and it doesn't seem to have made the situation much better; it's using the default stylesheet on Mozilla 1.3b.

 

warm.gif

Link to comment

Thanks Fuzzy. I really like this method.

 

There is one problem with my gpx file. The cache owners' HTML can take control of the page. Background images are popular here, for instance. Also, this page turned on centered paragraphs and didn't turn center off. The whole last half of my file is centered.

 

Is there any way of restoring the default formatting between page descriptions? How about disabling backgrounds?

Link to comment

quote:
Originally posted by John E Cache:

There is one problem with my gpx file. The cache owners' HTML can take control of the page. Background images are popular here, for instance.


 

Plucker won't use background images anyway, so you could probably ignore them if Plucker is your ultimate goal. Removing them is difficult. The descriptions, which contain the sort of thing you're talking about, are just text as far as XSLT is concerned. XPath has some provisions for editing text, but nothing truly sophisticated. Since you can't depend on the HTML being well-formed XML, you can't use XSLT to edit it, even if you had a way to turn the text into an XML tree.

 

In addition, there are lots of ways to set a background image. In addition to the (illegal) extra

tags, there are CSS tricks like the one you see being used in my sample file on Perfectly Perplexing Puzzles.

 

quote:

Also, this page turned on centered paragraphs and didn't turn center off. The whole last half of my file is centered.


 

This, thankfully, is easy to fix (although a "proper" browser should be able to assume that the "

" tag is turned off when the element enclosing it ends.) All you need to do to fix this behavior is add a
at the end of the template for gpx:wpt mode="body". Yeah, that'll be illegal, but any browser that treats
the way IE does probably doesn't care.

 

warm.gif

Link to comment

quote:
Originally posted by Warm Fuzzies - Fuzzy:

 

This, thankfully, is easy to fix (although a "proper" browser should be able to assume that the "

" tag is turned off when the element enclosing it ends.) All you need to do to fix this behavior is add a
at the end of the template for gpx:wpt mode="body". Yeah, that'll be illegal, but any browser that treats
the way IE does probably doesn't care.


 

My post was very poorly stated. It should have been two posts. One about Plucker and one about the problems I had a with IE.

 

I haven't tried Plucker and wondered if Plucker would handle these templates(question 1). The problems I had were with IE. I downloaded MSXML 4.0 but I don't know if that makes a difference.

 

I'll try your suggestion. Thanks.

Link to comment
Guest
This topic is now closed to further replies.
×
×
  • Create New...