Idiotic idiom

quidity on 2002-06-22T00:07:20

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?


Well...

darobin on 2002-06-22T15:10:32

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.

Perl & XML

Odud on 2002-06-24T08:56:09

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.

Re:Perl & XML

darobin on 2002-06-24T11:46:46

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.