News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[Beta] XSLT stylesheets for Modification XML files - Make them look pretty

Started by Daniel15, April 27, 2007, 05:30:01 AM

Previous topic - Next topic

Daniel15

Hi everyone,
I'm looking for people to beta-test some XSLT stylesheets I'm working on. Basically, an XSLT stylesheet formats a XML file so it looks pretty when viewed in a web browser (or other application). Usually, opening your package-info.xml file or install.xml file with a web browser will display something like this (depending on your browser... This is with Opera 9 and a XML Tree User JavaScript):


With my XSLT stylesheets applied to the XML files, they're a lot prettier:


This makes debugging modification-related problems, and installing mods manually a lot easier.

An example
To view an example of these stylesheets in use, take a look at these two example files (both from SMFShop 3.0):
http://dev.dansoftaustralia.net/svn/modparser/trunk/xslt/package-info.xml
http://dev.dansoftaustralia.net/svn/modparser/trunk/xslt/install_SMF1-1.xml

How to use?
To use the stylesheets with your modifications, first download these two files:
http://dev.dansoftaustralia.net/svn/modparser/trunk/xslt/package-info.xsl
http://dev.dansoftaustralia.net/svn/modparser/trunk/xslt/modification.xsl
And place them in your mod's directory (same directory as package-info.xml file). Then, in package-info.xml, find:
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
Add before:
<?xml-stylesheet href="package-info.xsl" type="text/xsl"?>

In any modification XML files you have, find:
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
Add before:
<?xml-stylesheet href="modification.xsl" type="text/xsl"?>

If you use these stylesheets yourself, it is suggested to bundle these two files with your modifications (ZIP or TAR.GZ), so that your users also see the formatting when they view the XML files.

Please tell me if this works with your mods :D.

Changelog
27th April 2007 - Initial beta release
6th May 2007 - Added dropdown box with SMF version listing for install/uninstall (rather than just displaying all install and uninstall sections)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Dannii

Is it namespace aware? That's the problem I had when I was working on this.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Daniel15

Quote from: eldʌkaː on April 27, 2007, 08:13:57 AM
Is it namespace aware? That's the problem I had when I was working on this.
Well, I was originally having problems with namespaces (XSLT stylesheets didn't work unless I commented out the DOCTYPE and xmlns in the XML files), but I sorted that all out :)

Could you please look through mine, and tell me if anything can be improved? I'm still a newbie at XSLT :P
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Dannii

The problem I had was making it work if someone hadn't included a namespace. Looks to me like yours wouldn't work if they left it out.
I've never did much with it, but it looks good to me. Noticed you have no upgrade section?
They should be uploaded to http://www.simplemachines.org/xml/ so we can use them with mods ;)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Oldiesmann

Is it possible for you to replace the variables with the path from the SMF directory (eg replace $sourcedir with Sources, $themedir with Themes/default, etc.)? It's been a while since I've done anything with XSLT, so it may not be possible, but if it is it would certainly make things more useful in my opinion.

I'll be using these for my SMF+G2 integration - should come in handy.
Michael Eshom
Christian Metal Fans

Daniel15

QuoteThe problem I had was making it work if someone hadn't included a namespace. Looks to me like yours wouldn't work if they left it out.
Well, technically, they always need to include the namespace (it's always a good idea).
In modification XML files, the <modification> tag should always look like:
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
(although I've never seen the "smf" namespace used...).

Note that just using "xmlns" names the SMF modification namespace the default namespace. If you wanted to, you could change that to:
<modification xmlns:mod="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
And use <mod:file>, <mod:operation>, etc. I don't think this would work with the package manager, as it's not a proper XML parser (it just uses a regular expression to imitate a XML parser :P. "Real" XML parsers check whether the XML file is well-formed, and validate it against the DOCTYPE or schema.).

QuoteI've never did much with it, but it looks good to me. Noticed you have no upgrade section?
Oops, I must have forgot that :P. A lot of it was copied from my Package Parser, which currently does not parse upgrade sections. I'll try to add it soon :).

QuoteIs it possible for you to replace the variables with the path from the SMF directory (eg replace $sourcedir with Sources, $themedir with Themes/default, etc.)?
I think that's possible, but the code I'd use would be very ugly... I'll try to look for a better way of doing it :)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Oldiesmann

Any idea how long it'll be before you have the "upgrade" section complete?
Michael Eshom
Christian Metal Fans

Daniel15

Quote from: Oldiesmann on May 05, 2007, 03:01:07 PM
Any idea how long it'll be before you have the "upgrade" section complete?
I added some initial support for upgrade sections today, however, it's not yet complete (well, it works, it's just very messy).
I still need to clean up a bit (eg. add JavaScript dropdowns to select a SMF version rather than just displaying all of them).
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Daniel15

OK, more updates today :). It took me ages to figure out why my updated JavaScript wasn't working in Firefox, but it turns out that mootools has a stupid bug in it (related to getElements()). The upgrades section seems to have stopped working in Opera (I'm not sure why this is - It works fine in Firefox).

Please test this out - These stylesheets are close to release stage now :D
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Advertisement: