Archive pour février 2007

Palestinians in Iraq, the Great Arab Unraveling and an Introduction to Shiism

Mercredi 28 février 2007

A very good round-up by Zvi Bar’el of Haaretz about what the Palestinians are enduring in Iraq.

This is not the nation’s largest minority, but it is apparently the most persecuted. Testimony by Palestinian refugees to journalists and human rights organizations paints a very grave picture: Iraqi gangs break into Palestinian homes at night and demand the residents leave within 24 hours. In isolated cases, Palestinians have been kidnapped on the street or at work, and their bodies have been found several days later, in ditches or garbage cans.

The Iraqi Interior Ministry grants Palestinians little rest – reports indicate that severe harassment of Palestinian families is a matter of course.

Unlike the 2 million Iraqi refugees who have left their homeland, Palestinians usually carry no documents bearing witness to their Iraqi citizenship, or anything that would permit them entry into neighboring Arab states, like Jordan or Syria.

Zvi Bar’el, Refugees, twice over,

Palestinians are also part of a larger trend as Patrick Cockburn shows in The Independent:

Iraq’s minorities, some of the oldest communities in the world, are being driven from the country by a wave of violence against them because they are identified with the occupation and easy targets for kidnappers and death squads. A « huge exodus » is now taking place, according to a report by Minority Rights Group International.

The UN High Commissioner for Refugees says 30 per cent of the 1.8 million Iraqis who have fled to Jordan, Syria and elsewhere come from the minorities.

Patrick Cockburn, ‘Exodus’ of Iraq’s ancient minorities, The Independent

Meanwhile, Rami G. Khouri is predicting that the Arab world is at a historic crossroad and that the current modern Arab state order that was created by the Europeans in circa 1920 has started to break down, in what we might perhaps call the Great Arab Unraveling. He adds that the way the US is pursuing its policy in the Midlle-East produce a murky picture.

The pervasive incoherence of this bizarre picture makes it perfectly routine for Arab monarchies to support Salafist terrorists, for Western democracies to ignore the results of Arab free elections, for Iranians and Arabs, and Shiites and Sunnis, to work hand in hand while also fighting bitter wars, for Islamists and secular Arabs to join forces, for freedom lovers in London and Washington to support seasoned Arab autocrats, for Western and Arab rule-of-law advocates to sponsor militias, and for Israel and the US to perpetuate Israeli policies that exacerbate rather than calm security threats and vulnerabilities in the region.

Rami G. Khouri, Prepare for the Great Arab Unraveling, The Daily Star

There’s an excellent introduction on Shiism by Mike Shuster of NPR available as a podcast.

Mike Shuster, The Partisans of Ali: A Series Overview, NPR (mp3)

See also the reading list.

Trapping Errors with simplexml for Not Well-Formed XML

Mercredi 7 février 2007

I discovered the hard way that in PHP5 there are no obvious ways to detect if some XML is well-formed, especially if you want to deploy on Unix/Windows platform and don’t want to access the shell directly.

Adding to this problem, I discovered also that the DOM and simplexml extensions can’t use the PHP5 exception handling to trap the errors when the XML is not well-formed. Using simplexml or the DOM extensions against not well-formed XML, the errors generated by these extensions are not trapped and are displayed immediately.

It’s possible to load with the DOM or the Tidy extensions not well-formed XML, and then repair it on the fly. But what if you need to detect not well-formed XML and provide a message stating the error?

Fortunately, after some research, I found that you could use the libxml functions (PHP 5.1 and over) to test XML well formedness and trap XML errors. So, I wiped out this little function called get_xml_object (see here for the inspiration) that allow me to trap errors when simplexml is used to parse XML. The function is quite simple, by default, you provide a path to a XML file. If you want to use a string, just add another argument after the first parameter (it can’t be anything, but here’s I chose « string » for clarity sakes). You can also replace the simplexml extension by the DOM extensions if you prefer this extension to parse XML.

The function get_xml_object will return an array that contains two keys, errors and xml. In this example, $result=get_xml_object($s, "string"), $result is an array. If there are no errors, $result['errors'] will be set to null. If everything is ok, $result['xml'] will contains a simplexml object that you can then manipulate with the simplexml extension.

$s = "tag>hello world</tag>";
// $s = "<tag>hello world</tag>";

function get_xml_object ($xml, $xmlFormat="file") {

  $xml_object = null;
  $result = array ("errors" => null, "xml" => null);

  libxml_use_internal_errors (true);
  $xmlFormat == "file"  ? $xml_object = simplexml_load_file ($xml) 
                        : $xml_object = simplexml_load_string ($xml);

  if (!$xml_object) {
     $errors = libxml_get_errors();
     foreach ($errors as $error) {
         $error_msg = "Error: line: " . $error->line 
                    . ": column: " . $error->column . ": " 
                    . $error->message . "\n";
     $result["errors"] = $error_msg;
  } else {
    $result["xml"] = $xml_object;
  return $result;

$result = get_xml_object ($s, "string");

if ($result['errors']) {
  var_dump ($result['errors']);
} else {
  var_dump ($result['xml']);