Hi Charles,
On 16 Feb 2006, at 01:10, Charles Nepote wrote:
> Here is my code which is working well.
> function GetPrefixFromURi($uri)
> {
> $namespaces = $this->dbModel->getParsedNamespaces();
> foreach($namespaces as $namespace_URI => $namespace_prefix)
> {
> if($namespace_URI == $uri)
> {
> $return = $namespace_prefix;
> break;
> }
> }
> if(!isset($return)) $return = "";
> return $return;
> }
You can do this shorter:
function getPrefixFromURI($uri) {
$prefixes = $this->dbModel->getParsedNamespaces();
return @$prefixes[$uri];
}
(Well, this returns null instead of "" if the prefix is not declared,
but I think that's reasonable.)
> Why not include this function directly in RAP (rewritten)? I think
> getting the prefix is a very common need (am I wrong?).
You're right, it's a common need. The code above is short and self-
explanatory, I think you can use it directly without a custom function.
Best,
Richard
>
>
> Charles Nepote.
>
>
>> On 8 Feb 2006, at 00:29, Charles Nepote wrote:
>>> Hi,
>>>
>>> Using RAP 0.9.3, I would like to know the namespace for a given
>>> prefix.
>>> For exemple, I would like to know for the string "rdfs" what is
>>> the corresponding namespace ; in this exemple the answer should
>>> be :
>>> "http://www.w3.org/2000/01/rdf-schema#"
>>>
>>> Is there a ready-to-use method ? I didn't find it...
>>>
>>> Thanks,
>>> Charles Nepote
>
>
|