Polite notice

Just to let you know that this web site uses CSS to enhance the look and user experience, it looks like your web browser can not understand CSS or you have turned it off.

The effect is that things may not look as intended. Thanks for viewing though!


Archive for March 15th, 2005

xsl, css for xml!

Had a look into styling xml documents today

The first issue was with Firefox, in was confused about what apache was sending it. Once I had sorted out that Firefox wanting the xsl sent to it with a mime header of application/xml then I was away.

My first experiment was simply just seeing if I could apply some sort of style. I got this working by linking in a xsl file with turned the xml displayed into a table layout.

Next came the styling of individual parts of the table, I wanted specific rows to have different back ground colours. So I learnt that xsl has an if statement by reading http://builder.com.com/5102-6371-5085807.html. Quite simply it:

<xsl :if test=Boolean-expression>
< !—- peform an action
</xsl:if>

But that doesn’t provide the else part I read further and found:

<xsl :choose>
<xsl :when test=condition>
< !—do something
</xsl:when>
<xsl :otherwise>
< !—do something
</xsl:otherwise>
</xsl:choose>

Just what I wanted, a bit of guess work led me to having multipule xsl:when which then provied me with if:if-else:else.

The now formatted xml file can be seen at staff.xml and the xsl file at staff.xsl. To see what the they really look like then you will need to view the source as your browser will format them.

Tuxx.org.uk is proudly powered by WordPress, Gallery, Debian & Zen