[SlugBug] more xslt questions. ignore if offended!

Mike Dewar m.dewar at sheffield.ac.uk
Fri Jun 24 16:46:05 BST 2005


OK. Have edited the xsl as you suggested. Thanks for the help.

I'm using Perl and the XML::XSLT library to do the transformation.

It's still spitting out the contents of the last <page>  element rather 
than the page element with the attribute title="home". Am I selecting 
it correctly with the lines:

<xsl:apply-templates select="page[@title='Home']"/>

....

<xsl:template match="page">

...

</xsl:template>

?

I can't for the life of me figure this out and I wanna set fire to my 
laptop.

Cheers

Mike


On 21 Jun 2005, at 18:26, Chris J wrote:

>
> [[ much snippage ]]
>
> And Lo! The Great Prophet Mike Dewar uttered these words of wisdom:
>>
>> For some reason, though, when I run the xslt the only page that is
>> displayed is the other page, the "World Domination Map" page. I've
>> tried not putting the attribute in the template match, like this:
>>
>
> What are you using as the XSL engine? Perl? PHP? Something custom 
> using a
> library? Something else? :-)
>
> One problem I've had with both MSXML's engine and older versions of 
> Sablotron
> is the lack of a template to handle the root element. So I'd advise to
> start with having a simple:
>
> 	<xsl:template match="/">
> 		<xsl:apply-tempates select="site" />
> 	</xsl:template>
>
> And treat that essentially as the entry point.
>
> You may even be able to do:
>
> 	<xsl:template match="/site">
> 		.
> 		.
> 	[your existing template that's just matching on site]
> 		.
> 		.
> 	</xsl:template>
>
> i.e., the addition of the '/' before site.
>
> You may also need to modify the top of your XSLT thusly:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0">
>
> Without the namespace declaration, Sablotron didn't want to know 
> (complained
> that 'xsl' was not a declared prefix - which is fair enough; any XML 
> parser
> worth its salt will fall over at syntax issues like undeclared 
> namespaces).
>
> Tweak them to start with, let me know what happens :-)
>
> Other things you could do is change the output format to xml from html 
> -
> this will ensure you spit out XHTML (I notice you've mentioned XHTML 
> in the
> comments of site.xml :-) ).
>
> You'll also need to tweak your site.xml graphics elements. Sablotron is
> spitting out this:
>
> <img src="%0a%09%09%09globe_section.png%0a%09%09%09">  (HTML out)
> or
> <img src="&#10;&#9;&#9;&#9;globe_section.png&#10;&#9;&#9;&#9;"/> (XML 
> out)
>
> So put your pic spec on one line:
> 	<graphic>globe_section.png</graphic>
>
> That's all I can see for now :-)
>
> Chris...
>
> -- 
> \ Chris Johnson                 \ NP:
>  \ cej at nightwolf.org.uk          \
>   \ http://cej.nightwolf.org.uk/  \
>    \ http://redclaw.org.uk/        
> ~---------------------------------------
>
>
> _______________________________________________
> SlugBug mailing list
> SlugBug at email-lists.org
> https://www.email-lists.org/mailman/listinfo/slugbug



More information about the SlugBug mailing list