W3C home > Mailing lists > Public > public-multilingualweb-lt@w3.org > November 2012

XHTML Namespace problems with PHP

From: Pablo Nieto Caride <pablo.nieto@linguaserve.com>
Date: Thu, 22 Nov 2012 19:39:36 +0100
To: "Jirka Kosek" <jirka@kosek.cz>
Cc: <public-multilingualweb-lt@w3.org>
Message-ID: <149001cdc8e0$b90d52a0$2b27f7e0$@linguaserve.com>
Hi Jirka, all,

 

With respect to the problem I explained at Lyon regarding PHP and the use of
XHTML namespaces, I’ve been doing a little research and I found this bug:
loadHTML doesn't use XHTML namespace https://bugs.php.net/bug.php?id=38538  

 

The problem is that when you try to load an HTML with the functions
loadHTMLFile  or loadHTML, even if you register the namespace, when doing
the xpath query with the NS h, it doesn’t work. So e.g. for the html
translate example number 1 of the Test Suite, a simple code like the
following won’t work.

 

$dom->loadHTMLFile(translate1html.html);

 

$xpath = new DOMXPath($dom);

$xpath->registerNamespace('h', 'http://www.w3.org/1999/xhtml');

$query = '//h:code';

$nodes = $xpath->query($query);

 

If I use $dom->load(translate1html.html); instead of loadHTMLFile, it works
but unlike loading HTML, XML has to be well-formed to load. So with lines
like <meta charset=utf-8> the parser won’t work unless it’s well-formed
<meta charset="utf-8"/>

 

I don’t know if somebody has encountered the same problem, in that case, is
there a solution? I can’t find any apart from removing the namespaces when
doing the xpath query. I read also that a solution might be turn the HTML
into XHTML with the PHP Tidy extension, but I’m not sure.

 

Any help will be welcome. Thanks!

__________________________________

Pablo Nieto Caride

Dpto. Técnico/I+D+i

Linguaserve Internacionalización de Servicios, S.A.

Tel.: +34 91 761 64 60 ext. 0422
Fax: +34 91 542 89 28 

E-mail:  <mailto:pablo.nieto@linguaserve.com> pablo.nieto@linguaserve.com

 <http://www.linguaserve.com/> www.linguaserve.com

 

«En cumplimiento con lo previsto con los artículos 21 y 22 de la Ley
34/2002, de 11 de julio, de Servicios de la Sociedad de Información y
Comercio Electrónico, le informamos que procederemos al archivo y
tratamiento de sus datos exclusivamente con fines de promoción de los
productos y servicios ofrecidos por LINGUASERVE INTERNACIONALIZACIÓN DE
SERVICIOS, S.A. En caso de que Vdes. no deseen que procedamos al archivo y
tratamiento de los datos proporcionados, o no deseen recibir comunicaciones
comerciales sobre los productos y servicios ofrecidos, comuníquenoslo a
clients@linguaserve.com, y su petición será inmediatamente cumplida.»

 

"According to the provisions set forth in articles 21 and 22 of Law 34/2002
of July 11 regarding Information Society and eCommerce Services, we will
store and use your personal data with the sole purpose of marketing the
products and services offered by LINGUASERVE INTERNACIONALIZACIÓN DE
SERVICIOS, S.A. If you do not wish your personal data to be stored and
handled, or you do not wish to receive further information regarding
products and services offered by our company, please e-mail us to
clients@linguaserve.com. Your request will be processed immediately.”

__________________________________
Received on Thursday, 22 November 2012 18:40:04 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 9 June 2013 00:25:03 UTC