| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| RDF Details |
| |
| <p> |
| Juneau supports serializing and parsing arbitrary POJOs to and from the following RDF formats: |
| </p> |
| <ul> |
| <li>RDF/XML |
| <li>Abbreviated RDF/XML |
| <li>N-Triple |
| <li>Turtle |
| <li>N3 |
| </ul> |
| |
| <p> |
| The serializers and parsers work identically to those in <c>juneau-marshall</c>, but are |
| packaged separately so that you don't need to pull in the Jena dependency unless you need it. |
| </p> |
| |
| <p class='bpcode w800'> |
| <jc>// A simple bean</jc> |
| <jk>public class</jk> Person { |
| <jk>public</jk> String name = <js>"John Smith"</js>; |
| <jk>public int</jk> age = 21; |
| } |
| |
| <jc>// Serialize a bean to JSON, XML, or HTML</jc> |
| Person p = <jk>new</jk> Person(); |
| |
| <jc>// Produces: |
| // <rdf:RDF |
| // xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
| // xmlns:jp="http://www.apache.org/juneaubp/" |
| // xmlns:j="http://www.apache.org/juneau/"> |
| // <rdf:Description> |
| // <jp:name>John Smith</jp:name> |
| // <jp:age>21</jp:age> |
| // </rdf:Description> |
| // </rdf:RDF></jc> |
| String rdfXml = RdfSerializer.<jsf>DEFAULT_XMLABBREV</jsf>.serialize(p); |
| |
| <jc>// Produces: |
| // @prefix jp: <http://www.apache.org/juneaubp/> . |
| // @prefix j: <http://www.apache.org/juneau/> . |
| // [] jp:age "21" ; |
| // jp:name "John Smith" .</jc> |
| String rdfN3 = N3Serializer.<jsf>DEFAULT</jsf>.serialize(p); |
| |
| <jc>// Produces: |
| // _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/name> "John Smith" . |
| // _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/age> "21" .</jc> |
| String rdfNTriple = RdfSerializer.<jsf>DEFAULT_NTRIPLE</jsf>.serialize(p); |
| </p> |