• AKrotkov (unregistered)

    Bonus points for style?

    :-D

  • (cs)

    Nice arrows you got there...

  • lucha (unregistered)

    wtf!

    ...but, if you scroll it down fast enough, it's kinda nice-looking. Maybe he is a better ascii-art-composer then a programmer.....

  • (cs)

    Definitely worthy of "WTF"! I hope for the developer's sake he made a custom tool to edit this crap out so he doesn't have to do it by hand!

  • Robin H-P (unregistered) in reply to ComputerGuyCJ

    Yes, this is exactly why I think that for anything besides browser display, XSLT is the devil.

  • (cs)

    When I see ucirc I alwasy think û so this makes perfect sense.

  • (cs)

    This is lovely! 

    It actually reminds me of an old Apple ][ game where you had to use the left and right arrows to maneuver a cursor between scrolling text “walls”.  (Kinda simulating falling down a hole.)

    Come to think of it, I believe it was the result of a “single line program” contest.  The whole program was entered in on a single Apple Basic line.  One line was limited to either 128 or 256 characters, don’t remember which.

    It was pretty impressive for its compactness.  I would not have wanted to try to maintain THAT either, but at least it did something reasonable.

  • (cs) in reply to Robin H-P

    You know, I'm not a total newbie to XSL, but for the life of me I can't imagine why anyone would want to do this. I strongly suspect six days of work could be boiled down to this:

    <FONT color=#0000ff size=2>

    <</FONT><FONT color=#800000 size=2>xsl:value-of</FONT><FONT color=#ff00ff size=2> </FONT><FONT color=#ff0000 size=2>disable-output-escaping</FONT><FONT color=#0000ff size=2>="yes"</FONT><FONT color=#ff00ff size=2> </FONT><FONT color=#ff0000 size=2>select</FONT><FONT color=#0000ff size=2>="$input"/>

    </FONT>

    But without knowing the original requirements, that's just a shot in the dark.

     

  • (cs)

    The real WTF is that he did not include replacements for all unicode characters.

    That code would not parse ????? (wa-te-fa-ku) correctly to &#12527;&#12486;&#12501;&#12449;&#12463;.

  • Alex Papadomulis (unregistered) in reply to marvin_rabbit

    You should check the international C objuscation contest, they make better things in less lines and more unmaintanable.

  • Melanie (unregistered) in reply to lucha

    It is making me seasick. [+o(]

  • (cs)

    six days, ha that guy was way underpaid

     

    I bet i could have made it last at least two weeks, taken a day off and came back with a longer list. Oh an I would have used C#.NET to make a program that would do it all for me, allowing me to surf the web and buy "it" from ebay.

  • (cs)

    There is always someone out there who takes a good idea/good tool and then abuses it to the point of stupidity while thinking they are being clever.

    Annoying, but hardly a wtf.  Stupidity neither confuses, nor surprises me when I see it (even outa myself on the occasion).

  • (cs)

    Indeed. Some... no, most uses of XML are truly repulsive. XML-RPC and SOAP, for example. (Worse than Tubgirl.) And XSL in general is high on the list. I can only hope, for the good of the Web, that XSL-FO (a new part of the XSL suite -- like CSS, except in XML) is not widely adopted. Seriously, what the hell is W3C thinking these days?

    My theory is that people think that any technology with an acronym starting with an 'X' is cool by default. Since the letter X is completely useless anyway, I propose we eliminate it from the alphabet. That'll put the various data-ekschange formats on an equal playing field.

  • (cs) in reply to A Wizard A True Star
    A Wizard A True Star:

    You know, I'm not a total newbie to XSL, but for the life of me I can't imagine why anyone would want to do this. I strongly suspect six days of work could be boiled down to this:

    <font color="#0000ff" size="2"> </font>

    <font color="#0000ff" size="2"><</font><font color="#800000" size="2">xsl:value-of</font><font color="#ff00ff" size="2"> </font><font color="#ff0000" size="2">disable-output-escaping</font><font color="#0000ff" size="2">="yes"</font><font color="#ff00ff" size="2"> </font><font color="#ff0000" size="2">select</font><font color="#0000ff" size="2">="$input"/></font>

    But without knowing the original requirements, that's just a shot in the dark.


    Cute, but that would leave him with invalid HTML, because the wëïrd characters would get copied into the output without being transformed to w&euml;&iuml;rd. The fun thing is that XSL doesn't provide for this so everybody has to create their own solution; like having &amp;euml; in the input and then doing the 'disable-output-escaping="yes"' thingy.

    P.S. XML > S-expr

  • (cs)

    IsTrue(Idiot!) = True

  • Csaboka (unregistered)

    This thing... Hurts my eyes...

  • (cs) in reply to Csaboka

    why?

    it looks good [:P] (if you scroll fast enough)

  • Henryk Pl&#246;tz (unregistered)

    Moin,

    Somebody should have told him about the concept of character encodings. There is absolutely no reason to escape anything other than & and < (and maybe > and ") in HTML. Simply select the right character encoding and everything will be fine. (This especially goes to Joost_: Of course "wëïrd" would not be invalid in HTML, so long as you declare what encoding you're using.)

    --
    Henryk Plötz
    Grüße aus Berlin

  • Eric the .5b (unregistered)

    SIX STRAIGHT DAYS to cut and paste all that?  Eesh.

  • Henryk Pl&#246;tz (unregistered) in reply to Henryk Pl&#246;tz

    The dog ate my homework^W^W^W^W'forum' software ate my characters: What I said was of course:
    There is absolutely _no_reason to escape anything other than & and < (and maybe > and ") in HTML.

  • (cs)

    At least it's nicely tabbed...

  • (cs)

    If you zoom out really far, you can see a dot and two right angle brackets.

    [image]

  • toxik (unregistered) in reply to Joost_

    I'm not intending to be a whipzor (don't ask, I mean pointdexter) but the output would be UTF-8, so Unicode would be OK, see there's a difference between escaping for ambigiouty and escaping for readability/transport stuffies.


  • nene (unregistered) in reply to Henryk Pl&#246;tz

    He should be assigned to extend this code to cover the whole unicode range :) That would be a real opportunity to show all those great XSL skills :D

  • (cs)

    So much stupid work, and it doesn't even contain the right translations for German umlauts.
    äöü ÄÖÜ ß
    auml ouml uuml Auml Ouml Uuml szlig

  • PeonPower (unregistered)

    He just copied the idea from the great pyramids of Div!

  • Random Scotsman (unregistered) in reply to PeonPower

    Did anyone else thing they were playing spyhunter when they scrolled down?

  • Random Scotsman (unregistered) in reply to Random Scotsman
    Anonymous:
    Did anyone else thinK they were playing spyhunter when they scrolled down?
  • (cs) in reply to Random Scotsman

    Reminds me of those old spams I used to get that said to hold the scroll down button, then a shit-ton of lines flew up, and "animated" characters cris crossed.....

     

  • Boofus McGoofus (unregistered)

    Anyone know why "&nbsp;" needs to be changed to " "?  Wasn't it valid html to start with?  (Yeah, I read through it.  I'll go be embarrassed now.)

  • (cs)

    oh my god you stupid ass wipe.

    I'll say this--the code is very pretty to watch when you scroll up and down.

  • (cs)
    Alex Papadimoulis:
    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.

    And on the seventh day, he rested.  Unfortunately, he did not quit programming.

    Sincerely,

    Gene Wirchenko


  • (cs) in reply to Random Scotsman
    Anonymous:
    Did anyone else thing they were playing spyhunter when they scrolled down?


    Cue the crash music.

    Sincerely,

    Gene Wirchenko

  • Russ Gray (unregistered) in reply to Brendan Kidwell

    [image]

    My god, XSL code shaped like giant angle-brackets? You know you're in the presence of a true artist when form and function are combined so flawlessly.

    Have you read Code Reading: An Open Source Perspective, by the way? Not many people out there that 'zoom out' of code...

  • (cs)

    Could this not be solved by simply specifying the encoding in the XML document?

    <?xml version="1.0" encoding="ISO-8859-1"?>

    Simple as that, right? Just seems like he did lots and lots of work for absolutely no reason. I am a bit fond of XML myself, but this is just ludicrous.

     

  • Spudley (unregistered)

    Sigh

    XML is designed to allow entities to be defined in the DTD. There's no need for a single line of that code.

    But in general... why bother anyway? Numeric entities are much more convenient. What's the point in defining a bunch of entities when you only end up using most of them once or twice anyway.

    But never mind.... I think it's fun that he's made the the thing look like a couple of angle-brackets.... sort of like fractal code -- it looks the same from a long way away as it does close up ;)

  • (cs) in reply to Boofus McGoofus
    Anonymous:
    Anyone know why "&nbsp;" needs to be changed to " "?  Wasn't it valid html to start with?

    Replacing &nbsp; with the U+0020 character (space) would be incorrect - the right character would be U+00A0 (no-break space). In the code that Alex posted the U+0020 character is used, but that could be a copy-paste error, so now we'll never know whether the original code had a bug or not.

    (This WTF'ed forum ate my first post. Can't you just fix/change it?)
  • GneralTsao (unregistered) in reply to Brendan Kidwell

    Powers of Ten, anyone? I bet at 10^26 this becomes the entire XMLiverse

    http://en.wikipedia.org/wiki/Powers_of_Ten

  • NoName (unregistered)

    Please, please, would someone drag out this "programmer" and break his fingers. All of them. Or better yet, just shot him. He just needs killing.

  • Appletosh (unregistered) in reply to marvin_rabbit

    I remember that game!  I would play it when I got tired of Lemonade Stand!

  • LP (unregistered)

    Ever heard this?

    XML is like violence: if it doesn't work, use more.

  • (cs)

    Is nobody taught anymore that this crap takes real time to process!? And unless I'm completly out of my mind, you want your web servers to be able to handle more that 4 users, right?
    ------

    Don't kill him, but make friday beat the idiot day.

    DD

  • Appletosh (unregistered) in reply to marvin_rabbit

    marvin_rabbit:
    This is lovely! 

    It actually reminds me of an old Apple ][ game where you had to use the left and right arrows to maneuver a cursor between scrolling text “walls”.  (Kinda simulating falling down a hole.)

    Come to think of it, I believe it was the result of a “single line program” contest.  The whole program was entered in on a single Apple Basic line.  One line was limited to either 128 or 256 characters, don’t remember which.

    It was pretty impressive for its compactness.  I would not have wanted to try to maintain THAT either, but at least it did something reasonable.

     

    Forum software is hard!

  • Dave Markle (unregistered)

    "Night Driver" implemented completely in XML!  Brilliant!


  • (cs) in reply to Henryk Pl&#246;tz

    Sorry Mr. Pl&ouml;tz, I was under the impression that IE was just being too forgiving when putting weird characters in HTML documents.

  • (cs)

    <font size="3">XSLT is a difficult dialect to fully master. Leaving aside for the moment the core issue of replacing textual content inside an XSLT document (which requires recursion), the following is an example of a cleaner implementation:

    POC.xml</font>
    <font size="2"><?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
    <?xml-stylesheet href="poc.xsl" type="text/xsl"?>
    <content>
    Hello this is the letter <b>ê</b>   
    </content>
    <font size="3">
    POC.xsl</font>
    <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        exclude-result-prefixes="msxsl">

    <xsl:output encoding="iso-8859-1" method="html"/>
    <xsl:variable name="items">
    <item text="ê" html="&amp;egrave;" />
    <item text="à" html="&amp;agrave;" />
    <item text="á" html="&amp;acute;" />
    <!-- add more items to be replaced -->
    </xsl:variable>

    <xsl:variable name="count" select="count(msxsl:node-set($items)/item)" />

    <xsl:template match="@* | ">
    <xsl:copy><xsl:apply-templates select="@
    | node()
    "/></xsl:copy>
    </xsl:template>

    <xsl:template match="text()">
    <xsl:call-template name="replace">
    <xsl:with-param name="content" select="string(.)" />
    </xsl:call-template>
    </xsl:template>

    <xsl:template name="replace">
    <xsl:param name="content" />
    <xsl:param name="counter" select="number(1)"/>
    <xsl:variable name="node" select="msxsl:node-set($items)/item[$counter]" />
    <xsl:choose>
    <xsl:when test="contains($content,$node/@text)">
    <xsl:call-template name="replace">
        <xsl:with-param name="content"
            select="concat(substring-before($content,$node/@text),$node/@html,substring-after($content,$node/@text))" />
        <xsl:with-param name="counter" select="$counter" />
    </xsl:call-template>
    </xsl:when>
    <xsl:when test="$counter &lt; $count">
    <xsl:call-template name="replace">
        <xsl:with-param name="content" select="$content" />
        <xsl:with-param name="counter" select="$counter + 1" />
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise><xsl:value-of select="$content" disable-output-escaping="yes"/></xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    </xsl:stylesheet> </font>

  • (cs)

    If it took six days to craft the XSLT, then either the developer does not understand XSLT, or the document design is suspect or even worse, there is a misapplication of XSLT to solve a certain problem domain.

    In this WTF, it obviously is the last.

    For one, textual recursions inside XSLT incur a heavy performance penalty. If this was for a Microsoft platform and static HTML files are generated, I'd use a custom class with an XmlReader to do the textial replacements instead of resorting to XSLT which is a dirty way to get it done (and incidentally is not quick when the size of the document goes beyond a certain magic number)

    XSLT is very handy to handle UI issues and apply presentation logic, especially in AJAX applications. But it should not be used throughout an application domain just because it seems cheap and easy to use.

  • BlueEagle (unregistered)

    What, you've never seen this kind of code before??

    Am I the only one working with such morons on a regular basis? o.O

  • Fubar (unregistered)

    Anyone who's ever used XSLT to transform XML to get decent HTML layouts knows that XSLT is a WTF all on its own. 

    For anything other than simple outputs it's one of the shittiest ways to manipulate XML.  For anything requiring comlpex layouts you're much better off using a standard C++ or Java DOM parser.  

Leave a comment on “Internationalexemelization”

Log In or post as a guest

Replying to comment #:

« Return to Article