• (cs) in reply to DropDeadThread
    DropDeadThread:
    What if you delete, say, address 2? How will you know not to look for it? And how do you know when you've reached the end of an address?
     
    <rootNode> 
       <indexOfAddresses>1,3,4...</indexOfAddresses>
       <address_1 numberOfCharacters="12" nextAddress="address_3">442 Fake St.</address_1>
       <address_3 numberOfCharacters="11" nextAddress="address_4>61 Main St.</address_3>
       <address_4 numberOfCharacters="13" nextAddress="address_5>99 R-Tard Ave</address_3>
       ...
    </rootNode>
    </pre>
    </div></BLOCKQUOTE>
    <p><b>.</b></p>
    <p>Guys, we really need to see more Design Patterny stuff here.  Linked Lists are so obsolete.  The Decorator Pattern is what we need....</p>
    <BLOCKQUOTE class="Quote">
    GangOfFour:
    <addresses>
        <address_101>
            123. Fake St.
            <next_address>
                  <address_100>
                         456 Strip Club Blvd.
                         <next_address>
                               <address_99>
                                       789 Street Ln.
                                       <next_address>
                                             ...
                                             <address_1>
                                                   1 Nest Pkwy
                                                   <next_address/>
                                             </address_1>
                                             ...
                                       </next address>
                               </address_99>
                        </next_address>
                 </address_100>
            </next_address>
       </address_101>
    </addresses>
    
  • jviray (unregistered) in reply to akatherder

    gee...

  • (cs) in reply to Grovesy
    Grovesy:
    FredSaw:
    Grovesy:
    Well, yes!. e.g. Web.Page->MyCompanyPage->SecurePage->DataViewPage->CustomerDetails

    Informs usus as to what each 'base' page does. What would you suggest? BasePage, BaseBasePage, BaseBaseBasePage???

    Essentially, yes. In your example the "blindingly obvious" thing is that they all are pages. What is not obvious is that other pages derive from them. Better:

    System.Web.UI.Page->CompanyBase->SecureBase->DataViewBase->CustomerDetails

    Ok I'll meet you 1/2 way and go along with that.

    Though only if the class is marked as Abstract, then yes you could say that it is base e.g. Otherwise, it all depends in how it is being used.

    I'm just not keen on labelling a class 'base', I would prefer it to have a name that hints at its responsibility.

    The solution to this whole problem is realizing that you're using Visual Studio and that refactoring takes a few seconds (maybe a few minutes, if the project is a few hundred pages). Right-click -> refactor -> rename -> voila.

    For those of you not familiar with VS 2005+, this allows you to rename a class, variable, struct, or pretty much anything from any point in the application and the compiler will go through the rest of your project and rename all other references to it to match, so that you don't have to fall back to find/replace and manual inspection of whether or not the current find actually needs to be replaced.

    Use your tools, people. BasePage is fine, so long as when you need to change things and have it inherit from a new BasePage you rename the old BasePage to something more descriptive.

  • (cs)

    I worked at a place where they did exactly the same thing, about five years ago. The XML was impossible to validate. It was actually one of a long list of WTFs at that place, but this one bothered me because, as others have said, it demonstrates a grave lack of understanding of XML.

  • Thuktun (unregistered)

    I worked in a company that had branches in the USA, Canada, and the UK. Some allegedly XML-savvy folks in the UK branch decided that we needed to represent a table of contents like this:

    <BMark1 name="..."> <BMark2 name="..."/> <BMark2 name="..."> <BMark3 name="..."/> <BMark3 name="..."/> </BMark2> </BMark1> <BMark1 name="..."/>

    Where the depth of the element was encoded into the name, rather than being implied by its position in the document. This would also have sabotaged the ability to write an XSD or DTD unless you arbitrarily limited the depth.

    Sadly, this kind of thing seems common in Enterprise-y circles.

  • (cs) in reply to dkallen99
    dkallen99:
    The REAL WTF is that he started counting with 1, instead of zero. Everyone knows arrays are indexed starting with zero.

    There are two kinds of people: 1) those who start arrays with one and 1) those who start them with zero.

  • TInkerghost (unregistered) in reply to James
    James:
    OK, so I'm a bit XML-stupid... talk to me like I was 5-year-old, or a 1st-year CS student (same mental acuity, no?). Would the right way to do this would be more like this?
    <addresslist>
      
    123 ABC
    ...
    987 XYZ
    </addresslist>

    I mean, obviously you can't write a schema when every tag is different, right? So if you do what I did above, how do you get a count out of it? I took an XML course a few years back, but not a lot sunk in =-)

    Generally something like this:

    <body>
      
    123 ABC
    234 BCD
    ...
    999 ZZZ
    </body>

    your XSD would mark index as a non-negative integer and the contents of the address tag as a string. Address would be marked as appearing a minimum of 0 times and an undefined maximum.

  • Jon (unregistered)
    <container>
    	<type>comment</comment>
    	<value>
    		<container>
    			<type>sentence</type>
    			<value>
    				<container>
    					<type>interjection</type>
    					<value>
    						<container><type>char</type><value>B</value</container>
    						<container><type>char</type><value>r</value</container>
    						<container><type>char</type><value>i</value</container>
    						<container><type>char</type><value>l</value</container>
    						<container><type>char</type><value>l</value</container>
    						<container><type>char</type><value>a</value</container>
    						<container><type>char</type><value>n</value</container>
    						<container><type>char</type><value>t</value</container>
    					</value>
    				</container>
    				<container>
    					<type>punctuation</type>
    					<value>!</value>
    				</container>
    			</value>
    		</container>
    	</value>
    </container>
  • ASantos (unregistered) in reply to akatherder

    We have some "special" XML too. Ours would look like this:

    <properties> <property> <propertykey>numberOfAddresses</propertykey> <propertyvalue>110</propertyvalue> </property> <property> <propertykey>address_1</propertykey> <propertyvalue>442 Fake St.</propertyvalue> </property> ... </properties>

    Fortunately I'm in the middle of cleaning it up now.

  • dkf (unregistered) in reply to vt_mruhlin
    vt_mruhlin:
    GangOfFour:
    <addresses>
        <address_101>
            123. Fake St.
            <next_address>
                <address_100>
    [...]
                </address_100>
            </next_address>
        </address_101>
    </addresses>
    
    Now that is quite the worst XML abuse I've seen in a long time, and that's despite knowing people who are aces at namespaces and XQuery. Indeed, that example goes further than any other here to making standard XML tools useless. No validation, no sane route to translation, no use of any of the usual DOM conveniences (hah!) In short, you'd need to use something heinous like parsed entities or putting content in PIs to make it worse...

    Do you mind if I take notes?

  • dolor (unregistered)

    what does the XML operator "_" do??? I've never see that before, wish I knew about it because my XML programs would be soooo much faster (I'm guessing because I don't know what it is) plus it looks more professional and enterprisish!

    I here are some sweet push and pop XML methods which work well with this data type.

    function getNULLvalue() { alert("To do: Need to fix this and user should never see this message."); return null; } function popXML() { try { var seperator = "."; var documentValueAsString = "document"; var elementValueAsString = "element"; var firstValueAsString = "first"; var lastValueAsString = "last"; var nextValueAsString = "next"; var previousValueAsString = "previous"; var childValueAsString = "child"; var siblingValueAsString = "sibling"; var nodesValueAsString = "nodes"; var nodeValueAsString = "node"; var valueValueAsString = "value";

    	xmlDoc=loadXMLDoc("xmlArray.xml");
    	var xmlCode = "xmlDoc" + seperator + documentValueAsString + elementValueAsString.substr(0,1).toUpperCase()+elementValueAsString.substr(1) + seperator + firstValueAsString + childValueAsString.substr(0,1).toUpperCase()+childValueAsString.substr(1)";
    	while ( eval(xmlCode) != getNULLvalue() )
    	{
    		xmlCode = xmlCode + seperator + nextValueAsString + siblingValueAsString.substr(0,1).toUpperCase()+siblingValueAsString.substr(1);
    	}
    	if(eval(xmlCode) == getNULLvalue())
    	{
    		xmlCodePaths = xmlCode.split(".");
    		xmlFixed = new Array();
    		xmlCode = getNULLvalue();
    		for(var i=0; i!=xmlCodePaths.length; i=i+1)
    		{
    			if(i<xmlCodePaths.length-1)
    			{
    				xmlFixed[i] = xmlCodePaths[i];
    			}
    		}
    		xmlCode = xmlFixed.join(seperator);
    		if(eval(xmlCode) == eval("xmlDoc" + seperator  + lastValueAsString + childValueAsString.substr(0,1).toUpperCase()+childValueAsString.substr(1)))
    		{
    			return eval("eval(xmlCode) + seperator + childValueAsString + nodesValueAsString.substr(0,1).toUpperCase()+nodesValueAsString.substr(1)")[0].eval(nodeValueAsString + valueValueAsString);
    		}
    	}
    }
    catch
    {
    	try
    	{
    		popXML();
    	}
    	catch
    	{	try
    		{
    			popXML();
    		}
    		catch
    		{	try
    			{
    				popXML();
    			}
    			catch
    			{	try
    				{
    					popXML();
    				}
    				catch
    				{	try
    					{
    						popXML();
    					}
    					catch
    					{	try
    						{
    							popXML();
    						}
    						catch
    						{	try
    							{
    								popXML();
    							}
    							catch
    							{	try
    								{
    									popXML();
    								}
    								catch
    								{	try
    									{
    										popXML();
    									}
    									catch
    									{
    										return "Error!";
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    }
    

    return; }

  • al (unregistered) in reply to ais523
    Clearly they need to encode the XML itself in XML so they can add the numbers:

    It's funny how much that resembles the Apple property list format, used throughout OS X:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
    <plist version="1.0">
    <dict>
        <key>Author</key>
        <string>William Shakespeare</string>
        <key>Lines</key>
        <array>
            <string>It is a tale told by an idiot,</string>
            <string>Full of sound and fury, signifying nothing.</string>
        </array>
        <key>Birthdate</key>
        <integer>1564</integer>
    </dict>
    </plist>

    Seriously, I can't believe how unhelpful this format is. It's like they were trying to make it a pain to traverse. On the plus side, the xsd is very, very simple.

  • Sum Yung Guy (unregistered)

    "XML is god's revenge on C programmers for mocking Lisp. Not only do they have to have brackets; THEY HAVE TO NAME THEM AS WELL"

    • A comment overheard by Professor Davenport at a computer algebra conference
  • (cs) in reply to Azd
    Azd:
    Azd:
    Looks like someone just converted one of our ini files to xml. We have lots of files that look like this:
    numberOfAddresses=110
    address_1=442 Fake St.
    address_2=61 Main St.
       ...
    address_110=3881 N 4th Ave. #5D
    

    I should also add that the code to read in this would open and close the file 111 times ... and was accessed by multiple processes with no locking for interprocess communication.

    Now you're diverging into the real world. Don't do that.

    Can't we just get back to the purity of discussing whether or not one can devise a schema for this no doubt excellent piece of inter-process communication?

  • (cs) in reply to Matt D
    Matt D:
    Freaking unreal. This "designer" obviously missed the point of XML entirely.
    "The point of XML?"

    Feel free to elucidate.

  • (cs) in reply to Pidgeot
    Pidgeot:
    dkallen99:
    The REAL WTF is that he started counting with 1, instead of zero. Everyone knows arrays are indexed starting with zero.

    There are two kinds of people: 1) those who start arrays with one and 1) those who start them with zero.

    I'm the other sort. I start with infinity. That way, I know I'm never going to run out of space.

    Design decisions, you see. Design decisions. Incidentally, what was this moron thinking?

    (For those that care, yes: the infinity in question is aleph-null. Just to be on the safe side.)

  • (cs) in reply to Azd
    Azd:
    Azd:
    Looks like someone just converted one of our ini files to xml. We have lots of files that look like this:
    numberOfAddresses=110
    address_1=442 Fake St.
    address_2=61 Main St.
       ...
    address_110=3881 N 4th Ave. #5D
    

    I should also add that the code to read in this would open and close the file 111 times ... and was accessed by multiple processes with no locking for interprocess communication.

    XML/Java philosophy: if it's too slow add more hardware

  • (cs) in reply to DOA
    DOA:
    Thief^:
    Actually the first C++ compiler was written in C++, and was compiled in itself
    Fun exercise: Explain this concept to your grandma.

    It's like God created himself...

  • Zaippa (unregistered)

    I've never used XML, never had courses in XML and never read up on XML, all i know is that it stores data in a tree structure and has syntax much like HTML. But still i see how this is wrong!

    Taking a tree and abusing it to make a list, by making all nodes children of the root, is kind a' like... why use a tree for that?

    (hehe, finally an XML WTF i could throw a rant into :))

  • immibis (unregistered) in reply to ais523
    ais523:
    Clearly they need to encode the XML itself in XML so they can add the numbers: SNIP See, that's much more customisable, and easier to process. It even allows a character other than underscore to be used...

    I think you mean

    <tag name="rootNode">
      <properties/>
      <contents type="nothing" value="" />
      <tagContents number="111">
        <tag name="numberOfAddresses">
          <properties/>
          <contents type="number" value="110" />
          <tagContents number="0" />
        </tag>
        <tag name="address" sequenceno="1" separator="_">
          <properties/>
          <contents type="string" value="442 Fake St." />
          <tagContents number="0" />
        </tag>
        <tag name="address" sequenceno="2" separator="_">
          <properties/>
          <contents type="string" value="61 Main St." />
          <tagContents number="0" />
        </tag>
        <!-- ... -->
        <tag name="address" sequenceno="110" separator="_">
          <properties/>
          <contents type="string" value="3881 N 4th Ave." />
          <tagContents number="0" />
        </tag>
      </tagContents>
    </tag>
    

    Even more customizable! You can have integer contents! Now if only XML came into this somewhere it would be enterprisy...oh...wait........

  • axo (unregistered)

    that needs not be a wtf on the "xml/dtd design" part. example: there's the possibility to insert dynamic data through xml into "adobe indesign cs1" - you can import the xml file and match xml nodes against design configuration. once the location of the xml node is set into the document, you can update the xml without the need to format the whole indesign document again. the problem is that indesign in that version could not understand following scheme, which would be the "appropriate way":

    <node id="42">content</node>
    <node id="47">content</node>
    

    ... so all you were able to do is to generate the dtd and xml dynamically and work just as the example above shows:

    <node_42>content</node_42>
    <node_47>content</node_47>
    

    ... so what are the options? create a well-designed xml file or create a crappy xml file and spare the layouter a week of additional work?

    wtf needs not be on the xml side.

    and yes, indesign seems to have improved on that problem in their next versions.

  • Izzy (unregistered) in reply to DOA
    DOA:
    Thief^:
    Actually the first C++ compiler was written in C++, and was compiled in itself
    Fun exercise: Explain this concept to your grandma.
    It's like those bad words Pappy said when he got drunk and pissed on the electric fence.
  • gman (unregistered)

    Bwahahaha! Does Ben work for EchoMail?

  • Watson (unregistered) in reply to real_aardvark
    real_aardvark:
    (For those that care, yes: the infinity in question is aleph-null. Just to be on the safe side.)
    I find it easier to index my arrays with ordinals rather than cardinals. You should try starting from ω.
  • JimM (unregistered) in reply to Opie

    [quote user="OpieThe solution to this whole problem is realizing that you're using Visual Studio and that refactoring takes a few seconds... [/quote] Obviously you're not being paid by the hour ;^)

    The correct solution to this whole problem is to throw Visual Studio out of the window and rewrite your entire application in a language / framework that actually works (Perl anyone?)...

  • JimM (unregistered) in reply to JimM

    [quote user="JimM"][quote user="OpieThe solution to this whole problem is realizing that you're using Visual Studio and that refactoring takes a few seconds... [/quote]

    Obviously you're not being paid by the hour ;^)

    The correct solution to this whole problem is to throw Visual Studio out of the window and rewrite your entire application in a language / framework that actually works (Perl anyone?)...[/quote] I hate it when windows autohighlights more text than you want to select :(

  • (cs)

    STOP IT STOP IT STOP IT STOP IT

    this thread is making me cry ;_;

    You are all bad bad people and I love you dearly.

  • blatant ripoff (unregistered)

    442 Fake St. doesn't resolve to an address. What's really going on here?

  • (cs) in reply to Cloak
    Cloak:
    DOA:
    Thief^:
    Actually the first C++ compiler was written in C++, and was compiled in itself
    Fun exercise: Explain this concept to your grandma.

    It's like God created himself...

    badly... in the case of C++

  • Tom (unregistered)

    That's exactly the same as what I've seen by a contractor for our systems:

    <Bit0 value="Description 1"/> <Bit1 value="Description 2"/> <Bit2 value="Description 3"/> <CODEA value="4"/> <CODEB value="4"/> <CODEC value="9"/>

    Where CODEA, CODEB and CODEC were descriptors that could vary. No DTD for you!

    Those config files are still in place, though. :( I always wanted to send them in ...

  • Doesnt Matter (unregistered) in reply to Alan

    This is EXACTLY why XML is bunch of shit in brackets!

  • Sjors (unregistered) in reply to akatherder

    Never, ever, say you understand something after reading a piece of it on CodeSOD. ;)

  • Mark (unregistered)

    Don't look at Visual Studio 2008, if this offends you.

    Someone at MS doesnt' get XML.

  • (cs) in reply to Grovesy
    Grovesy:
    Cloak:
    DOA:
    Thief^:
    Actually the first C++ compiler was written in C++, and was compiled in itself
    Fun exercise: Explain this concept to your grandma.

    It's like God created himself...

    badly... in the case of C++

    Ahem. <boring but true>Cfront was written in C, as far as I'm aware, at least until 2.0.</boring but true>

    Early C compilers were indeed written in a sub-set of C. Basically, they boot-strapped themselves. (Perhaps your grannie hangs around leather bars and would be excited by the concept?) I haven't looked into it, but I assume they still required a modicum of assembler on the output end in order to work on the plethora of weird chipsets available in the 1970s.

  • (cs) in reply to Watson
    Watson:
    real_aardvark:
    (For those that care, yes: the infinity in question is aleph-null. Just to be on the safe side.)
    I find it easier to index my arrays with ordinals rather than cardinals. You should try starting from ω.
    Jesus, I've got enough problems with the back-slash on this keyboard, and now you expect me to manage an omega?

    Correction accepted, however.

  • (cs) in reply to Cloak
    Cloak:
    XML/Java philosophy: if it's too slow add more hardware
    Hardware is cheap. Morons, somewhat counter-intuitively, are not.
  • Jacob Alberty (unregistered) in reply to ais523

    If XML isn't solving your problem, you need to use more XML.

  • (cs) in reply to al
    al:
    Clearly they need to encode the XML itself in XML so they can add the numbers:
    It's funny how much that resembles the Apple property list format, used throughout OS X:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
    <plist version="1.0">
    <dict>
        <key>Author</key>
        <string>William Shakespeare</string>
        <key>Lines</key>
        <array>
            <string>It is a tale told by an idiot,</string>
            <string>Full of sound and fury, signifying nothing.</string>
        </array>
        <key>Birthdate</key>
        <integer>1564</integer>
    </dict>
    </plist>
    Seriously, I can't believe how unhelpful this format is. It's like they were trying to make it a pain to traverse. On the plus side, the xsd is very, very simple.
    This is basically a direct port of the Old-style property list, which is very similar to JSON, although strings are the only supported primitive type. For example, the above plist in the old-style format would be
    {
        "Author" = "William Shakespeare";
        "Lines" =
        (
            "It is a tale told by an idiot,",
            "Full of sound and fury, signifying nothing."
        );
        "Birthdate" = "1564";
    }
  • ka2 (unregistered) in reply to akatherder

    lol

  • regeya (unregistered)

    Um...wow.

    So many levels of wrong, it hurts.

    Just a quick tip, though: If you need to convert this to something more sensible, perl's XML::Simple comes to mind, which also has a Ruby port...very flexible, makes it fairly simple to convert XML data to native data structures.

    Where you go from there, though, is anyone's guess. What the heck does one do with just addresses? Just curious.

  • GregoryD (unregistered) in reply to akatherder

    Yeah, but it has an X in front. That means it's an Xtreme Array.

  • Frenchier than thou (unregistered)

    Hey I know that style, it's been generated with Access!

    Damn thing makes up a schema for each file it generates. "Dude, making an XML file is easy, just get the data in a table and make it generate the XML from there".

  • Mr.Grep (unregistered) in reply to ais523

    Ack! That makes my brain hurt. Why even put an index on on the tag? You just loop over children of root node or write XSLT to process it. A simple xpath would give you the count of the address nodes. I could see maybe putting the sequence number on the address tag as an attribute, but that's not really necessary. Keep it simple and let the tools do the work for you. Thus:

    <AddressList>
    442 Fake St.
    61 Main St.
    ...
    3881 N 4th Ave. #5D
    </AddressList>
  • Symbiatch (unregistered)

    Well, just take a look at Finvoice (by the Finnish Banking Association). They said that they had too little time to specify it. So it's like this (contents removed):

    <SellerPartyDetails> <SellerPartyIdentifier /> <SellerOrganisationName /> <SellerOrganisationTaxCode /> </SellerPartyDetails> <SellerContactPersonName /> <SellerCommunicationDetails> <SellerEmailaddressIdentifier /> </SellerCommunicationDetails> <BuyerPartyDetails>...</BuyerPartyDetails> <InvoiceNumber /> <InvoiceDate />

    So, it's very nice that contact person and email address are not part of SellerPartyDetails, but the most obvious thing: why on earth don't they use <SellerParty><TaxCode />...</Sellerparty>? It would have two very basic benefits: it would be hierarchical, as XML should be, and it would allow software to check for addresses etc with specific tags and not use one tag for the seller, one for the buyer, third for the place of delivery etc.

    But hey, it's not like it's in use in more than one country as the official e-invoicing standard...

  • Mark Lindell (unregistered)

    XML is like violence.

    If it doesn't solve the problem, use more!

  • anonymous (unregistered)

    How do you like this?

    <Data name="XXXX"> <Data name="XX" value="XXXXX"/> <Data name="XXX" value="XXXXXX"/> </Data> <Data name="XXXXXX" value="XXXX"/> <Data name="XXXX"> <Data name="XXXX" value="XXXX"/> </Data> <Data name="XXX"> <Data name="XX" value="XXX"/> <Data name="XXXX" value="XXXXX"/> </Data>

    (I X'ed out the actual values)

    and it goes on...

  • pushedx (unregistered)

    Sadly, I've done something like this before in my code for defining map data for a game :(

    The good news was that I didn't type it by hand, I had another program generate it.

  • (cs) in reply to akatherder
    akatherder:
    Sweet, I understand XML now. It's just like an array.
    I truly hope this is sarcasm...
  • steve (unregistered)

    </rootNode> seems superfluous. I wonder if you could just delete it and everything would still work fine.

Leave a comment on “XML Abuse”

Log In or post as a guest

Replying to comment #:

« Return to Article