Created
April 16, 2012 11:33
-
-
Save njh/2397937 to your computer and use it in GitHub Desktop.
Create RDF for a WebId using EasyRdf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/'); | |
| require_once "EasyRdf.php"; | |
| EasyRdf_Namespace::set('cert', 'http://www.w3.org/ns/auth/cert#'); | |
| $graph = new EasyRdf_Graph(); | |
| $bob = $graph->resource('https://bob.example/profile#me', 'foaf:Person'); | |
| $bob->addLiteral('foaf:name', 'Bob'); | |
| $bob->addResource('foaf:weblog', 'http://bob.example/blog'); | |
| $cert = $graph->newBNode('cert:RSAPublicKey'); | |
| $cert->addLiteral('rdfs:label', 'made on 23 November 2011 on my laptop'); | |
| $cert->add('cert:modulus', | |
| array( | |
| 'type' => 'literal', | |
| 'datatype' => 'http://www.w3.org/2001/XMLSchema#hexBinary', | |
| 'value' => 'cb24ed85d64d794b69c701c186acc059501e856000f661c93204d8380e07191c5c8b368d2ac32a428acb970398664368dc2a867320220f755e99ca2eecdae62e8d15fb58e1b76ae59cb7ace8838394d59e7250b449176e51a494951a1c366c6217d8768d682dde78dd4d55e613f8839cf275d4c8403743e7862601f3c49a6366e12bb8f498262c3c77de19bce40b32f89ae62c3780f5b6275be337e2b3153ae2ba72a9975ae71ab724649497066b660fcf774b7543d980952d2e8586200eda4158b014e75465d91ecf93efc7ac170c11fc7246fc6ded79c37780000ac4e079f671fd4f207ad770809e0e2d7b0ef5493befe73544d8e1be3dddb52455c61391a1' | |
| ) | |
| ); | |
| $cert->addLiteral('cert:exponent', 65537); | |
| $bob->add('cert:key', $cert); | |
| #print $graph->dump(); | |
| header('Content-Type: application/rdf+xml'); | |
| print $graph->serialise('rdfxml'); | |
| ?> |
Author
Author
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:cert="http://www.w3.org/ns/auth/cert#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<foaf:Person rdf:about="https://bob.example/profile#me">
<foaf:name>Bob</foaf:name>
<foaf:weblog rdf:resource="http://bob.example/blog"/>
<cert:key>
<cert:RSAPublicKey>
<rdfs:label>made on 23 November 2011 on my laptop</rdfs:label>
<cert:modulus rdf:datatype="http://www.w3.org/2001/XMLSchema#hexBinary">
cb24ed85d64d794b69c701c186acc059501e856000f661c93204d8380e07191c5c8b368d2ac32a428acb970398664368dc2a867320220f755e99ca2eecdae62e8d15fb58e1b76ae59cb7ace8838394d59e7250b449176e51a494951a1c366c6217d8768d682dde78dd4d55e613f8839cf275d4c8403743e7862601f3c49a6366e12bb8f498262c3c77de19bce40b32f89ae62c3780f5b6275be337e2b3153ae2ba72a9975ae71ab724649497066b660fcf774b7543d980952d2e8586200eda4158b014e75465d91ecf93efc7ac170c11fc7246fc6ded79c37780000ac4e079f671fd4f207ad770809e0e2d7b0ef5493befe73544d8e1be3dddb52455c61391a1
</cert:modulus>
<cert:exponent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">65537</cert:exponent>
</cert:RSAPublicKey>
</cert:key>
</foaf:Person>
</rdf:RDF>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Creates RDF, as seen in the WebId specification:
http://www.w3.org/2005/Incubator/webid/spec/#in-rdf-xml