I'm currently playing around with Xalan as the basis for a drag'n'drop application to be used to build static HTML web pages from XML/XSLT sources. This will replace the tool I currently use, which is a home-brewed macro processor written in Perl.

One useful feature of the system I use now is that when it comes across an HREF or a SRC attribute, it will scan upwards in the directory tree until it finds a matching file, and insert the correct relative URL. So if I have a directory structure like:

        home
           foo.html
           bar.jpg
           subdirectory
              baz.html

Then my source code for 'baz.html' and 'foo.html' can just include a tag of the form <IMG SRC="bar.jpg">, and the processor will automatically turn it into <IMG SRC="../bar.jpg"> where necessary. It will also issue a warning if it can't find the referenced file. As you can imagine, this makes life a lot easier where I have standard graphics on every page - I don't have to calculate the precise offset between each individual page and the standard graphic. This could also be crucial in cases where the graphic is inserted by a template (i.e. an XSL stylesheet).

I'd like the new system to do something similar, but before I get too deep into it, I wanted to check that there's not some magic way of doing this already supported by Xalan or XSLT.

Assuming that there isn't such a facility built-in, does anyone have any suggestions on how to write it? Currently, I'm transforming straight to a stream attached to a target file. Presumably, I could build an object that would take the output from the transformer as a stream, scan that for the relevant attributes, perform re-referencing and then kick the result out to file (or perhaps to another object that would do HTML optimization ...). But the output is likely to be HTML, which would suggest that I'll have to do string manipulations, rather than getting an XML document tree from which it would be relatively easy to pick out the relevant tags and attributes.

Any comments or advice?

Thanks in advance

        Angus
--
[EMAIL PROTECTED]                             http://pobox.com/~angus

Reply via email to