Hi all,
I have a question that I'm sure could be answered by some research, but I thought I'd ask here first in case somebody has some code, or so that I can get the low down right away.
Is there a good way of building links in an xml document so that a browser pointed at the file can change XSL on the same file. I.e. If I have file.xsl and I have three different views of that data (default.xsl, view2.xsl, and view3.xsl) is there a good way of setting up file.xsl so that a browser pointed at it will be able to change among views?
I want to do this with a TEI-encoded runic file that has filesheets for editorial or diplomatic presentation, and each of these in runic or roman letters.
-d
Daniel O'Donnell wrote:
Hi all,
I have a question that I'm sure could be answered by some research, but I thought I'd ask here first in case somebody has some code, or so that I can get the low down right away.
Is there a good way of building links in an xml document so that a browser pointed at the file can change XSL on the same file. I.e. If I have file.xsl and I have three different views of that data (default.xsl, view2.xsl, and view3.xsl) is there a good way of setting up file.xsl so that a browser pointed at it will be able to change among views?
Well, the easy way is to just have four output documents with links to switch between them. I.e. edRunic.html dipRunic.html edRoman.html dipRoman.html and when you generate the files just create links to the other files. So, entirely pre-processed.
If you want to do it dynamically, then you'll need something like Apache's cocoon. In the sitemap.xmap for that where you'd normally have something like:
<map:match pattern="*.html"> <map:generate src="{1}.xml" /> <map:transform src="file2html.xsl"/> <map:transform src="makePretty.xsl"/> <map:serialize encoding="UTF-8" type="xhtml"/> </map:match>
Which would hypothetically generate a file at the url/*.html from the results of putting whatever-filename-you-used.xml through file2html.xsl and then the result of that through makePretty.xsl to give you your output. Instead you'd need to pass a parameter, something like:
<map:match pattern="*.html"> <map:select type="request"> <map:parameter name="parameter-name" value="style"/> <map:when test="edRunic"> <map:generate src="{1}.xml" /> <map:transform src="edRunic.xsl"/> <map:serialize encoding="UTF-8" type="xml"/> </map:when> <map:when test="dipRunic"> <map:generate src="{1}.xml" /> <map:transform src="dipRunic.xsl"/> <map:serialize encoding="UTF-8" type="xml"/> </map:when> <map:when test="dipRoman"> <map:generate src="{1}.xml" /> <map:transform src="edRunic.xsl"/> <map:serialize encoding="UTF-8" type="xml"/> </map:when> map:otherwise" <map:generate src="{1}.xml" /> <map:transform src="edRoman.xsl"/> <map:serialize encoding="UTF-8" type="xml"/> </map:otherwise> </map:select> </map:match>
So if you did http://www.example.com/dan/foo.html you'd defaultly get the edRoman transformation for foo.xml. If you did http://www.example.com/dan/foobar.html?style=dipRunic you'd get the dipRunic one, for foobar.xml, etc.
Probably not the answer you were looking for, but might be helpful since this is the kind of thing that cocoon is really good at.
-james
On Mon, 2006-13-03 at 10:00 +0000, James Cummings wrote:
Daniel O'Donnell wrote:
Well, the easy way is to just have four output documents with links to switch between them. I.e. edRunic.html dipRunic.html edRoman.html dipRoman.html and when you generate the files just create links to the other files. So, entirely pre-processed.
That's the obvious answer, but less neat than dynamic
If you want to do it dynamically, then you'll need something like Apache's cocoon. In the sitemap.xmap for that where you'd normally have something like:
<snip>
So if you did http://www.example.com/dan/foo.html you'd defaultly get the edRoman transformation for foo.xml. If you did http://www.example.com/dan/foobar.html?style=dipRunic you'd get the dipRunic one, for foobar.xml, etc.
Probably not the answer you were looking for,
I think that's a fair assessment ;)
but might be helpful since this is the kind of thing that cocoon is really good at.
Thanks James for putting this on the record. This isn't the solution for a quick informal web page like I was thinking of this time, but it is useful to know the answer for more complicated projects.
-james