From: Shadi Abou-Z. <sh...@ab...> - 2006-03-02 02:29:46
|
Hi Richard, Thanks for the feedback. The character encoding in the document headers a= re fine. After the query, the characters are escaped like this "\u00D0" (= correct Unicode values but escaped instead of the actual characters). Her= e is a more complete example: *** DATA: <http://www.example.org/data.rdf> <?xml version=3D"1.0" encoding=3D"UTF-8"?> <rdf:RDF xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:doc=3D"http://www.example.org/my/schema#" xmlns:dc=3D"http://purl.org/dc/elements/1.1/"> <doc:featureType rdf:ID=3D"lang"> <dc:title rdf:parseType=3D"Literal">Language</dc:title> <dc:description rdf:parseType=3D"Literal">The natural language of the= document.</dc:description> </doc:featureType> <doc:feature rdf:ID=3D"bg"> <dc:title rdf:parseType=3D"Literal">Bulgarian</dc:title> <dc:description rdf:parseType=3D"Literal"><span lang=3D"bg">=C3=90=E2= =80=98=C3=91=C5=A0=C3=90=C2=BB=C3=90=C2=B3=C3=90=C2=B0=C3=91=E2=82=AC=C3=91= =C2=81=C3=90=C2=BA=C3=90=C2=B8</span> (Bulgarian)</dc:description> <doc:isFeatureType rdf:resource=3D"#lang"/> </doc:feature> </rdf:RDF> *** PAGE: <http://www.example.org/data.php> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww= w.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en-US" lang=3D"e= n-US"> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8= " /> <title>Document Features</title> </head> <?php /* include libraries */ define("RDFAPI_INCLUDE_DIR", "/usr/local/lib/php/rdfapi-php/api/"); include(RDFAPI_INCLUDE_DIR . "RdfAPI.php"); include(RDFAPI_INCLUDE_DIR . "syntax/RdfParser.php"); $parser =3D new RdfParser(); $DB =3D $parser->generateModel("http://www.example.org/data.rdf"); function getFeatureList($DB) { /* build RDQL query */ $query =3D "SELECT ?id, ?label, ?description WHERE (?id, <doc:isFeatu= reType>, ?type), (?id, <dc:description>, ?description), (?type, <dc:descr= iption>, ?label) USING dc FOR <http://purl.org/dc/elements/1.1/> doc FOR = <http://www.example.org/my/schema#>"; /* send query to database */ $resultSet =3D $DB->rdqlQueryasIterator($query); /* array of results */ $features =3D array(); while($resultSet->hasNext()) { $feature =3D $resultSet->next(); /* build array of results */ $features[] =3D array("id" =3D> $feature["?id"]->getLocalName(), "l= abel" =3D> $feature["?label"]->getLabel(), "description" =3D> $feature["?= description"]->getLabel()); } return $features; } ?> <body> <dl> <?php $type =3D ""; $features =3D getFeatureList($DB); foreach($features as $feature) { if($type !=3D $feature["label"]) { if($type !=3D "") { ?> </ul></dd> <?php } $type =3D $feature["label"]; ?> <dt><?php printf($feature["label"]); ?></dt> <dd><ul> <?php } ?> <li><?php printf($feature["description"]); ?></li> <?php } if($type !=3D "") { ?> </ul></dd> <?php } ?> </dl> </body> </html> Richard Cyganiak wrote: > Hi Shadi, >=20 > On 1 Mar 2006, at 11:25, Shadi Abou-Zahra wrote: >=20 >> Hi, >> >> Does RAP support non-ASCII characters in XML literals and if so, how? >=20 > Yes, RAP can do that. But, as always, getting anything beyond US-ASCII=20 > to work can be a serious pain. >=20 > It's all a question of getting the character encoding right. By default= ,=20 > RAP assumes all data to be UTF-8 encoded. If your data is not UTF-8=20 > encoded, then you either have to convert it to UTF-8 (recommended) or=20 > set DEFAULT_ENCODING in constants.php to the encoding of your data (For= =20 > the cyrillic alphabet, try "iso-8859-5" or "windows-1251"). >=20 > Make sure that all your XML files start with an xml declaration (e.g.=20 > "<?xml version=3D"1.0" encoding=3D"UTF-8"?>", or whatever encoding you'= re=20 > using instead of UTF-8). RAP-generated XML files will have this=20 > automatically. >=20 > If you output HTML, make sure it has this inside the <title> element: > <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8= "> > (or whatever encoding you're using instead of UTF-8). I'm not sure if=20 > all RAP-generated HTML has this. >=20 > RAP can't convert between different encodings, and can't combine RDF=20 > input from different encodings. That's why I always recommend doing=20 > everything in UTF-8. Most other encodings lack some characters that som= e=20 > people will need. >=20 > If this doesn't help, could you please provide a more complete example=20 > of what you're doing and where it doesn't work. >=20 > Yours, > Richard >=20 >=20 >=20 >=20 >> For example, to query and output the following information: >> >> >> <dc:description rdf:parseType=3D"Literal"><span=20 >> lang=3D"bg">=D0=91=D1=8A=D0=BB=D0=B3=D0=B0=D1=80=D1=81=D0=BA=D0=B8</sp= an> (Bulgarian)</dc:description> >> >> >> Note: I've tried setting the "UNIC_RDF" constant to FALSE (in=20 >> api/constants.php) but that did not help. This is what is returned: >> >> >> <span=20 >> lang=3D\\"bg\\">\u00D0\u0091\u00D1\u008A\u00D0\u00BB\u00D0\u00B3\u00D0= \u00B0\u00D1\u0080\u00D1\u0081\u00D0\u00BA\u00D0\u00B8</span>=20 >> (Bulgarian) >> >> >> Thanks, >> Shadi >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by xPML, a groundbreaking scripting=20 >> language >> that extends applications into web and mobile media. Attend the live=20 >> webcast >> and join the prime developer group breaking into this new coding=20 >> territory! >> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=110944&bid$1720&dat=1216= 42 >> _______________________________________________ >> Rdfapi-php-interest mailing list >> Rdf...@li... >> https://lists.sourceforge.net/lists/listinfo/rdfapi-php-interest >> >=20 >=20 --=20 Lieber Querschnitt als Durchschnitt=20 - Peter Laisacher, Salzburger Rugby Bulls |