Posts Tagged ‘artikel’

Performing loops in XSLT

If you read this blog from time to time, you might have noticed that I am often talking about the XML/XSLT combo. Some people really don’t like declarative programming languages, because it is well, declarative. It works for me though.

(http://en.wikipedia.org/wiki/Declarative_programming). (Dimitre Novatchev actually proved [PDF 400kb] that XSLT can be used as a functional programming language)

One of the problems with XSLT is looping. To create a loop, you have to be able to update the same variable over and over again until you reach the desired value for that variable.
But XSLt doesn’t do that. if you declare a variable it will hold the same value untill the end. this bit really puzzles alot of people, but wait there is a solution.

You can get around almost any problem because most of the XSLT processors available, allow you to extend your XSLT stylesheet with JSCript, C# or whatever compiler is available on your system. But it is a bit messy.

If you start using this kind of combination of JavaScript and XSLT, your code gets unreadable very soon. So that is the reason why Oliver Becker created this nice loop extension. He uses nothing but XSLT that can be used as any other XSLT Extension. Have a look at the code below how it’s done:

<loop:for name="i" from="10" to="1" step="-1">
 <loop:for name="j" from="1" to="10">
  <xsl:value-of select="$i * $j" />
   <xsl:text>&#x9;</xsl:text>
  </loop:for>
 <xsl:text>&#xA;</xsl:text>
</loop:for>

He implemented for loop AND while loops.

<loop:while test="expression">
 <!-- optional some <xsl:variable> elements -->
  <loop:do>
   <!-- template body -->
    </loop:do>
    <loop:last>
   <!-- template body -->
  </loop:last>
 <!-- at least one <loop:update> element -->
</loop:while>

And a “function” to just update a variable:

<loop:update name="qname" select="expression" />

Have a look at the other XSLT stylesheets he is offering for download on his homepage:

  • Merging XML documents
  • Tracing execution of a stylehseet
  • Quine: The Self-Reproducing Stylesheet

In search for Google

Yahoo and MSN made minor tweaks to their interface. One of them seems like a reaction to how people use search boxes.

If you search for the phrase “google.com” on one of these search engines, they will give you a second search box, similar to the one on top giving you a second try to use their search page.


What is going on here?

People buy package PCs and internet connection deals that involve changing the homepage to the preferred search engine of the dealer you bought it from. When people finally get the internet connection working, they start IE and type “google.com” in whatever box they can get their hands on. It has been known for a while that people use other search engines like that.

The strange thing though is that they did not notice the address bar and the similarity of the address in there and what they just typed.

Why not type “google.com” in the address bar?

I guess that people don’t know the difference between the browser interface and the webpage that is rendered by the browser.
The changes in the interface of these result pages, Yahoo and MSN, are most probable driven by real case studies, so you should be aware that:

  • changing browser interface elements like the scroll bar will obfuscate the difference between browser and webpage even more
  • people don’t know what an address bar is
  • people don’t know what a URL is used for
  • people know how a URL looks like
  • people know what a link is
  • people know what a textbox is and a button to search

The visitor on your site might be the same person that uses Yahoo as a bookmark to go to google.com.

Extending Umbraco with a library

I have been using the .net based Umbraco CMS for more then a year now and never have I had the feeling it limited me in anyway. But now I need a quick and dirty approach to connect to a database other then the Umbraco database.

Umbraco can grab XML feeds using the build in XSLT library extension, but I am just playing around at the moment and need direct access to manipulating query results.

So I created my own XSLT library. It has one 1 method at the moment: QueryDatabase(‘connection string’,'query’)

Just a note: it probably is not the greatest idea to use this in a production environment. What I plan to do afterwards, is to hard-code the query into another method not allowing any unknown request to the database.

But here is the code anyway (code pasted below), the dll and the VS 2003 project zip file.

If you want to use it without looking at the code just do the following actions:

  1. Download the astuanax xslt libarary dll
  2. Unzip the file and put it in the “/bin” folder of your Umbraco website
  3. Edit the file “xsltExtensions.xml” in the folder “/config” and
  4. Add the following line:
  5. Once you got this running, go to the XSLT editor in Umbraco and paste the following code into your xslt file:

    This will show you the XML code you can expect from this query.

Leave a comment if you like it. Or if you have a problem using it, let me know and I will try to fix it.

C# Code:

More Persona examples

Maybe you are interested in my Persona tool, a form for sales and marketing people to create personas
Last updated on 13th November 2007.

At the moment it seems more and more people are interested in using personas in the development process of writing software or creating websites. Here are 3 more examples and some really good introductions to personas

Examples

Articles

Business needs and personas

The Sigia discussion list hosted a nice discussion on business needs and personas. I use personas for discussing requirements and one of the things that came up was to use a special persona that every programmer/designer knows about: grump.
I am certainly going to add this one to the list of must-have personas.

What I do with personas is to make sure that one of them is a grump,
one is impatience, one is dysfuctional, another is low-vision and
angry, and so forth. The fastest way to design for Mr Jenkins, age 53,
and to align him with the business goals is to point to him and ask if
someone on our team ever had to deal with this grump! And sure enough,
they have, and lots of suggestions crop up to try to get him off our
back, in the best possible way. People seem to (again, my experience)
spot flaws in systems faster based on how dysfunctional grumpy
impatient people use them. I also find it easier to work with my peers
when the personas are loaded with emotions and flaws more than
stereotypes of behavioral patterns.

Alexander Johannesen

Quality control with style sheets

Once you are off with a CMS and people start to edit pages, all sorts of code grows inside the database. Copy-paste leftovers from MS Word and code handwritten by tech enthusiast clutter your clean and simple HTML template and after 2 weeks your design is no longer what it used to be.

Sounds familiar?

To avoid all these problems we can use a well-known CSS combo: dependency and specificity, to mark all these little coding errors with big borders in orange or red, depending on the severity. Editors really don’t like these boxes and will do whatever it takes to get them out.
To see how it works you need a human editor with HTML3 and <FONT> tag knowledge, a CMS that can detect if an editor is logged on (any CMS does that), and the stylesheet we are going to create.

Editors in charge

You or a designer crafted the headers very carefully, and they really look great in the new design. Pixel-perfect!
Unfortunately the editor in charge thinks that headers should be bigger and bolder. He looks at the design and goes into the CMS to make same basic changes, adding FONT, B and any other element he knows about. This is additional markup that can mess up your entire website and really shound’t be in there.

There is actually not much you can do about it if you stick to using a rich text editor (RTE) and don’t want to break down the document into distinct fields (and validate these fields). But… you can make people aware of these things. And I will show you can do this using a few lines of code and a stylesheet.

Let’s have a look at an example stylesheet:

/* stylesheet headers */
h1 {	}
h2{
	font-size: 1.05em /* not too big */
	font-weight: normal; /* instead of bold */ }
h3 {	}

What happens if the editor incorrectly adds a <FONT> tag, and a B element?


What happens here? If you are unlucky, the rest of the page is rendered with the wrong font-size and your headers appear bold.

To avoid all these things you can work your way through all the little errors and add them into the additional stylesheet like this:

/* stylesheet debug */
font, b, i{
	display: block; /* make it stand out on the page*/
	border:2px solid red; /* here is your problem !! */
	font-size: 8px; /* very small unreadable print*/
} 

h2 strong {
	font-weight: normal;
	display: block; /* make it stand out on the page*/
	border:2px solid orange; /* orange means: not nice, but is ok */
}  

Don’t want DIV elements inside the #content area, because they should use paragraph element?

#content div {
	display: block; /* make it stand out on the page*/
	border:2px solid red; /* here is your problem !! */
	font-size: 8px; /* very small unreadable print*/
}

These are simple examples but they show how the idea works. Once you know your template and what can happen when things go wrong, you can dig a little deeper and apply strict rules to where an element can and is allowed to appear.

For example, I have seen some editors use BLOCKQUOTE to indent paragraphs. This is a common mistake and will not be allowed, so I added this to the rules:

.productpage #content blockquote{ /* error markup in here */ } 

I am not allowing BLOCKQUOTE elements in the content block on a productpage. (note: You need to be able to distinguish different page types from each other).

When should you show these errors?

Obviously, we shouldn’t show these errors to the visitors. That is where the need to detect the login comes in. ALl you have to do is test if the person viewing the website is logged in as an author and based on that test, add the debug stylesheet or not.

This is the XSLT code I am using in Umbraco:

<?xml version="1.0"?>
	<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:msxml="urn:schemas-microsoft-com:xslt"
		xmlns:umbraco.library="urn:umbraco.library"
		exclude-result-prefixes="msxml umbraco.library">
	<xsl:output method="html"/> 

	<xsl:param name="currentPage"/> 

	<xsl:template match="/">
		<xsl:if test="umbraco.library:RequestCookies('UserContext') != ''">
			<link media="all" href="/css/debug.css" id="debug" rel="stylesheet" type="text/css"/>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>

This is an XSLT macro, using the default Umbraco library to detect the cookie with the authentication flag. If it is found and not empty, add the debug stylesheet in the HTML header of the page.

The next step is to determine if you are going show the errors in a life environment to make sure editors have to care about it, or that you will leave it out and only use it for your quality review.

I always show the big errors and surround them with a red border. Using font tags to override my CSS rules is unacceptable so these will be shown in the life environment.

All you have to do is split the severe errors from the others and put them in a separate sylesheet. Then hardcode the reference to the stylesheet into the template. That way the severe errors will always be shown and editors will have to check their pages in preview mode before actually publishing.

I am not sure if this technique is useful for other webmasters, but if you do plan to use, let me know.

I am currently using it on my Umbraco installation and in the beginning it cause a lot of support because the editors will call you. After a while they will know and they have learned to use standard based markup. After that support calls will go down again.

Information Architecture Summit 2006

Ik ben er even uit geweest, maar het is nu toch tijd om jullie aandacht te vestigen op de EuroIA summit in Berlijn. Het onderwerp van de conferentie is „Building our practice“ en de keynote wordt gegeven door Peter Morville, ons allen bekend van de het boek “ Information Architecture for the World Wide Web ”.
Als je het boek nog niet in huis hebt, Amazon is open 24 op 24, 7 dagen op 7.

Wat kan je verwachten?
Vorig jaar was even wennen omdat niemand wist of IA in een Europese context anders was dan elders. Die vraag werd duidelijk beantwoord met een ja en vandaag wordt er gefocust op de praktijk.

  • Wat doen Europese IA’s eigenlijk?
  • En is dat anders dan in de Us of in Azie?
  • Welke technieken gebruiken jullie?
  • Welke tools?

Of die vragen beantwoord worden hangt meer van jullie af. Er zullen verschillende panels georganiseerd worden waar jullie vragen kunnen stellen en discussie centraal staat.

Het is bijna te laat om nog een presentatie in te dienen, euh eigenlijk is het al te laat maar als je idee echt aanslaat heb je misschien nog een kans.
Er is vraag naar:

  • Case Studies – specific examples showing the use of IA in completed projects
  • Presentations – talks that discuss principles and ideas, or provide insightful analogies and though-provoking explorations to open the minds of information architects
  • Panels – differing opinions and discussion on the topics of the day lead by a moderator
  • Posters – illustrating a concept from research or practice

Break

I stopped posting for a while now, but you can expect me to be back next month. I am out for the long weekend and I am visitng Denmark. After that, you will see some new things appear.

Categories

About

My name is Len Dierickx and this is my personal blog. I studied Musicology at the UG, long time ago but got more and more into webdevelopment. I started this blog because the EuroIA summit in Brussels (Belgium, Oct 2005), was such an inspiration. And I was thinking about a blog on IA a while now, so that was the extra kick I needed to get it actually done.

Powered by WordPress