From: Richard C. <ri...@cy...> - 2006-03-02 09:44:58
|
Hi Shadi, On 2 Mar 2006, at 03:29, Shadi Abou-Zahra wrote: > Thanks for the feedback. The character encoding in the document =20 > headers are fine. After the query, the characters are escaped like =20 > this "\u00D0" (correct Unicode values but escaped instead of the =20 > actual characters). Set UNIC_RDF to FALSE again to avoid this. I've taken your example, saved the XML and PHP files to disk, changed =20= the URL for generateModel() to the filename, called the page from the =20= browser, and ithe bulgarian fragment is displayed correctly. (But the =20= bulgarian bit in the file that you copy&pasted into the email is =20 displayed as gibberish by my email client, so I copy&pasted it from =20 your original email where it appeared fine, and saved the file as =20 UTF-8. Not sure if this is related to the problem or just email =20 misbehaving.) Can you please verify that your version of the XML file is really =20 UTF-8 encoded? Or you could send it to me by *attaching* it to the =20 email, then I can check. Also, can you put the script onto a webserver where we can se it? Richard > Here 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 =20= > 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 =20 > 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)</=20 > 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" =20 > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en-US" =20 > lang=3D"en-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, =20 > <doc:isFeatureType>, ?type), (?id, <dc:description>, ?description), =20= > (?type, <dc:description>, ?label) USING dc FOR <http://purl.org/dc/=20 > 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(), =20= > "label" =3D> $feature["?label"]->getLabel(), "description" =3D> = $feature=20 > ["?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, >> On 1 Mar 2006, at 11:25, Shadi Abou-Zahra wrote: >>> Hi, >>> >>> Does RAP support non-ASCII characters in XML literals and if so, =20 >>> how? >> Yes, RAP can do that. But, as always, getting anything beyond US-=20 >> ASCII to work can be a serious pain. >> It's all a question of getting the character encoding right. By =20 >> default, RAP assumes all data to be UTF-8 encoded. If your data is =20= >> not UTF-8 encoded, then you either have to convert it to UTF-8 =20 >> (recommended) or set DEFAULT_ENCODING in constants.php to the =20 >> encoding of your data (For the cyrillic alphabet, try "iso-8859-5" =20= >> or "windows-1251"). >> Make sure that all your XML files start with an xml declaration =20 >> (e.g. "<?xml version=3D"1.0" encoding=3D"UTF-8"?>", or whatever =20 >> encoding you're using instead of UTF-8). RAP-generated XML files =20 >> will have this automatically. >> 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 =20= >> if all RAP-generated HTML has this. >> RAP can't convert between different encodings, and can't combine =20 >> RDF input from different encodings. That's why I always recommend =20 >> doing everything in UTF-8. Most other encodings lack some =20 >> characters that some people will need. >> If this doesn't help, could you please provide a more complete =20 >> example of what you're doing and where it doesn't work. >> Yours, >> Richard >>> 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 api/=20= >>> constants.php) but that did not help. This is what is returned: >>> >>> >>> <span lang=3D\\"bg\\">\u00D0\u0091\u00D1\u008A\u00D0\u00BB\u00D0=20 >>> \u00B3\u00D0\u00B0\u00D1\u0080\u00D1\u0081\u00D0\u00BA\u00D0=20 >>> \u00B8</span> (Bulgarian) >>> >>> >>> Thanks, >>> Shadi >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by xPML, a groundbreaking =20 >>> scripting language >>> that extends applications into web and mobile media. Attend the =20 >>> live 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 > Lieber Querschnitt als Durchschnitt - Peter Laisacher, =20 > Salzburger Rugby Bulls > |