[redland-dev] Round tripping rdfxml forgets xmlns

Sebastian Jansen sebastian.jansen at gmail.com
Sat Sep 23 14:13:50 UTC 2006


Hi Justin,

On 9/22/06, Justin Bonnar <jbonnar at berkeley.edu> wrote:
>
> Hi Chris,
>

I guess, you mean Sebastian :-)

Thus, the foaf and rtm name space is completely forgotten or squeezed in in
> a weird way... Any hints to avoid this?
>
>
> By default, Redland doesn't store the namespace mappings in the model, and
> the rdfxml serializer doesn't do any pre-processing.  You can get around
> this by registering the namespaces you want with the serializer.  If you
> want to "pretty-print" more complex RDF/XML documents, try using the
> rdfxml-abbrev serializer instead.  I don't know Perl very well but try
> something like:
>
>   my $serializer =3D new RDF::Redland::Serializer("rdfxml-abbrev");
>   $serializer->set_namespace("foaf", "http://xmlns.com/foaf/0.1");
>   $serializer->set_namespace("rtm", "http://psi.ontopia.net/rtm/# ");
>

Ah, perfect. That's a good way to come around with my problem.

Also, the RDF/XML in your initial example isn't quiet right: you can't use
> qnames for URIs.
>

Okay, thanks. Good to know...

Sebastian

If you want to abbreviate them, you'll need to define entities in a DOCTYPE
> like as follows:
>
>   <!DOCTYPE rdf:RDF [
>       <!ENTITY rdf " http://www.w3.org/1999/02/22-rdf-syntax-ns#">
>       <!ENTITY rtm " http://psi.ontopia.net/rtm/#">
>       <!ENTITY foaf " http://xmlns.com/foaf/0.1/">]>
>
>   <rdf:RDF xmlns:rdf=3D"&rdf;" xmlns:foaf=3D"&foaf;" xmlns:rtm=3D"&rtm;">
>
>    <rdf:Description rdf:about=3D"&rdf;type">
>    <rtm:maps-to rdf:resource=3D"&rtm;instance-of"/>
>     </rdf:Description>
>
>     <rdf:Description rdf:about=3D"&foaf;name">
>       <rtm:maps-to rdf:resource=3D"&rtm;basename"/>
>     </rdf:Description>
>
>   </rdf:RDF>
>
> -Justin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/redland-dev/attachments/20060923/=
d228b8a1/attachment.htm


More information about the redland-dev mailing list