Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

quidity (1296)

  (email not shown publicly)

A relapsing reformed physicist.

Journal of quidity (1296)

Friday June 21, 2002
07:07 PM

Idiotic idiom

[ #5851 ]

I was reading an article about something we've all done at least once (written a web based forum), by using Perl and XML, where I came accross this quote:

In XML, it's traditional to use id as a unique identifier across all elements, regardless of type. That means having a thread with id="1" and a post with id="1" is forbidden. I want to keep the two separate, each with its own counting scheme, so I used different attributes.

That strikes me as being stupid. It seems like a hack to dodge some underlying problem with XML, or inherited tradition that pupports to make things easy by actually making things hard. After all, how do I guess if I'm using id or num to refer to my uniquue identifiers today?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Well... (Score:3, Informative)

    by darobin (1316) on 2002.06.22 10:10 (#9901) Homepage Journal

    It's unfortunate but it's the kind of technical mistake and general imprecision which frequently plagues Erik's stuff, though he can otherwise be good.

    To boot the example is invalid because XML IDs can't start with a number, they have to be valid names.

    And that pretty much solves the problem. Use a "t" prefix for threads, a "p" prefix for posts... That is, if you need to use IDs for threads which I'm thinking is probably rather useless as XML's hierarchical nature could make that unnecessary. And putting all posts in the same document is probably a bad idea, so posts and threads should probably not be together anyway.

    I could go on and on, the point is that whenever a technology is misused, you're bound to see that kind of mismatch.

    He not dodging a problem with XML, he's dodging his own ignorance of XML.


    -- Robin Berjon []

    • How would you rate the book then? It's was on my wanted list but now I'm not so sure - particularly if there are many technical errors.
      • It depends on your needs. The book doesn't have too many technical errors (though I did catch a few that couldn't be fixed in time unfortunately). It's a good introduction and overview of Perl and XML if you have little or no knowledge of that domain already. If however you do know about Perl and XML then you probably don't need the book as it'll be too simple.


        -- Robin Berjon []