<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blockquote &#187; XSLT</title>
	<atom:link href="http://blockquote.be/facet/xslt/feed/" rel="self" type="application/rss+xml" />
	<link>http://blockquote.be</link>
	<description>a blog for webmasters practicing Information Architecture</description>
	<lastBuildDate>Sat, 06 Feb 2010 15:16:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XSLT library for Umbraco: update</title>
		<link>http://blockquote.be/2008/04/07/updated-my-xslt-library-for-umbraco/</link>
		<comments>http://blockquote.be/2008/04/07/updated-my-xslt-library-for-umbraco/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 20:15:49 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[XSLT]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[xslt library]]></category>

		<guid isPermaLink="false">http://blockquote.be/2008/04/07/updated-my-xslt-library-for-umbraco/</guid>
		<description><![CDATA[Some 2 years ago I published an xslt library extension for Umbraco. I added several methods to the class that proved to be useful for me, maybe they are useful for you too.
The code is provided as is, no garanty, blabla &#8230; though should not harm anyone.
You can download the dll and adjust your xslt [...]]]></description>
			<content:encoded><![CDATA[<p>Some 2 years ago I published an <a href="http://blockquote.be/2006/08/09/extending-umbraco-with-a-library/">xslt library extension</a> for <a href="http://umbraco.org">Umbraco</a>. I added several methods to the class that proved to be useful for me, maybe they are useful for you too.</p>
<p>The code is provided as is, no garanty, blabla &#8230; though should not harm anyone.</p>
<p>You can <a href="/examples/astuanax.dll.public.zip">download the dll</a> and adjust your xslt configuration settings in Umbraco or <a href="/examples/astuanax-public.zip">download the full VS2008 project [1.5 MB]</a> and have a look at the code.<br />
Just for the reference, below is a list of methods available in the class with a short description</p>
<dl style="font-size:0.8em; border: 1px solid #ccd0d6; background: #ebedef; padding: 1em;">
<dt style="font-weight:bold">XPathNodeIterator QueryDatabase(string conn, string query ) </dt>
<dd>Query the umbraco database or any other database that you need.</dd>
<dt style="font-weight:bold">string createMemberGroup(string memberGroupName) </dt>
<dd>Create a member group</dd>
<dt style="font-weight:bold">string isMemberOfGroup(string memberGroupName, string memberId) </dt>
<dd>Check if the member supplied belongs to the group supplied</dd>
<dt style="font-weight:bold"><del datetime="2008-04-09T08:40:43+00:00">XPathNodeIterator GetAccessingGroups(int documentId)</del></dt>
<dd>Not working, will be removed &#8230;</dd>
<dt style="font-weight:bold">XPathNodeIterator getAllMembersFromGroup(string groupId)</dt>
<dd>REturn all the members that are in a group</dd>
<dt style="font-weight:bold">string getMemberGroups()</dt>
<dd>Returns the list of groups the current memner belongs to</dd>
<dt style="font-weight:bold">XPathNodeIterator getAccesXml()</dt>
<dd>Returns the full xml document that contains the list of protected pags and groups.</dd>
<dt style="font-weight:bold">string getMemberFromFirstLetter(char letter)</dt>
<dd>Well, get member from the first letter</dd>
<dt style="font-weight:bold">XPathNodeIterator getMemberFromFirstLetterXml(char letter) </dt>
<dd>Well, same, but then in xml.</dd>
<dt style="font-weight:bold">string addMemberToGroup(string memberGroupName, int memberId)</dt>
<dd>Add a given member to a give group</dd>
<dt style="font-weight:bold">string addPageToGroup(int currentPage, int groupId, int loginPage, int errorPage )</dt>
<dd>Protect a page with a membergroup</dd>
<dt style="font-weight:bold">bool updateProperty(int DocumentId, string propName, string propValue)</dt>
<dd>Update any property (not the umbraco properties) for any given document.</dd>
</dl>
<h2>Download</h2>
<ul>
<li><a href="/examples/astuanax.dll.public.zip">only the dll</a></li>
<li><a href="/examples/astuanax-public.zip">the full xslt extension VS2008 project [1.5 MB]</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2008/04/07/updated-my-xslt-library-for-umbraco/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XSLT and PHP on a Mac, Part 2</title>
		<link>http://blockquote.be/2007/12/11/xslt-and-php-on-a-mac-part-2/</link>
		<comments>http://blockquote.be/2007/12/11/xslt-and-php-on-a-mac-part-2/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 22:51:59 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://blockquote.be/2007/12/11/xslt-and-php-on-a-mac-part-2/</guid>
		<description><![CDATA[Now that I installed MySQL, got the apache server running and Wordpress installed, I am facing another problem.
The version of PHP included in Mac OS X seems to be an old one (that&#8217;s fine) without XSL transformations support (not ok) as it is not compiled into the module.
The one programming language I continuously use during [...]]]></description>
			<content:encoded><![CDATA[<p>Now that <a href="http://blockquote.be/2007/11/26/php-development-on-a-mac-part-1/">I installed MySQL, got the apache server running and Wordpress installed</a>, I am facing another problem.</p>
<p>The version of PHP included in Mac OS X seems to be an old one (that&#8217;s fine) without XSL transformations support (not ok) as it is not compiled into the module.</p>
<p>The one programming language I continuously use during the day is XSLT combined with a lot of XML documents and webservices. I need XSL, really, and I cannot live without XSL support, no way.</p>
<p>I could download the source code, find all the libraries, find the commands to compile and fix everything manually. But it is just easier to download the <a href="http://www.entropy.ch/software/macosx/php/" title="Marc Liyanage - Software - Mac OS X Packages - PHP">PHP package from Marc Liyanaga</a>.</p>
<p>First you should disable the PHP4 module in the Apache config file, because if you install on top of that it will give you some strange errors. It will not remove the Apple module, but Apache will try to load both modules and that is something to avoid.</p>
<p><a href="http://www2.entropy.ch/download/entropy-php-5.2.4-1.tar.gz" title="">Download the package [PHP 5.2.4 for Apache 1.3]</a>, install and try the <a href="http://www.php.net/phpinfo">phpinfo file you created before</a>, and you will see that you have a running version of PHP5.<br />
I checked the configuration and it seems to have XSL support.</p>
<p>None of the code I wrote before ran without problems, everything resulted in a fatal error. After some time I figured out that the <a href="http://be.php.net/xsl" title="PHP: XSL - Manual">XSL module has changed extensively</a><br />
As a result of that none of the code I wrote before will work, ever again.</p>
<p>At the moment I have PHP4 without XLST support installed, and a PHP5 version with XSLT support.</p>
<p>I tried Fink with the <a href="http://finkcommander.sourceforge.net/">Finkcommander</a> but they only have PHP modules for Apache 2, so no luck with that either.</p>
<p>This might not be a big problem for you, but I want to make sure the plugin I am writing, works on as many platforms as possible. and that includes PHP4.<br />
  I could not find any statistics on how many hosts have switched to PHP4, I think not they are many.</p>
<p>The PHP website mentions that PHP4 will no longer be supported from January 2008, so I guess I am going to develop for PHP5 and hope for the better.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6977975878818061";
//300x250, created 11/9/07
google_ad_slot = "0010215045";
google_ad_width = 300;
google_ad_height = 250;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2007/12/11/xslt-and-php-on-a-mac-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Performing loops in XSLT</title>
		<link>http://blockquote.be/2006/08/14/performing-loops-in-xslt/</link>
		<comments>http://blockquote.be/2006/08/14/performing-loops-in-xslt/#comments</comments>
		<pubDate>Mon, 14 Aug 2006 04:00:58 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[XSLT]]></category>
		<category><![CDATA[artikel]]></category>

		<guid isPermaLink="false">http://blockquote.be/?p=278</guid>
		<description><![CDATA[


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&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-6977975878818061";
//336x280, created 11/6/07
google_ad_slot = "0152792327";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>If you read this blog from time to time, you might have noticed that I am <a href="http://blockquote.be/2005/03/01/xml-into-php-array-using-xslt/">often talking</a> about the <a href="http://blockquote.be/2004/05/04/xml-documenten-opbouwen-element-versus-attribuut/">XML/XSLT combo</a>. Some people really don&#8217;t like declarative programming languages, because it is well, declarative. It works for me though.</p>
<p>(http://en.wikipedia.org/wiki/Declarative_programming). (Dimitre Novatchev actually <a href="http://www.topxml.com/xsl/articles/fp/fp.zip">proved [PDF 400kb]</a> that <a href="http://fxsl.sourceforge.net/">XSLT can be used as a functional programming language</a>) </p>
<p>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.<br />
But XSLt doesn&#8217;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.</p>
<p>You can get around almost any problem because most of the XSLT processors available, allow you to extend your <a href="http://msdn.microsoft.com/msdnmag/issues/02/03/xml/" class="broken_link" >XSLT stylesheet with JSCript, C# or whatever compiler is available on your system</a>. But it is a bit messy. </p>
<p>If you start using this kind of combination of JavaScript and XSLT, your code gets unreadable very soon. So that is the reason why <a href="http://www2.informatik.hu-berlin.de/~obecker/">Oliver Becker</a> created this nice <a href="http://www2.informatik.hu-berlin.de/~obecker/XSLT/loop-compiler/">loop extension</a>. He uses nothing but XSLT that can be used as any other XSLT Extension. Have a look at the code below how it&#8217;s done: </p>
<pre>&lt;loop:for name=&quot;i&quot; from=&quot;10&quot; to=&quot;1&quot; step=&quot;-1&quot;&gt;
 &lt;loop:for name=&quot;j&quot; from=&quot;1&quot; to=&quot;10&quot;&gt;
  &lt;xsl:value-of select=&quot;$i * $j&quot; /&gt;
   &lt;xsl:text&gt;&amp;#x9;&lt;/xsl:text&gt;
  &lt;/loop:for&gt;
 &lt;xsl:text&gt;&amp;#xA;&lt;/xsl:text&gt;
&lt;/loop:for&gt;</pre>
<p>He implemented for loop AND while loops.</p>
<pre>&lt;loop:while test=&quot;expression&quot;&gt;
 &lt;!-- optional some &lt;xsl:variable&gt; elements --&gt;
  &lt;loop:do&gt;
   &lt;!-- template body --&gt;
    &lt;/loop:do&gt;
    &lt;loop:last&gt;
   &lt;!-- template body --&gt;
  &lt;/loop:last&gt;
 &lt;!-- at least one &lt;loop:update&gt; element --&gt;
&lt;/loop:while&gt;</pre>
<p>And a &#8220;function&#8221; to just update a variable:</p>
<pre>&lt;loop:update name=&quot;qname&quot; select=&quot;expression&quot; /&gt;</pre>
<p>Have a look at the other <a href="http://www2.informatik.hu-berlin.de/~obecker/XSLT/#loop-compiler">XSLT stylesheets he is offering for download on his homepage</a>:</p>
<ul>
<li>Merging XML documents</li>
<li>Tracing execution of a stylehseet</li>
<li>Quine: The Self-Reproducing Stylesheet</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2006/08/14/performing-loops-in-xslt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending Umbraco with a library</title>
		<link>http://blockquote.be/2006/08/09/extending-umbraco-with-a-library/</link>
		<comments>http://blockquote.be/2006/08/09/extending-umbraco-with-a-library/#comments</comments>
		<pubDate>Wed, 09 Aug 2006 08:34:00 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[XSLT]]></category>
		<category><![CDATA[artikel]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[Umbraco]]></category>

		<guid isPermaLink="false">http://blockquote.be/?p=275</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using the <a href="http://umbraco.org">.net based Umbraco CMS</a> 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. </p>
<p>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. </p>
<p>So I created my own XSLT library. It has one 1 method at the moment: QueryDatabase(&#8216;connection string&#8217;,'query&#8217;)</p>
<p>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.</p>
<p>But here is the <a href="http://blockquote.be/examples/umbraco-xslt-lib-astuanax.txt">code anyway</a> (code pasted below), the <a href="http://blockquote.be/examples/dll-astuanax.zip">dll</a> and the <a href="http://blockquote.be/examples/astuanax.zip">VS 2003 project zip file</a>.</p>
<p>If you want to use it without looking at the code just do the following actions:</p>
<ol>
<li> Download the <a href="http://blockquote.be/examples/dll-astuanax.zip">astuanax xslt libarary dll</a> </li>
<li> Unzip the file and put it in the &#8220;/bin&#8221; folder of your Umbraco website </li>
<li> Edit the file &#8220;xsltExtensions.xml&#8221; in  the folder &#8220;/config&#8221; and</li>
<li>Add the following line: <br />
<textarea rows="5" cols="15">&lt;ext assembly=&#8221;/bin/astuanax&#8221; type=&#8221;astuanax.Library&#8221; alias=&#8221;astuanax&#8221; /&gt;<br />
</textarea>
</li>
<li>Once you got this running, go to the XSLT editor in Umbraco and paste the following code into your xslt file:<br />
<textarea rows="5" cols="15">&lt;textarea&gt;<br />
&lt;xsl:copy-of select=&quot;astuanax:QueryDatabase(&#8216;Server=127.0.0.1;Database=Northwind;User ID=****;Password=*****;Trusted_Connection=False&#8217;, &#8216;SELECT LastName FROM Employees&#8217;)&quot;/&gt;<br />
&lt;/textarea&gt;<br />
</textarea></p>
<p>This will show you the XML code you can expect from this query.
</li>
</ol>
<p>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. </p>
<p><!--adsense--></p>
<p><strong>C# Code:</strong></p>
<p><textarea rows="15" cols="15">using System;<br />
using System.Xml;<br />
using System.Xml.Schema;<br />
using System.Xml.Xsl;<br />
using System.Xml.XPath;<br />
using System.Data;<br />
using System.Data.SqlClient;<br />
using System.IO;<br />
using System.Collections;<br />
using System.Globalization;<br />
using System.Net;<br />
using System.Text.RegularExpressions;</p>
<p>namespace astuanax<br />
  {<br />
   /// &lt;summary&gt;<br />
   /// &lt;/summary&gt;<br />
   public class Library<br />
   {<br />
    private static string _ErrorMessage = &quot;&quot;; </p>
<p>    /*<br />
     * This method is enabling debug information to be passed along<br />
     * doing them umbraco situps..<br />
     */ </p>
<p> public static string ErrorMessage()<br />
  {<br />
   return _ErrorMessage;<br />
  }</p>
<p>  /// &lt;summary&gt;<br />
  /// Query a database other then the Umbraco database<br />
  /// &lt;/summary&gt;<br />
  /// &lt;param name=&quot;connection string&quot;&gt;server &#8211; database &#8211; username &#8211; password &lt;/param&gt;<br />
  /// &lt;param name=&quot;sql&quot;&gt; sql query&lt;/param&gt;<br />
  /// &lt;returns&gt; XML dataset &lt;/returns&gt;</p>
<p>  public static XPathNodeIterator QueryDatabase(string conn, string query )<br />
  {<br />
   try<br />
   {<br />
    SqlConnection thisConnection = new SqlConnection(conn);<br />
    // Server=localhost;Database=Northwind;User ID=****;Password=****;Trusted_Connection=False<br />
    thisConnection.Open();<br />
    SqlCommand thisCommand = thisConnection.CreateCommand();<br />
    thisCommand.CommandText = query;<br />
    SqlDataAdapter adapter = new SqlDataAdapter(thisCommand);</p>
<p>    DataSet ds = new DataSet();<br />
    adapter.Fill(ds);<br />
    thisConnection.Close();</p>
<p>    XmlDocument xdoc = new XmlDocument();<br />
    xdoc.LoadXml(ds.GetXml());<br />
    XPathNavigator xp = xdoc.CreateNavigator();<br />
    return xp.Select(&quot;.&quot;);<br />
  }<br />
   catch (SqlException e)<br />
    {<br />
     _ErrorMessage = e.Message;<br />
     return null;<br />
    }<br />
  }<br />
 }<br />
}<br />
</textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2006/08/09/extending-umbraco-with-a-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quality control with style sheets</title>
		<link>http://blockquote.be/2006/07/17/quality-control-with-style-sheets/</link>
		<comments>http://blockquote.be/2006/07/17/quality-control-with-style-sheets/#comments</comments>
		<pubDate>Mon, 17 Jul 2006 18:00:17 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[XSLT]]></category>
		<category><![CDATA[artikel]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[qa]]></category>
		<category><![CDATA[quality control]]></category>

		<guid isPermaLink="false">http://blockquote.be/?p=265</guid>
		<description><![CDATA[
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 [...]]]></description>
			<content:encoded><![CDATA[<p><!--adsense--></p>
<p>Once you are off with a <abbr title="Content Management System" lang="en"><span title="Content Management System" lang="en">CMS</span></abbr> and people start to edit pages, all sorts of code grows inside the database. Copy-paste leftovers from <abbr title="Microsoft" lang="en"><span title="Microsoft" lang="en">MS</span></abbr> Word and code handwritten by tech enthusiast clutter your clean and simple <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> template and after 2 weeks your design is no longer what it used to be. </p>
<p><strong>Sounds familiar?</strong></p>
<p>To avoid all these problems we can use a well-known <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr> 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&#8217;t like these boxes and will do whatever it takes to get them out. <br />
To see how it works you need a human editor with HTML3 and &lt;FONT&gt; tag knowledge, a <abbr title="Content Management System" lang="en"><span title="Content Management System" lang="en">CMS</span></abbr> that can detect if an editor is logged on (any <abbr title="Content Management System" lang="en"><span title="Content Management System" lang="en">CMS</span></abbr> does that), and the stylesheet we are going to create. </p>
<h2> Editors in charge </h2>
<p>You or a designer crafted the headers very carefully, and they really look great in the new design. Pixel-perfect! <br />
  Unfortunately the editor in charge thinks that headers should be bigger and bolder. He looks at the design and goes into the <abbr title="Content Management System" lang="en"><span title="Content Management System" lang="en">CMS</span></abbr> 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&#8217;t be in there. </p>
<p>There is actually not much you can do about it if you stick to using a rich text editor (<abbr title="rich text editor" lang="en"><span title="rich text editor" lang="en">RTE</span></abbr>) and don&#8217;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. </p>
<p>Let&#8217;s have a look at an example stylesheet: </p>
<pre><code>/* stylesheet headers */
h1 {	}
h2{
	font-size: 1.05em /* not too big */
	font-weight: normal; /* instead of bold */ }
h3 {	}
</code></pre>
<p>What happens if the editor incorrectly adds a &lt;FONT&gt; tag, and a B element? </p>
<p>
    <br />
  What happens here? If you are unlucky, the rest of the page is rendered with the wrong font-size and your headers appear bold. </p>
<p>To avoid all these things you can work your way through all the little errors and add them into the additional stylesheet like this: </p>
<pre><code>/* 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 */
}  </code></pre>
<p>Don&#8217;t want DIV elements inside the #content area, because they should use paragraph element? </p>
<pre><code>#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*/
}</code></pre>
<p>
  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. </p>
<p>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: </p>
<pre><code>.productpage #content blockquote{ /* error markup in here */ } </code></pre>
<p>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). </p>
<h2>When should you show these errors? </h2>
<p>Obviously, we shouldn&#8217;t show these errors to the visitors. That is where the need to detect the login comes in. <abbr title="American League" lang="en"><span title="American League" lang="en">AL</span></abbr>l 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. </p>
<p>This is the <abbr title="Extensible Stylesheet Language Transformations" lang="en"><span title="Extensible Stylesheet Language Transformations" lang="en">XSLT</span></abbr> code I am using in Umbraco: </p>
<pre><code>&lt;?xml version="1.0"?&gt;
	&lt;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"&gt;
	&lt;xsl:output method="html"/&gt; 

	&lt;xsl:param name="currentPage"/&gt; 

	&lt;xsl:template match="/"&gt;
		&lt;xsl:if test="umbraco.library:RequestCookies('UserContext') != ''"&gt;
			&lt;link media="all" href="/css/debug.css" id="debug" rel="stylesheet" type="text/css"/&gt;
		&lt;/xsl:if&gt;
	&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</code></pre>
<p>This is an <abbr title="Extensible Stylesheet Language Transformations" lang="en"><span title="Extensible Stylesheet Language Transformations" lang="en">XSLT</span></abbr> 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 <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> header of the page. </p>
<p>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. </p>
<p>I always show the big errors and surround them with a red border. Using font tags to override my <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr> rules is unacceptable so these will be shown in the life environment. </p>
<p>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. </p>
<p>I am not sure if this technique is useful for other webmasters, but if you do plan to use, let me know. </p>
<p>I am currently using it on my <a href="http://www.umbraco.org">Umbraco</a> 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. </p>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2006/07/17/quality-control-with-style-sheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webpatterns: HTML &amp; CSS working together</title>
		<link>http://blockquote.be/2005/12/09/webpatterns-html-css-working-together/</link>
		<comments>http://blockquote.be/2005/12/09/webpatterns-html-css-working-together/#comments</comments>
		<pubDate>Thu, 08 Dec 2005 22:18:06 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[XSLT]]></category>
		<category><![CDATA[artikel]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://blockquote.be/?p=100</guid>
		<description><![CDATA[John Allssop wrote an article about using webpatterns in HTML and he wondered if we could gather these patterns and put them on a website. He started a blog and a wiki on webpatterns.org to document webpatterns. It is not active yet but I really think you should keep an eye on it. He is [...]]]></description>
			<content:encoded><![CDATA[<p>John Allssop wrote <a href="http://westciv.typepad.com/dog_or_higher/2005/11/webpatterns_and.html">an article about using webpatterns in HTML</a> and he wondered if we could gather these <tag>patterns</tag> and put them on a website. He started a <a href="http://www.webpatterns.org">blog and a wiki on webpatterns.org</a> to document <tag>webpatterns</tag>. It is not active yet but I really think you should keep an eye on it. He is going to start a quizz similar to the <a href="http://www.simplebits.com/bits/simplequiz/">“SimpleQuizz from Dan Cederholm”</a>.</p>
<p>In the article, John talks about the use of classes and id’s but I doubt we can restrict webpatterns to <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> only. Most of the webpatterns that exist on the web today come from problems when using <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> together with <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr>. And from that perspective, the relation between <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> and <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr> is similar to the relation between  <abbr title="Extensible Markup Language" lang="en"><span title="Extensible Markup Language" lang="en">XML</span></abbr> and XSLT.</p>
<p>I previously wrote an article about the <tag>XML</tag>/<tag>XSLT </tag>combo. When to <a href="http://blockquote.be/2004/05/04/xml-documenten-opbouwen-element-versus-attribuut/">choose between pointing to an element or including an element</a>. This relates to the use of attributes or elements. When to point or include depends on what you want to achieve with the XSLT transformation.</p>
<p>In many cases you can improve your XML if you think about the <abbr title="Extensible Stylesheet Language Transformations" lang="en"><span title="Extensible Stylesheet Language Transformations" lang="en">XSLT</span></abbr> transformation that will happen later on. This same thinking can improve your <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> and <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr> code.</p>
<p>Pointing in <abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> and <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr> is the same as using an id or class attribute and use an id selector for a rule in your style sheet.</p>
<p><strong><abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr><br />
</strong></p>
<pre><code>#navBar{ declaration in here}
# content { declaration in here}

&lt;div id="navBar&#038;gt";&lt;/div&gt;
&lt;div id="content"&gt;&lt;/div&gt;</code></pre>
<p><strong>XML/XSLT</strong></p>
<pre><code>&lt;xsl:value-of select="element[@id=" navBar"]"/&gt;
&lt;xsl:value-of select="element[@id=" content"]"/&gt;

&lt;element id="navBar"/&gt;
&lt; element id="content"/&gt;</code></pre>
<p>In this case you can use an id to point to the element in question.</p>
<p>Now if you have nested elements and you include the element you want to transform or style, you get something like this.</p>
<p><strong><abbr title="HyperText Markup Language" lang="en"><span title="HyperText Markup Language" lang="en">HTML</span></abbr> <abbr title="Cascading Style Sheets" lang="en"><span title="Cascading Style Sheets" lang="en">CSS</span></abbr></strong></p>
<pre><code>div#contact ul li, div li {declaration in here}
</code></pre>
<p><strong>XML/XSLT</strong></p>
<pre><code>&lt;div class=”contact”&gt; &lt;ul&gt; &lt;li&gt; … 

&lt;contact&gt;&lt;person&gt;&lt;lastName&gt; …. &lt;xsl:value-of select=”contact/person/lastName”/&gt;
or
&lt;xsl:Value-of select=”contact//lastName”/&gt;</code></pre>
<p>We can call the first example <strong>redundant</strong> because using an id and pointing to each element will result in a large stylesheet with lots of repetition.</p>
<p>The second example is using <strong>dependency</strong> because your are depending on relationships between elements.</p>
<p>The article <a href="http://www.mezzoblue.com/archives/2005/01/20/redundancy_v concept" class="broken_link" >“Dependency versus redundancy”</a>on <a href="http://www.mezzoblue.com">mezzoblue</a> clearly documents the difference between the 2 patterns. Both directions, coding for redundancy or dependency, have their own advantages and in many cases your are going to use both.</p>
<p>To come back to the pattern subject, the pattern would tell you when to choose for <tag>redundany </tag>or <tag>dependency</tag>. When to use an id or notand rely on child parent relations. </p>
<p>And I think it is clear that this relates to both <tag>CSS </tag>and <tag>HTML</tag>.</p>
<p>To close this post, I am really expecting to see big things happening on the <a href="http://webpattern.org">webpattern.org</a> website but only if we provide feedback and tell John if this or that pattern actually works.</p>
<p>So go and have a look and subscribe to his <a href="http://westciv.typepad.com/dog_or_higher/atom.xml%5C%22" class="broken_link" >feed</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2005/12/09/webpatterns-html-css-working-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML into PHP array using XSLT</title>
		<link>http://blockquote.be/2005/03/01/xml-into-php-array-using-xslt/</link>
		<comments>http://blockquote.be/2005/03/01/xml-into-php-array-using-xslt/#comments</comments>
		<pubDate>Tue, 01 Mar 2005 21:03:44 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[XSLT]]></category>
		<category><![CDATA[artikel]]></category>

		<guid isPermaLink="false">http://blockquote.be/2005/03/01/xml-into-php-array-using-xslt/</guid>
		<description><![CDATA[Don&#8217;t want to read everything? Jump to the code or leave a comment

9 months ago I wrote a few lines PHP-code to get XML data into an array. The reason why I wrote this is hard to recall but in the process I had to solve a problem: how do I get a serie of [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t want to read everything? <a href="#sourceCode">Jump to the code</a> or <a href="#respond">leave a comment</a></p>
<p><!--adsense--></p>
<p>9 months ago I wrote a few lines PHP-code to get XML data into an array. The reason why I wrote this is hard to recall but in the process I had to solve a problem: how do I get a serie of values from an XML file into a PHP array?</p>
<p>Lots of solutions exist like the package <a href="http://pear.php.net/package/XML_Serializer" title="Swiss-army knive for reading and writing XML files. Creates XML files from data structures and vice versa.">PEAR::XML_Serializer</a> but they were all too advanced for what I needed.<br />
All I needed was a simple function or class that would do just that: convert xml file with values to php array. And I found a simple trick using nothing more than XSLT.</p>
<p>
If you look at an array in PHP, the data inside is a <q>storable presentation of a value</q>. To get the value back into a string you have to call the <a href="http://be.php.net/manual/en/function.serialize.php"><code>serialize()</code></a> function. Getting the array back from the string, you guessed it, call the <code>unserialize()</code> function. I&#8217;m not getting any deeper into this, the manual entries are very clear and the array section of the PHP manual is very good.</p>
<p>
Once you know how a serialized array looks like, you can generate it with whatever you have. You can generate it through an XSLT transformation, like I did. </p>
<p><span id="more-72"></span></p>
<p>Look at this PHP array:</p>
<pre>
$arr = array(
	"path" => " /var/www/admin/",
	"url"=> "http://www.domain.be/",
	"webmaster" => "someEmail@address.be",
	"lang" => "en-uk"
);
echo serialize($arr);
</pre>
<p>This produces the following result:</p>
<pre>a:4:{
	s:4:"path";
	s:21:" /var/www/admin/";
	s:3:"url";
	s:19:"http://www.domain.be/";
	s:9:"webmaster";
	s:17:"someEmail@address.be";
	s:4:"lang";
	s:5:"en-uk";
	}</pre>
<p>First it tells you how many key-value pairs are stored: 4 in this case.<br />
It iterates through all the members and counts the number of characters for each key and each value, finally adding the actual value. </p>
<p>The original XML I wanted to convert was a config file with a few entries. The file looks like this:</p>
<pre>
&lt; ?xml version=&quot;1.0&quot;?&gt;
&lt;configuration&gt;
&lt;entry name=&quot;path&quot;_
value=&quot;/var/www/admin/&quot;/&gt;
&lt;entry name=&quot;url&quot;_
value=&quot;http://www.domain.be/&quot;/&gt;
&lt;entry name=&quot;webmaster_
value=&quot;someEmail@address.be&quot;/&gt;
&lt;entry name=&quot;lang&quot; value=&quot;EN&quot;/&gt;
&lt;/configuration&gt;
</pre>
<p>A simple configuration file for an online application.<br />
Using XSLT, you can easily transform this XMl tree into a string that matches the serialized string I mentioned above.
</p>
<p>The XSLT file looks like this:</p>
<pre>
&lt; ?xml version=&quot;1.0&quot;?&gt;
&lt;xsl :stylesheet version=&quot;1.0&quot;
xmlns:xsl=&quot;http://www.w3.org/_
1999/XSL/Transform&quot;&gt;
&lt;xsl :output method=&quot;text&quot;/&gt;
&lt;/xsl&gt;
</pre>
<p>Set the output method to text so you are sure that you get a literal result and not valid XML.</p>
<pre>
<xsl :strip-space elements="*"/>
</pre>
<p>Strip white-space an every node, because the serialize function cannot handle that.</p>
<pre>
&lt;xsl :variable name=&quot;total&quot;
select=&quot;count(//entry)&quot;/&gt;
</pre>
<p>Count all node values that we need in the PHP array.</p>
<pre>
&lt;xsl :template match=&quot;/&quot;&gt;
&lt;/xsl&gt;&lt;xsl :text&gt;a:&lt;/xsl&gt;
&lt;xsl :value-of select=&quot;$total&quot;/&gt;
&lt;xsl :text&gt;:{&lt;/xsl&gt;
&lt;xsl :apply-templates/&gt;
&lt;xsl :text&gt;}&lt;/xsl&gt;
</pre>
<p>Start the string with &#8220;a:&#8221;, then the number of key/value pairs.</p>
<pre>
&lt;xsl :template match=&quot;entry&quot;&gt;
&lt;/xsl&gt;&lt;xsl :text&gt;s:&lt;/xsl&gt;
&lt;xsl :value-of_
select=&quot;string-length(@name)&quot;/&gt;
</pre>
<p>Count the key characters.</p>
<pre>
 &lt;xsl :text&gt;:&quot;&lt;/xsl&gt;
&lt;xsl :value-of select=&quot;@name&quot;/&gt;
&lt;xsl :text&gt;&quot;;&lt;/xsl&gt;
 </pre>
<p>Add the actual key value</p>
<pre>
 &lt;xsl :text&gt;s:&lt;/xsl&gt;
&lt;xsl :value-of_
select=&quot;string-length(@value)&quot;/&gt;
</pre>
<p>Count the key characters</p>
<pre>
&lt;xsl :text&gt;:&quot;&lt;/xsl&gt;
&lt;xsl :value-of select=&quot;@value&quot;/&gt;
&lt;xsl :text&gt;&quot;;&lt;/xsl&gt; 
</pre>
<p>Add the actual key value.</p>
<pre>
</pre>
<p id="sourceCode">And we are done.</p>
<p>Transform the XML file with the XSLT file listed above and you get the the serialized string as a result<br />
Call the unserialize function on the transformation result and you get a true PHP array.</p>
<p>Have a look at the <a href="/examples/xml2phpArray.phps.php">source code</a> and the <a href="/examples/xml2phpArray.php">working code</a></p>
<p><!--adsense#archive--></p>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2005/03/01/xml-into-php-array-using-xslt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML documenten opbouwen: Element versus Attribuut</title>
		<link>http://blockquote.be/2004/05/04/xml-documenten-opbouwen-element-versus-attribuut/</link>
		<comments>http://blockquote.be/2004/05/04/xml-documenten-opbouwen-element-versus-attribuut/#comments</comments>
		<pubDate>Tue, 04 May 2004 10:05:23 +0000</pubDate>
		<dc:creator>Len</dc:creator>
				<category><![CDATA[XSLT]]></category>
		<category><![CDATA[artikel]]></category>
		<category><![CDATA[Dutch]]></category>
		<category><![CDATA[Information architecture]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://blockquote.be/2004/05/04/xml-documenten-opbouwen-element-versus-attribuut/</guid>
		<description><![CDATA[
Related posts

Webpatterns: HTML &#038; CSS working together


Uche Ogbuji, gastspreker op XML Europe 2004, geeft
enkele basisprincipes om XML documenten op te bouwen. Het belangrijkste principe dat in zijn artikel naar voren komt is dat je attributen in XML documenten enkel gebruikt om machine-gegevens op te slaan, en elementen om leesbare gegevens weer te geven.
Atributen zoals een [...]]]></description>
			<content:encoded><![CDATA[<div id="intro" style="padding-top: 10px;">
<strong>Related posts</strong></p>
<ul>
<li><a href="http://blockquote.be/2005/12/09/webpatterns-html-css-working-together/">Webpatterns: HTML &#038; CSS working together</a></li>
</ul>
</div>
<p><a href="http://www.idealliance.org/papers/dx_xmle04/index/author/98a10869d17866a536c62d994c.html" title="Author Uche Ogbuji" hreflang="EN">Uche Ogbuji</a>, gastspreker op <a href="http://www.xmleurope.com/" title="XML Europe 2004: Documenting the Future" hreflang="EN">XML Europe 2004</a>, geeft<br />
enkele basisprincipes om <abbr title="Extensible Markup Language "><span title="Extensible Markup Language ">XML</span></abbr> documenten op te bouwen. Het belangrijkste principe dat in zijn artikel naar voren komt is dat je attributen in <abbr title="Extensible Markup Language "><span title="Extensible Markup Language ">XML</span></abbr> documenten enkel gebruikt om machine-gegevens op te slaan, en elementen om leesbare gegevens weer te geven.</p>
<p>Atributen zoals een ID, zijn referentiepunten voor programma&#8217;s. Ze worden gebruikt bij het transformeren van documenten d.m.v. XSLT en komen zelden voor in de output van een transformatie. De inhoud van een element daarentegen bevat leesbare gegevens zoals een naam, de titel van een boek<br />
enz., die getoond worden aan de gebruiker.<br />
Een ID kan soms rare vormen aannemen, bvb. &#8220;sessionid{az12sqdb54qdg54qfb}&#8221;, waardoor de leesbaarheid van het document vermindert. Zet je de ID in een attribuut, dan wordt het duidelijk dat dit gegeven niet relevant is voor de lezer.</p>
<p>Machine-gegevens in een attribuut plaatsen heeft nog meer voordelen. <abbr title="XSL Transformations"><span title="XSL Transformations">XSLT</span></abbr> heeft bvb. meer mogelijkheden om attributen te bewerken. Een element uit de tree halen is veel eenvoudiger als je een attribuut-waarde hebt omdat je een ID rechtstreeks in een XPath expression kan plaatsen.<br />
 Onderstaande <abbr title="Extensible Stylesheet Language"><span title="Extensible Stylesheet Language">XSL</span></abbr>  voorbeeld heeft de variabele &#8220;username&#8221; ingesteld en gaat op zoek naar de auteur met de username waarde &#8220;jpeters&#8221;.</p>
<pre>
&lt;xsl :variable name=&quot;username&quot;&gt;jpeters&lt;/xsl&gt;
&lt;xsl :value-of select=&quot;//name[@username = $username]&quot;&gt;
&lt;/xsl&gt;</pre>
<p>Het <abbr title="Extensible Markup Language "><span title="Extensible Markup Language ">XML</span></abbr> document gaat als volgt:</p>
<pre>
&lt; ?xml version=&quot;1.0&quot;?&gt;
  &lt;authors&gt;
&lt;author&gt;
&lt;name username=&quot;jpeters&quot; pw=&quot;myPWencrypted&quot;&gt;
JanPeters
&lt;/name&gt;
&lt;/author&gt;
&lt;/authors&gt;
</pre>
<p>Het resultaat is de inhoud van het element &#8220;name&#8221; waarmee de usernaam &#8220;jpeters&#8221; overeenkomt. Nu nog het wachtwoord opnemen als attribuut en je hebt zo een authenticatie systeem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blockquote.be/2004/05/04/xml-documenten-opbouwen-element-versus-attribuut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
