XSLT in My Photo Gallery

I now have my entire photo gallery equipped to transform itself into PDF. I’m not sure it this has any use whatsoever but it was a learning exercise.

I have Apache Tomcat running on a machine behind my firewall talking through on port 8080 with Cocoon deployed. I then added a map:match in cocoons root sitemap and setup it up so the XML was coming directly out of a php script. This script generates an XML representation of the photos inside a given album including sub-albums. I run the XSLT that I mentioned in a earlier post with a few modifications to accommodate sub-albums and included a header and footer. It works!

You can see it work here, click on the pdf link in the top right corner.

XML ~ XSLT => PDF

Now the bitching starts. The hardest thing out of this puzzle was not the XSL, PHP, or even cocoon’s sitemap. It was getting cocoon to run! I spent a considerable amount of time trying to get cocoon running in Jetty but kept getting, “Language Exception: org.apache.cocoon.componcents.language.LanguageException: Error compiling sitemap_xmap”. I tried everything I knew but could not get it working, I even went to the effort of trying to recompile Cocoon (that was fun!).

Finally I decided to use Tomcat because I had more experience with it. After setting up Tomcat I simply copied the cocoon.war file into my webapps directory and it worked. The cocoon default page never looked so good. I then began modifying the sitemap to do what I needed. Everything worked even my hacked transform. At some point I switched from the machine itself to my laptop. I only have 1.5 monitors the .5 is the small blurry 14″ that I was running the matching on. From the laptop I was running ssh to connect to the box. I was screwing around and decided to restart tomcat. When I did this everything quit working. I was pissed, I walked through every step I made and it came down to everything worked and then I restarted tomcat and it quit. The error message I was seeing was this:

FATAL_E (2003-03-09) 10:19.36:402 [core.datasources.personnel](Unknown-URI) Unknown-thread/LogKitLogger: Excalibur could not create any connections. Examine your settings to make sure they are correct. Make sure you can connect with the same settings on your machine.
ERROR (2003-03-09) 10:19.50:619 [sitemap.generator.velocity](/cocoon/Our_Pets/photo.pdf) Thread-19/VelocityGenerator: ResourceManager : unable to find resource ‘VM_global_library.vm’ in any resource loader.
ERROR (2003-03-09) 10:19.55:993 [sitemap](/cocoon/Our_Pets/photo.pdf) Thread-19/Handler: Error compiling sitemap
java.lang.InternalError: Can’t connect to X11 window server using ‘:0.0′ as the value of the DISPLAY variable.

Finally it hit me the last line “Can’t connect to X11 window server…” was the root of the problem. I had started cocoon from SSH, outside of X, so it didn’t have access to X windows. So I restarted cocoon from X and sure enough it worked. Later I was reading the install instructions for cocoon and they talk in detail about this problem. I called this a self inflicted “RTFM“.

Comments are closed.