• « OPML, Let Me Count The Ways I Love Thee...
    • |
    • Main
    • |
    • Don't Reinvent The Basics? Since When Did Sun Have Anything To Do With "Inventing" The Office Software Basics? »
            • November 29, 2005

              It's People Like This That Give XSLT The Undeserved Rap For Being Difficult

            • Internationalexemelization - The Daily WTF

              via a recent link left in a comment by Jez the following Daily WTF (Jez, couldn't agree with you more, btw..) showcases why agility and language have a lot less in common with an agile programmer than one might hope to be the case.

              Now, before you jump all over for my undeserved comment in the title -- please look at the following description preceded then by (to be honest I'm surprised this even ran with blowing the stack, but theres no XML attached to it so its tough to know how deep the recursion could potentially go) what I would term a perfect representation of not only someone who doesnt understand XSLT, but anything even remotely resembling any type of code of ANY sort -- and then let me know if you think maybe, just maybe cases like this speak volumes as to why there are some people who should stop pretending they know how to program and simply move into middle management (although, I'm not sure the middle management folks will want this individual either... and I wouldn't blame them!):

              There are some developers out there who believe that XML is the greatest "innovation" in computer science since electricity. Believing that, apparently, all data and communication are best represented as strings with angle-brackets, they'll go to great strides to ensure that this "technology" is applied liberally throughout systems they build. Undeterred by the inherent constraints of a data interchange format and its related transforms, they'll make sure that XML is not only the driving force behind their projects, but their raison d'�tre.

              Joe works with one such a developer, and presents us i18n.xsl, the end result of his colleague's six straight days of work trying to get his fully-XSL solution to properly display HTML characters.

              
              
              <xsl:template name="Replace">
                <xsl:param name="string" select="''"/>
                <xsl:param name="pattern" select="''"/>
                <xsl:param name="replacement" select="''"/>
                <xsl:choose>
                <xsl:when test="$pattern!='' and $string!='' and contains($string, $pattern)">
                  <xsl:value-of select="substring-before($string, $pattern)"/>
                   
                  <xsl:copy-of select="$replacement"/>
                  <xsl:call-template name="Replace">
                    <xsl:with-param name="string" select="substring-after($string, $pattern)"/>
                    <xsl:with-param name="pattern" select="$pattern"/>
                    <xsl:with-param name="replacement" select="$replacement"/>
                  </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$string"/>
                </xsl:otherwise>
                </xsl:choose>
              </xsl:template>
              
              

              <xsl:template name="ReplaceLCWithHTML">
              <xsl:param name="input" select="''"/>
              <xsl:choose>
              <xsl:when test="$input!=''">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string" select="$input"/>
              <xsl:with-param name="pattern" select="'à'"/>
              <xsl:with-param name="replacement" select="'&agrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'á"/>
              <xsl:with-param name="replacement" select="'&aacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'â'"/>
              <xsl:with-param name="replacement" select="'&acirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'è'"/>
              <xsl:with-param name="replacement" select="'&egrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'é'"/>
              <xsl:with-param name="replacement" select="'&eacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ê'"/>
              <xsl:with-param name="replacement" select="'&ecirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ì'"/>
              <xsl:with-param name="replacement" select="'&igrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'í'"/>
              <xsl:with-param name="replacement" select="'&iacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'î'"/>
              <xsl:with-param name="replacement" select="'&icirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ò'"/>
              <xsl:with-param name="replacement" select="'&ograve;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ó'"/>
              <xsl:with-param name="replacement" select="'&oacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ô'"/>
              <xsl:with-param name="replacement" select="'&ocirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ù'"/>
              <xsl:with-param name="replacement" select="'&ugrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ú'"/>
              <xsl:with-param name="replacement" select="'&uacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'û'"/>
              <xsl:with-param name="replacement" select="'&ucirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ý'"/>
              <xsl:with-param name="replacement" select="'&yacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'œ'"/>
              <xsl:with-param name="replacement" select="'&oelig;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'ç'"/>
              <xsl:with-param name="replacement" select="'&ccedil;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'™'"/>
              <xsl:with-param name="replacement" select="'&trade;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'¢'"/>
              <xsl:with-param name="replacement" select="'&cent;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'©'"/>
              <xsl:with-param name="replacement" select="'&copy;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'®'"/>
              <xsl:with-param name="replacement" select="'&reg;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'°'"/>
              <xsl:with-param name="replacement" select="'&deg;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'&nbsp;'"/>
              <xsl:with-param name="replacement" select="' '"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'&shy;'"/>
              <xsl:with-param name="replacement" select="' '"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'·'"/>
              <xsl:with-param name="replacement" select="'&middot;'"/>
              </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
              <xsl:value-of select="$input"/>
              </xsl:otherwise>
              </xsl:choose>
              </xsl:template>

              <xsl:template name="ReplaceUCWithHTML">
              <xsl:param name="input" select="''"/>
              <xsl:choose>
              <xsl:when test="$input!=''">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string">
              <xsl:call-template name="Replace">
              <xsl:with-param name="string" select="$input"/>
              <xsl:with-param name="pattern" select="'À'"/>
              <xsl:with-param name="replacement" select="'&Agrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Á'"/>
              <xsl:with-param name="replacement" select="'&Aacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Â'"/>
              <xsl:with-param name="replacement" select="'&Acirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'È'"/>
              <xsl:with-param name="replacement" select="'&Egrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'É'"/>
              <xsl:with-param name="replacement" select="'&Eacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ê'"/>
              <xsl:with-param name="replacement" select="'&Ecirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ì'"/>
              <xsl:with-param name="replacement" select="'&Igrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Í'"/>
              <xsl:with-param name="replacement" select="'&Iacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Î'"/>
              <xsl:with-param name="replacement" select="'&Icirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ò'"/>
              <xsl:with-param name="replacement" select="'&Ograve;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ó'"/>
              <xsl:with-param name="replacement" select="'&Oacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ô'"/>
              <xsl:with-param name="replacement" select="'&Ocirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ù'"/>
              <xsl:with-param name="replacement" select="'&Ugrave;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ú'"/>
              <xsl:with-param name="replacement" select="'&Uacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Û'"/>
              <xsl:with-param name="replacement" select="'&Ucirc;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ý'"/>
              <xsl:with-param name="replacement" select="'&Yacute;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Œ'"/>
              <xsl:with-param name="replacement" select="'&OElig;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'Ç'"/>
              <xsl:with-param name="replacement" select="'&Ccedil;'"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'&NBSP;'"/>
              <xsl:with-param name="replacement" select="' '"/>
              </xsl:call-template>
              </xsl:with-param>
              <xsl:with-param name="pattern" select="'&SHY;'"/>
              <xsl:with-param name="replacement" select="' '"/>
              </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
              <xsl:value-of select="$input"/>
              </xsl:otherwise>
              </xsl:choose>
              </xsl:template>

            • Posted by m.david : November 29, 2005 12:25 AM GMT

            Trackback Pings

            TrackBack URL for this entry:
            http://www.xsltblog.com/xslt-blog-mt/mt-tb.cgi/1159

            Comments

              • Oh for crying out loud. This falls into the same category as the programmer who wrote:

                switch(i){ case 1:return “a”;break; case 2:return “b”;break; case 3:return “c”;break; .. case 26:return “z”;break; }

                The art of programming comes in the ability of programmers to recognize how to abstract and generalize. The example above can be done in about a ten line XSLT reading a secondary file that contains the appropriate character mappings (and becomes even more trivial in XSLT2). Of course, I suspect that the initial author’s non-XSLT code is just as hopeless.

                — Kurt

              • Posted by: Kurt Cagle at December 4, 2005 05:22 PM
              • :D Isn’t it amazing what people can believe to be “code” :D

              • Posted by: M. David Peterson at December 5, 2005 07:01 AM

            Post a comment




            Remember Me?

            (you may use HTML tags for style)

          • © 2005 :: <XSLT:Blog/> (xsltblog.com) is a product of M. David Peterson and FunctionalX Consulting. See Licensing Info Below.
          • Except where otherwise noted, this sites content and source code is licensed under the Attribution License from Creative Commons.