Author: stain Date: Mon Nov 21 14:03:42 2016 New Revision: 1001425 Log: RDF introduction
Added: websites/production/commonsrdf/content/images/rdf-01.svg websites/production/commonsrdf/content/images/rdf-02.svg websites/production/commonsrdf/content/introduction.html Added: websites/production/commonsrdf/content/images/rdf-01.svg ============================================================================== --- websites/production/commonsrdf/content/images/rdf-01.svg (added) +++ websites/production/commonsrdf/content/images/rdf-01.svg Mon Nov 21 14:03:42 2016 @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<!-- +To edit, use https://www.draw.io/ +When saving, use +File -> Export as -> SVG + Zoom: 100% + (x) Transparent background + (x) Include a copy of the diagram +--> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="425px" height="136px" version="1.1" content="<mxfile userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36" version="6.0.1.5" editor="www.draw.io" type="google"><diagram>7VdNc5swEP01HNsBhIl9DI7dHNqZzuTQ9CgLGdQIxAj5K7++K7MCYxvbSTs5JZdIT7srad/bFfbItNh+07TKf6iUSy/0061HHrwwDMgkhn8W2TXInT9pgEyLFI064Em8cgR9RFci5XXP0Cgljaj6IFNlyZnpYVRrtembLZXs71rRjJ8AT4zKU/SXSE3eoOMw7vBHLrLc7RzEeL+COmO8SZ3TVG0OIDLzyFQrZZpRsZ1yaZPn8tL4zQdW24NpXppbHMLGYU3lCu/mhTEtKo8kEgIkiVq0QGYBPLbZuVxAPEg7TJJNLgx/qiizKxtgHrDcFBJmgY1HF1wmlL1kWq3KdKqk0rBUqtI6L4WUDvJCMp/Pkvmd3VTTVMBlemv3yXRufVRp5rQQ0srokcs1N4JRXEDVBATnBwH8/R/gVIqsBIzBBhwWk5aOoL3qmmvDt4PpDVrSQO1cFdzoHZigw8jxjEIPSdTMN51sAmeTH0hmjBhFpWZt6I5MGCCf57klp1ylIGOcKm1ylamSylmHJmyl1zzFBOx5amdMFYLB2O/TCpnQu2fE95PfOKkN1ebelltH8x6bC3tmdEidBZO0 ru0OFkQTu8EfbswO2aQrowDqzv5dqQrtaqPVCz+geTEeRSO/XXGVGv4P5fCtMM8uAzB2dz6S8XLMOGNXxd8QZdnp6axWK80QwtYC6cu46dXu7WokzsWp0Y+GVYZRfioBwYdDRHE/RHNm9DpsPEeBoslAZbhAzU1PAoFa6O7ArLIG9RsOjHceOteIjC/Zw6A5QVeBbZ5vKsroSsN9Ke3rdLnlQj8y/SLUvBavdLE3sDLErID1KPFGD+dane1roHl5jwuFSNN9C7jSp88UyGAlnaucwa6KjzXeonsiD/VNLurb/+r78V2Pvi/IvuaSGrHu19cNsndhgiOZq+Wy5uZIGW/VwuhTC/+ghcu9LiJBTwjB5MKL+pGkx1dIBw6g539+c737myv8wG8umHbf6o0Yul88ZPYX</diagram></mxfile>"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffebf7-1-ffabcf-1-s-0"><stop offset="0%" style="stop-color:#FFEBF7"/><stop offset="100%" style="stop-color:#FFABCF"/></linearGradient></defs><g transform="translate(0.5,0.5)"><ellipse cx="361" cy="91" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="361" cy="91" rx="60" ry="40" fill="url(#mx-gradient-ffebf7-1-ffabcf-1-s-0)" stroke="#000000" pointer-events="none"/><g transform="translate(341.5,84.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="38" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 40px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><Bob></div></div></foreignObject><text x="19" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Bob&gt;</text></switch></g><path d="M 103 63 Q 103 21 211 21 Q 319 21 319 54.76" fill="none" stroke="#b85450" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><path d="M 319 60.76 L 315 52.76 L 319 54.76 L 323 52.76 Z" fill="#b85450" stroke="#b85450" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><g transform="transl ate(186.5,0.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="52" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><knows></div></div></foreignObject><text x="26" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;knows&gt;</text></switch></g><ellipse cx="61" cy="91" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="61" cy="91" rx="60" ry="40" fill="url(#mx-gradient-ffebf7-1-ffabcf-1-s-0)" stroke="#000000" pointer-events="none"/><g transform="translate(38.5,84.5)"><switch><foreignObject style="o verflow:visible;" pointer-events="all" width="44" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 44px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><Alice></div></div></foreignObject><text x="22" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Alice&gt;</text></switch></g></g></svg> Added: websites/production/commonsrdf/content/images/rdf-02.svg ============================================================================== --- websites/production/commonsrdf/content/images/rdf-02.svg (added) +++ websites/production/commonsrdf/content/images/rdf-02.svg Mon Nov 21 14:03:42 2016 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<!-- +To edit, use https://www.draw.io/ +When saving, use +File -> Export as -> SVG + Zoom: 100% + (x) Transparent background + (x) Include a copy of the diagram +Then re-insert these comments in the replaced SVG. +--> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="665px" height="415px" version="1.1" content="<mxfile userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36" version="6.0.1.6" editor="www.draw.io" type="device"><diagram>7VpLc+I4EP41HCdlWX4eAwk7h5mqqcpW7exR2MJoIyxKFq/59Sth2UYmfkCATGXMJVZLaj366+7PHY/gZLn7i6PV4juLMR3ZVrwbwaeRbQMALflHSfa5JHC9XJBwEutBleCF/MJaqOclaxLjzBgoGKOCrExhxNIUR8KQIc7Z1hw2Z9RcdYUSfCJ4iRA9lf5DYrHQp7C9Sv4Vk2RRrAy8MO+Zoeg14Wyd6vVGNpwffnn3EhW69EGzBYrZ9kgEn0dwwhkT+dNyN8FU3W1xbfm8aUNvuW+OU9Fngp1P2CC6xsWOPbRcjeCYSgXjMZuVgkQJ9LbFvrgqqU9aRTbG2wUR+GWFItWzlcCQsoVYUtkCSh+aYTou72fCKOOyK2WpmjwnlBYieWnT6fN46qtFOYqJPIzR9zieTNUcloopWhKqUPYV0w0WJEK6Q4MKQN0+UmAdflKOKElSKYvkAlh2jktzgPKoG8wF3jVeLyiNJp0BsyUWfC+H6AnQ13bWfmBDmLe3FapAgYXFEaICLUMayEmpujKmfND2fNu28NRWsUS5bjIuFixhKaLPlXQcrfkGx/oCDnYqWxFbkkg+W6ZZ 5U3w/U8tPzT+1Y1MIC4elTdWZj7IpkTtWU+IixERRVmmVlBCPUQt8B8WYq+tidaCSVG192+MrfS4THD2io/MPAtcx7XKnsKR7WsgB++I+FncgHwuzlyD8TyIcBR1gj83lLKOgbOMrXmkRTryyOtLsDB8tz8agW+baLRgM8q0lh+MSOXNKhzXVJHvWc86Djw1RdBp8IxCUX7SE0USLWh/NGylBmRnbFifuXFfQdA2Xj7kO6g8sLznXk7pdATc11Qlr/aQK+ORMJ2Q44z8QrPDAAVDfStytDseuU9vhToV1yTm6aPuWJI4PoSAjjj9hoM0etJbntMYVXUu16eoUuQxvmErvq0Hy/J8w3xftPU5pkiQjelfPWBfqAGeOYXN5xkWNWSciwV3wMI7sNAe6+wAGEAAQfh7GN3rMLq0gYz5A+e6mHN9JOXyO4w7WSBOyWDeK1Jq6Ib3s28wUOq7UmpwZ0rtn02pazQWAv9sSl1X4dYyVW9KXRRZmhQ1UOoLklg4MJd3MJfgU7HYomY3gOEGNBYC06ftoH98ua3VQYfVp4yJGVJzPoDrxAgH8+j2fOYkQXpRgGfz6zAdD3wgkwX2H051Skt+XPWwRPFFVKc/0JwaAwFh/9TSoOKknNeXxHg1EnOrumDTmfvuqzb+3XVBADvi6Yqi/ZBFG7Oo/bk4VVeZeEDD5ZzKdULTlf3fhVN1FYT/xmlKusw+MKrmonBoBn3Xsu7IqLy7MKo/gTdZD47bXiXqSZ2Uhh+YE2lMBcWnKvKcWzkqfPcMel8r+/jBuaSrpsGxayjty7ls32tXdL3CEeiqkA+JrTWxeZ+L5gQDGm5Gc2xofskAw/5fe9zW6uGQCO/zv5K+WbAowpQVmUNB4sHtlw39a2RDGJg5yLPd3mgtXundGrvzLsyHXi0f+k7tBeFKNQjXridwv3Vf9fGuY3zc+e4ahN1VyR/CcWs4Du+dnHeFGjPSf4E137lK2La7Kv4DOi5P1k7tz dRpe+O8Iwpks/oYPR9effEPn/8H</diagram></mxfile>"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffebf7-1-ffabcf-1-s-0"><stop offset="0%" style="stop-color:#FFEBF7"/><stop offset="100%" style="stop-color:#FFABCF"/></linearGradient></defs><g transform="translate(0.5,0.5)"><ellipse cx="361" cy="103" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="361" cy="103" rx="60" ry="40" fill="url(#mx-gradient-ffebf7-1-ffabcf-1-s-0)" stroke="#000000" pointer-events="none"/><g transform="translate(341.5,96.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="38" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 40px; white-space: nowrap; word-wrap: normal; text-align: center ;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><Bob></div></div></foreignObject><text x="19" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Bob&gt;</text></switch></g><path d="M 103 75 Q 103 33 211 33 Q 319 33 319 66.76" fill="none" stroke="#b85450" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><path d="M 319 72.76 L 315 64.76 L 319 66.76 L 323 64.76 Z" fill="#b85450" stroke="#b85450" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(186.5,12.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="52" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><knows></div></div></foreignObject><text x="26" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;knows&gt;</text></switch></g><ellipse cx="61" cy="103" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="61" cy="103" rx="60" ry="40" fill="url(#mx-gradient-ffebf7-1-ffabcf-1-s-0)" stroke="#000000" pointer-events="none"/><g transform="translate(38.5,96.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="44" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 44px; white-space: nowrap; word-wrap: normal; text-align: center;"><di v xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><Alice></div></div></foreignObject><text x="22" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Alice&gt;</text></switch></g><ellipse cx="361" cy="229" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="361" cy="229" rx="60" ry="40" fill="url(#mx-gradient-ffebf7-1-ffabcf-1-s-0)" stroke="#000000" pointer-events="none"/><g transform="translate(332.5,222.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="56" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 58px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns=" http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><Charlie></div></div></foreignObject><text x="28" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Charlie&gt;</text></switch></g><path d="M 103 131 Q 319 131 319 192.76" fill="none" stroke="#b85450" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><path d="M 319 198.76 L 315 190.76 L 319 192.76 L 323 190.76 Z" fill="#b85450" stroke="#b85450" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(221.5,110.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="52" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><knows></div></div></foreignObject><text x="26" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;knows&gt;</text></switch></g><ellipse cx="601" cy="103" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="601" cy="103" rx="60" ry="40" fill="#dae8fc" stroke="#6c8ebf" pointer-events="none"/><g transform="translate(569.5,96.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="62" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 62px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style ="display:inline-block;text-align:inherit;text-decoration:inherit;"><Football></div></div></foreignObject><text x="31" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Football&gt;</text></switch></g><path d="M 371 63 Q 371 21 479 21 Q 587 21 587 54.76" fill="none" stroke="#6c8ebf" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><path d="M 587 60.76 L 583 52.76 L 587 54.76 L 591 52.76 Z" fill="#6c8ebf" stroke="#6c8ebf" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(457.5,0.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="46" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1 999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><plays></div></div></foreignObject><text x="23" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;plays&gt;</text></switch></g><ellipse cx="281" cy="370" rx="60" ry="40" fill="#000000" stroke="#000000" transform="translate(2,3)" opacity="0.25"/><ellipse cx="281" cy="370" rx="60" ry="40" fill="#dae8fc" stroke="#6c8ebf" pointer-events="none"/><g transform="translate(254.5,363.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="52" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 54px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;te xt-align:inherit;text-decoration:inherit;"><Tennis></div></div></foreignObject><text x="26" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;Tennis&gt;</text></switch></g><path d="M 55 143 Q 55 237 168 237 Q 281 237 281 321.76" fill="none" stroke="#6c8ebf" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><path d="M 281 327.76 L 277 319.76 L 281 321.76 L 285 319.76 Z" fill="#6c8ebf" stroke="#6c8ebf" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(146.5,216.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="46" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="di splay:inline-block;text-align:inherit;text-decoration:inherit;"><plays></div></div></foreignObject><text x="23" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;plays&gt;</text></switch></g><path d="M 403 257 Q 451 257 451 313.5 Q 451 370 349.24 370" fill="none" stroke="#6c8ebf" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><path d="M 343.24 370 L 351.24 366 L 349.24 370 L 351.24 374 Z" fill="#6c8ebf" stroke="#6c8ebf" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(398.5,303.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="46" height="13" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 13px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.or g/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;"><plays></div></div></foreignObject><text x="23" y="13" fill="#000000" text-anchor="middle" font-size="13px" font-family="Helvetica">&lt;plays&gt;</text></switch></g></g></svg> Added: websites/production/commonsrdf/content/introduction.html ============================================================================== --- websites/production/commonsrdf/content/introduction.html (added) +++ websites/production/commonsrdf/content/introduction.html Mon Nov 21 14:03:42 2016 @@ -0,0 +1,716 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia at 21 November 2016 + | Rendered using Apache Maven Fluido Skin 1.3.0 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20161121" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Commons RDF – Introduction to RDF using Commons RDF</title> + + <link rel="stylesheet" href="./css/bootstrap.min.css" type="text/css" /> + <link rel="stylesheet" href="./css/site.css" type="text/css" /> + <link rel="stylesheet" href="./css/print.css" media="print" /> + + <script type="text/javascript" src="./js/jquery.min.js"></script> + <script type="text/javascript" src="./js/bootstrap.min.js"></script> + <script type="text/javascript" src="./js/prettify.min.js"></script> + <script type="text/javascript" src="./js/site.js"></script> + + +<link rel="stylesheet" href="./css/prettify.css" media="all" type="text/css"/> +<script src="./js/prettify.js" type="text/javascript"></script> +<script type="text/javascript">window.onload=function() { + prettyPrint(); + }</script> + </head> + + <body class="composite"> + <a href="http://commonsrdf.incubator.apache.org/" id="bannerLeft" title="Apache Commons RDF logo"> + <img class="logo-left" src="images/commonsrdf-logo.png" alt="Apache Commons RDF logo"/> + </a> + <div class="clear"></div> + + <div class="navbar"> + <div class="navbar-inner"> + <div class="container-fluid"> + <a class="brand" href="https://commonsrdf.incubator.apache.org/">Commons RDF ™</a> + <ul class="nav"> + + <li id="publishDate">Last Published: 21 November 2016</li> + <li class="divider">|</li> <li id="projectVersion">Version: 0.4.0-incubating-SNAPSHOT</li> + </ul> + <div class="pull-right"> <ul class="nav"> + <li> + <a href="http://www.apachecon.com/" class="externalLink" title="ApacheCon"> + ApacheCon</a> + </li> + <li> + <a href="http://www.apache.org" class="externalLink" title="Apache"> + Apache</a> + </li> + <li> + <a href="http://commons.apache.org/" class="externalLink" title="Commons"> + Commons</a> + </li> + <li> + <a href="http://incubator.apache.org/" class="externalLink" title="Incubator"> + Incubator</a> + </li> + </ul> +</div> + </div> + </div> + </div> + + <div class="container-fluid"> + <table class="layout-table"> + <tr> + <td class="sidebar"> + <div class="well sidebar-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Project</li> + <li class="none"> + <a href="index.html" title="Home"> + Home</a> + </li> + <li class="none"> + <a href="apidocs/index.html?org/apache/commons/rdf/api/package-summary.html" title="API"> + API</a> + </li> + <li class="none"> + <a href="implementations.html" title="Implementations"> + Implementations</a> + </li> + <li class="none"> + <a href="userguide.html" title="User Guide"> + User Guide</a> + </li> + <li class="none"> + <a href="download.html" title="Download"> + Download</a> + </li> + <li class="none"> + <a href="contributing.html" title="Contributing"> + Contributing</a> + </li> + <li class="none"> + <a href="team-list.html" title="Team"> + Team</a> + </li> + </ul> + <ul class="nav nav-list"> + <li class="nav-header">Tools</li> + <li class="none"> + <a href="mail-lists.html" title="Mailing Lists"> + Mailing Lists</a> + </li> + <li class="none"> + <a href="https://git-wip-us.apache.org/repos/asf/incubator-commonsrdf.git" class="externalLink" title="Source (Git)"> + Source (Git)</a> + </li> + <li class="none"> + <a href="https://github.com/apache/incubator-commonsrdf/" class="externalLink" title="Source (GitHub mirror)"> + Source (GitHub mirror)</a> + </li> + <li class="none"> + <a href="https://issues.apache.org/jira/browse/COMMONSRDF" class="externalLink" title="Issues (Jira)"> + Issues (Jira)</a> + </li> + </ul> + <ul class="nav nav-list"> + <li class="nav-header">Modules</li> + <li class="none"> + <a href="api/index.html" title="Commons RDF API"> + Commons RDF API</a> + </li> + <li class="none"> + <a href="simple/index.html" title="Commons RDF impl: Simple"> + Commons RDF impl: Simple</a> + </li> + <li class="none"> + <a href="rdf4j/index.html" title="Commons RDF impl: RDF4j"> + Commons RDF impl: RDF4j</a> + </li> + <li class="none"> + <a href="jena/index.html" title="Commons RDF impl: Jena"> + Commons RDF impl: Jena</a> + </li> + <li class="none"> + <a href="jsonld-java/index.html" title="Commons RDF impl: JSON-LD Java"> + Commons RDF impl: JSON-LD Java</a> + </li> + <li class="none"> + <a href="commons-rdf-integration-tests/index.html" title="Commons RDF Integration tests"> + Commons RDF Integration tests</a> + </li> + </ul> + <ul class="nav nav-list"> + <li class="nav-header"><i class="icon-info-sign"></i>Project Documentation</li> + <li class="collapsed"> + <a href="project-info.html" title="Project Information"> + Project Information</a> + </li> + <li class="collapsed"> + <a href="project-reports.html" title="Project Reports"> + Project Reports</a> + </li> + </ul> + <ul class="nav nav-list"> + <li class="nav-header">Commons</li> + <li class="none"> + <a href="http://commons.apache.org/" class="externalLink" title="Home"> + Home</a> + </li> + <li class="none"> + <a href="http://www.apache.org/licenses/" class="externalLink" title="License"> + License</a> + </li> + <li class="collapsed"> + <a href="http://commons.apache.org/components.html" class="externalLink" title="Components"> + Components</a> + </li> + <li class="collapsed"> + <a href="http://commons.apache.org/sandbox/index.html" class="externalLink" title="Sandbox"> + Sandbox</a> + </li> + <li class="collapsed"> + <a href="http://commons.apache.org/dormant/index.html" class="externalLink" title="Dormant"> + Dormant</a> + </li> + </ul> + <ul class="nav nav-list"> + <li class="nav-header">General Information</li> + <li class="none"> + <a href="http://commons.apache.org/security.html" class="externalLink" title="Security"> + Security</a> + </li> + <li class="none"> + <a href="http://commons.apache.org/volunteering.html" class="externalLink" title="Volunteering"> + Volunteering</a> + </li> + <li class="none"> + <a href="http://commons.apache.org/patches.html" class="externalLink" title="Contributing Patches"> + Contributing Patches</a> + </li> + <li class="none"> + <a href="http://commons.apache.org/building.html" class="externalLink" title="Building Components"> + Building Components</a> + </li> + <li class="none"> + <a href="http://commons.apache.org/commons-parent-pom.html" class="externalLink" title="Commons Parent Pom"> + Commons Parent Pom</a> + </li> + <li class="none"> + <a href="http://commons.apache.org/build-plugin/index.html" class="externalLink" title="Commons Build Plugin"> + Commons Build Plugin</a> + </li> + <li class="none"> + <a href="http://commons.apache.org/releases/index.html" class="externalLink" title="Releasing Components"> + Releasing Components</a> + </li> + <li class="none"> + <a href="http://wiki.apache.org/commons/FrontPage" class="externalLink" title="Wiki"> + Wiki</a> + </li> + </ul> + <ul class="nav nav-list"> + <li class="nav-header">ASF</li> + <li class="none"> + <a href="http://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How the ASF works"> + How the ASF works</a> + </li> + <li class="none"> + <a href="http://www.apache.org/foundation/getinvolved.html" class="externalLink" title="Get Involved"> + Get Involved</a> + </li> + <li class="none"> + <a href="http://www.apache.org/dev/" class="externalLink" title="Developer Resources"> + Developer Resources</a> + </li> + <li class="none"> + <a href="http://www.apache.org/foundation/policies/conduct.html" class="externalLink" title="Code of Conduct"> + Code of Conduct</a> + </li> + <li class="none"> + <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"> + Sponsorship</a> + </li> + <li class="none"> + <a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"> + Thanks</a> + </li> + </ul> + </div> + <div id="poweredBy"> + <a href="http://www.apache.org/events/current-event.html" title="ApacheCon" class="builtBy"> + <img class="builtBy" alt="ApacheCon" src="http://www.apache.org/events/current-event-125x125.png" /> + </a> + <a href="http://maven.apache.org/" title="Maven" class="builtBy"> + <img class="builtBy" alt="Maven" src="http://maven.apache.org/images/logos/maven-feather.png" /> + </a> + </div> + </td> + <td class="content"> + <h1>Introduction to RDF using Commons RDF</h1> +<p>This page is a tutorial to introduce programming with the <a class="externalLink" href="https://www.w3.org/TR/rdf11-concepts/">Resource Description Framework (RDF)</a> using Java and <a href="index.md">Apache Commons RDF</a>. If you already know RDF, you may instead jump ahead to the <a href="userguide.html">Commons RDF user guide</a>.</p> +<p>This is not meant as an extensive RDF tutorial, for that please consult the <a class="externalLink" href="https://www.w3.org/TR/rdf11-primer/">W3C RDF 1.1 Primer</a>. You may also like the <a class="externalLink" href="https://jena.apache.org/tutorials/rdf_api.html">Apache Jena introduction to RDF</a> which uses the <a class="externalLink" href="https://jena.apache.org/">Apache Jena</a> implementation directly.</p> +<p>This tutorial attempts to show the basic concepts of RDF and how you can work with RDF programmatically using the <a href="index.md">Apache Commons RDF API</a> in a simple Java program.</p> +<div class="section"> +<h2><a name="Getting_started_with_Commons_RDF"></a>Getting started with Commons RDF</h2> +<p>This tutorial will assume you already know a bit of <a class="externalLink" href="http://docs.oracle.com/javase/tutorial/">Java programming</a> and that you use an <i>IDE</i> like <a class="externalLink" href="http://www.eclipse.org/">Eclipse</a> or <a class="externalLink" href="https://netbeans.org/">Netbeans</a>. Note that Commons RDF requires Open JDK 8, <a class="externalLink" href="https://www.java.com/">Java 8</a> or equivalent.</p> +<p>The Commons RDF JARs are <a href="download.html">available from Maven Central</a>. While there are multiple <a href="implementations.html">Commons RDF implementations</a>, this tutorial will use the built-in <i>simple</i> implementation as it requires no additional dependencies.</p> +<p>First, create a new Java project for this tutorial, say <tt>rdftutorial</tt>.</p> +<p><b>Tip</b>: Check that your IDE project is using the <b>Java 8</b> syntax and compiler.</p> +<p>We’ll create the package name <tt>org.example</tt>, but you can use whatever you prefer. Then create <tt>RdfTutorial.java</tt> with a static <tt>main()</tt> method we can run:</p> + +<div class="source"> +<div class="source"> +<pre>package org.example; + +import org.apache.commons.rdf.api.*; +import org.apache.commons.rdf.simple.SimpleRDF; + +public class RdfTutorial { + public static void main(String[] args) { + // ... + } +} +</pre></div></div> +<div class="section"> +<h3><a name="Adding_Commons_RDF_to_the_class_path"></a>Adding Commons RDF to the class path</h3> +<p>Above we added the <tt>import</tt> for the Commons RDF API, but the library is not yet on your class path.</p> +<p><b>Note</b>: If you are already familiar with <i>Maven</i>, then see instead <a href="userguide.html#Using_Commons_RDF_from_Maven">how to use Commons RDF from Maven</a> and add the <tt>commons-rdf-simple</tt> dependency to your project. This will make it easier later to share your project or to use newer versions of Commons RDF.</p> +<p>This tutorial assumes a classic Java project with local <tt>.jar</tt> files (say in your project’s <tt>lib/</tt> folder), so download and add to your project’s class path:</p> + +<ul> + +<li><a class="externalLink" href="https://repo.maven.apache.org/maven2/org/apache/commons/commons-rdf-api/0.3.0-incubating/commons-rdf-api-0.3.0-incubating.jar">commons-rdf-api-0.3.0-incubating.jar</a> (<a class="externalLink" href="https://repo.maven.apache.org/maven2/org/apache/commons/commons-rdf-api/0.3.0-incubating/commons-rdf-api-0.3.0-incubating.jar.asc">signature</a>)</li> + +<li><a class="externalLink" href="https://repo.maven.apache.org/maven2/org/apache/commons/commons-rdf-simple/0.3.0-incubating/commons-rdf-simple-0.3.0-incubating.jar">commons-rdf-simple-0.3.0-incubating.jar</a> (<a class="externalLink" href="https://repo.maven.apache.org/maven2/org/apache/commons/commons-rdf-simple/0.3.0-incubating/commons-rdf-simple-0.3.0-incubating.jar.asc">signature</a>)</li> +</ul> +<p><i>Tip: If you prefer you can <a class="externalLink" href="https://www.apache.org/info/verification.html">verify the signatures</a> using the Commons RDF <a class="externalLink" href="http://www.apache.org/dist/incubator/commonsrdf/KEYS">KEYS</a>.</i></p> +<p>As there are <a href="implementations.html">multiple Commons RDF implementations</a>, we have to say which one we want to use. Add to your <tt>RdfTutorial</tt> class:</p> + +<div class="source"> +<div class="source"> +<pre>RDF rdf = new SimpleRDF(); +</pre></div></div> +<p>If you have the classpath set up correctly, you should now be able to compile <tt>RdfTutorial</tt> without warnings.</p></div></div> +<div class="section"> +<h2><a name="RDF_resources"></a>RDF resources</h2> +<p>“The clue is in the name”; the <i>Resource Description Framework</i> (RDF) is for describing <b>resources</b>. But what is a resource?</p> +<p>Anything can be a resource, it is just a concept we want to describe, like computer <i>files</i> (text document, image, database), <i>physical things</i> (person, place, cat), <i>locations</i> (city, point on a map), or more <i>abstract concepts</i> (organization, disease, theatre play).</p> +<p>To know which concept we mean, in RDF the resource needs to either:</p> + +<ul> + +<li>have a global <i>identifier</i>; we call this an <b>IRI</b></li> + +<li>be used <i>indirectly</i> in a statement; we call this a <b>blank node</b></li> + +<li>be a <i>value</i>, we call this a <b>literal</b></li> +</ul> +<p>In this tutorial we’ll use the <i>IRI</i> syntax <tt><identifier></tt> to indicate an identified resource, the <i>blank node</i> syntax <tt>_:it</tt> to indicate an indirectly referenced resource, and the <i>literal</i> syntax <tt>"Hello"</tt> to indicate a value.</p> +<p>Don’t worry about this syntax, RDF is a <b>model</b> with several ways to represent it when saved to a file; the <a href="apidocs/index.html?org/apache/commons/rdf/api/package-summary.html">Commons RDF API</a> directly reflects the RDF model in a syntax-neutral way.</p> +<p>Let’s create our first identified resource, an <tt>IRI</tt> instance:</p> + +<div class="source"> +<div class="source"> +<pre>IRI alice = rdf.createIRI("Alice"); +System.out.println(alice.ntriplesString()); +</pre></div></div> +<p>This should print out:</p> + +<blockquote> +<p><tt><Alice></tt></p> +</blockquote> +<p><b>Note</b>: For simplicity this tutorial use <i>relative IRI references</i> which are not really global identifiers. While this is supported by <tt>SimpleRDF</tt>, some implementations will require <i>absolute IRIs</i> like <tt><http://example.com/Alice></tt>.</p> +<div class="section"> +<h3><a name="Triples"></a>Triples</h3> +<p>To describe a resource in RDF we provide one or more statements, which are called <i>triples</i> of 3 resources (<i>subject</i>, <i>predicate</i>, <i>object</i>):</p> + +<div class="source"> +<div class="source"> +<pre><Alice> <knows> <Bob> . +</pre></div></div> +<p><img src="images/rdf-01.svg" alt="Alice knows Bob" /></p> +<p>This RDF statement is a relationship between the <b>subject</b> <tt><Alice></tt> and the <b>object</b> <tt><Bob></tt>, not dissimilar from the subject and direct object of the similar English sentence <i>“Alice knows Bob”</i>.</p> +<p>What kind of relationship? Well, that is identified with the <b>predicate</b> <tt><knows></tt>. The relationship is <i>directional</i>, from the subject to the object; although <i>Alice knows Bob</i>, we don’t know if Bob really knows Alice! In RDF the predicate is also called a <i>property</i> as it is describing the subject.</p> +<p>You may have noticed that properties are also resources - to understand the kind of relationship we also need a description of it’s concept. More about this later!</p> +<p>Let’s try to create the above statement in Commons RDF; first we’ll create the remaining resources <tt><knows></tt> and <tt><Bob></tt>:</p> + +<div class="source"> +<div class="source"> +<pre>IRI knows = rdf.createIRI("knows"); +IRI bob = rdf.createIRI("Bob"); +</pre></div></div> +<p>Note that the Java variable names <tt>alice</tt>, <tt>knows</tt> and <tt>bob</tt> are not important to Commons RDF, we could as well have called these <tt>a</tt>, <tt>k</tt>, <tt>b</tt>, but to not confuse yourself it’s good to keep the variable names somewhat related to the captured identifiers.</p> +<p>Next we’ll create a <tt>Triple</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>Triple aliceKnowsBob = rdf.createTriple(alice, knows, bob); +</pre></div></div> +<p>We can access <tt>.getSubject()</tt>, <tt>.getPredicate()</tt> and <tt>.getObject()</tt> from a <tt>Triple</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println(aliceKnowsBob.getSubject().ntriplesString()); +System.out.println(aliceKnowsBob.getPredicate().ntriplesString()); +System.out.println(aliceKnowsBob.getObject().ntriplesString()); +</pre></div></div> + +<blockquote> +<p><tt><Alice></tt> <br /> <tt><knows></tt> <br /> <tt><Bob></tt></p> +</blockquote> +<p><i><b>Tip</b>: Instances from <tt>SimpleRDF</tt> can be printed directly, as <tt>System.out</tt> would use their <tt>.toString()</tt>, but for consistent behaviour across implementations we use <tt>.ntriplesString()</tt> above.</i></p> +<p>With <tt>SimpleRDF</tt> we can also print the <tt>Triple</tt> for debugging:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println(aliceKnowsBob); +</pre></div></div> + +<blockquote> +<p><tt><Alice> <knows> <Bob> .</tt></p> +</blockquote></div> +<div class="section"> +<h3><a name="Graph"></a>Graph</h3> +<p>By using the same identified resources in multiple triples, you can create a <i>graph</i>. For instance, this graph shows multiple relations of <tt><knows></tt> and <tt><plays></tt>:</p> + +<div class="source"> +<div class="source"> +<pre><Alice> <knows> <Bob> . +<Alice> <knows> <Charlie> . +<Alice> <plays> <Tennis> . +<Bob> <knows> <Charlie> . +<Bob> <plays> <Football> . +<Charlie> <plays> <Tennis> . +</pre></div></div> +<p>The power of a graph as a data structure is that you don’t have to decide a hierarchy. The statements of an RDF graph can be listed in any order, and so we should not consider the <tt><Alice></tt> resource as anything more special than <tt><Bob></tt> or <tt><Tennis></tt>.</p> +<p><img src="images/rdf-02.svg" alt="Graph of Alice knows Bob and Charlie, Alice and Charlie play Tennis, Bob plays Football" /></p> +<p>It is therefore possible to <i>query</i> the graph, such as <i>"Who plays Tennis?</i> or <i>“Who does Alice know?”</i>, but also more complex, like <i>“Does Alice anyone that plays Football?”</i>.</p> +<p>Let’s try that now using Commons RDF. To keep the triples we’ll need a <tt>Graph</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>Graph graph = rdf.createGraph(); +</pre></div></div> +<p>We already have the first triple, so we’ll <tt>.add()</tt> it to the <tt>graph</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>graph.add(aliceKnowsBob); +</pre></div></div> +<p>Before adding the remaining statements we need a few more resources:</p> + +<div class="source"> +<div class="source"> +<pre>IRI charlie = rdf.createIRI("Charlie"); + +IRI plays = rdf.createIRI("plays"); + +IRI football = rdf.createIRI("Football"); +IRI tennis = rdf.createIRI("Tennis"); +</pre></div></div> +<p>Now we use the <tt>graph.add(subj,pred,obj)</tt> shorthand which creates the <tt>Triple</tt> instances and add them to the graph.</p> + +<div class="source"> +<div class="source"> +<pre>graph.add(alice, knows, charlie); +graph.add(alice, plays, tennis); +graph.add(bob, knows, charlie); +graph.add(bob, plays, football); +graph.add(charlie, plays, tennis); +</pre></div></div> +<p>Next we’ll ask the graph those questions using <tt>.iterate(s,p,o)</tt> and <tt>null</tt> as the wildcard.</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println("Who plays Tennis?"); +for (Triple triple : graph.iterate(null, plays, tennis)) { + System.out.println(triple.getSubject()); +} +</pre></div></div> + +<blockquote> +<p><tt>Who plays Tennis?</tt> <br /> <tt><Alice></tt> <br /> <tt><Charlie></tt></p> +</blockquote> +<p>Notice how we only print out the <tt>.getSubject()</tt> (our wildcard), if you check <tt>.getPredicate()</tt> or <tt>.getObject()</tt> you will find they are equal to <tt>plays</tt> and <tt>tennis</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println("Who plays Tennis?"); +for (Triple triple : graph.iterate(null, plays, tennis)) { + System.out.println(triple.getSubject()); + System.out.println(plays.equals(triple.getPredicate())); + System.out.println(tennis.equals(triple.getObject())); +} +</pre></div></div> +<p>We can query with wildcards in any positions, for instance for the <i>object</i>:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println("Who does Alice know?"); +for (Triple triple : graph.iterate(alice, knows, null)) { + System.out.println(triple.getObject()); +} +</pre></div></div> + +<blockquote> +<p><tt>Who does Alice know?</tt> <br /> <tt><Bob></tt> <br /> <tt><Charlie></tt></p> +</blockquote> +<p>Let’s try to look up which of those friends play football:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println("Does Alice anyone that plays Football?"); +for (Triple triple : graph.iterate(alice, knows, null)) { + RDFTerm aliceFriend = triple.getObject(); + if (graph.contains(aliceFriend, plays, football)) { + System.out.println("Yes, " + aliceFriend); + } +} +</pre></div></div> +<p>You will get a compiler error:</p> + +<blockquote> +<p><tt>RDFTerm</tt> cannot be converted to <tt>BlankNodeOrIRI</tt></p> +</blockquote> +<p>This is because in an RDF triple, not all kind of resources can be used in all positions, and the kind of resource in Commons RDF is indicated by the interfaces:</p> + +<ul> + +<li><a href="apidocs/org/apache/commons/rdf/api/IRI.html">IRI</a> (identified)</li> + +<li><a href="apidocs/org/apache/commons/rdf/api/BlankNode.html">BlankNode</a> (indirect)</li> + +<li><a href="apidocs/org/apache/commons/rdf/api/Literal.html">Literal</a> (value)</li> +</ul> +<p>Look at the method signature of <a class="externalLink" href="http://commonsrdf.incubator.apache.org/apidocs/org/apache/commons/rdf/api/Graph.html#contains-org.apache.commons.rdf.api.BlankNodeOrIRI-org.apache.commons.rdf.api.IRI-org.apache.commons.rdf.api.RDFTerm-">graph.contains(s,p,o)</a>:</p> + +<div class="source"> +<div class="source"> +<pre>boolean contains(BlankNodeOrIRI subject, + IRI predicate, + RDFTerm object) +</pre></div></div> +<p>In short, for any RDF triple:</p> + +<ul> + +<li>The <b>subject</b> must be a <a href="apidocs/org/apache/commons/rdf/api/BlankNodeOrIRI.html">BlankNodeOrIRI</a>, that is either a <tt>BlankNode</tt> or <tt>IRI</tt></li> + +<li>The <b>predicate</b> must be a <a href="apidocs/org/apache/commons/rdf/api/IRI.html">IRI</a> (so we can look up what it means)</li> + +<li>The <b>object</b> must be a <a href="apidocs/org/apache/commons/rdf/api/RDFTerm.html">RDFTerm</a>, that is either a <tt>BlankNode</tt>, <tt>IRI</tt> or <tt>Literal</tt></li> +</ul> +<p>As we are retrieving triples from the graph, the <tt>triple.getObject()</tt> is only known to be an RDFTerm if we use it as a Java variable - there could in theory be triples in the graph with <tt>Literal</tt> and <tt>BlankNode</tt> objects:</p> + +<div class="source"> +<div class="source"> +<pre><Alice> <knows> "Santa Claus". +<Alice> <knows> _:someone. +</pre></div></div> +<p>In this case we could have done a naive casting like <tt>(IRI)aliceFriend</tt>; we inserted her <tt>IRI</tt>-represented friends right before, but this is a toy example - there’s no need to use RDF if you already know the answer!</p> +<p>So unless you know for sure in your graph that <tt><knows></tt> is never used with a literal value as object, this would not be safe. So we’ll do an <tt>instanceof</tt> check (skipping any literals) and cast to <tt>BlankNodeOrIRI</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println("Does Alice anyone that plays Football?"); +for (Triple triple : graph.iterate(alice, knows, null)) { + RDFTerm aliceFriend = triple.getObject(); + if (! (aliceFriend instanceof BlankNodeOrIRI)) { + continue; + } + if (graph.contains( (BlankNodeOrIRI)aliceFriend, plays, football)) { + System.out.println("Yes, " + aliceFriend); + } +} +</pre></div></div> + +<blockquote> +<p><tt>Does Alice anyone that plays Football?</tt> <br /> <tt>Yes, <Bob></tt></p> +</blockquote></div></div> +<div class="section"> +<h2><a name="Literal_values"></a>Literal values</h2> +<p>We talked briefly about literals above as a way to represent <i>values</i> in RDF. What is a literal value? In a way you could think of a value as when you no longer want to stay in graph-land of related resources, and just want to use primitive types like <tt>float</tt>, <tt>int</tt> or <tt>String</tt> to represent values like a player rating, the number of matches played, or the full name of a person (including spaces and punctuation which don’t work well in an identifier).</p> +<p>Such values are in Commons RDF represented as instances of <tt>Literal</tt>, which we can create using <tt>rdf.createLiteral(..)</tt>. Strings are easy:</p> + +<div class="source"> +<div class="source"> +<pre>Literal aliceName = rdf.createLiteral("Alice W. Land"); +</pre></div></div> +<p>We can then add a triple that relates the resource <tt><Alice></tt> to this value, let’s use a new predicate <tt><name></tt>:</p> + +<div class="source"> +<div class="source"> +<pre>IRI name = rdf.createIRI("name"); +graph.add(alice, name, aliceName); +</pre></div></div> +<p>When you look up literal properties in a graph, take care that in RDF a property is not necessarily <i>functional</i>, that is, it would be perfectly valid RDF-wise for a person to have multiple names; Alice might also be called <i>“Alice Land”</i>. </p> +<p>Instead of using <tt>graph.iterate()</tt> and <tt>break</tt> in a for-loop, it might be easier to use the Java 8 <tt>Stream</tt> returned from <tt>.stream()</tt> together with <tt>.findAny()</tt> - which return an <tt>Optional</tt> in case there is no <tt><name></tt>:</p> + +<div class="source"> +<div class="source"> +<pre>System.out.println(graph.stream(alice, name, null).findAny()); +</pre></div></div> + +<blockquote> +<p><tt>Optional[<Alice> <name> "Alice W. Land" .]</tt></p> +</blockquote> +<p><b>Note:</b> Using <tt>.findFirst()</tt> will not returned the “first” recorded triple, as triples in a graph are not necessarily kept in order.</p> +<p>You can use <tt>optional.isPresent()</tt> and <tt>optional.get()</tt> to check if a <tt>Triple</tt> matched the graph stream pattern:</p> + +<div class="source"> +<div class="source"> +<pre>Optional<? extends Triple> nameTriple = graph.stream(alice, name, null).findAny(); +if (nameTriple.isPresent()) { + System.out.println(nameTriple.get()); +} +</pre></div></div> +<p>If you feel adventerous, you can try the <a class="externalLink" href="http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html">Java 8 functional programming</a> style to work with of <tt>Stream</tt> and <tt>Optional</tt> and get the literal value unquoted:</p> + +<div class="source"> +<div class="source"> +<pre>graph.stream(alice, name, null) + .findAny().map(Triple::getObject) + .filter(obj -> obj instanceof Literal) + .map(literalName -> ((Literal)literalName).getLexicalForm()) + .ifPresent(System.out::println); +</pre></div></div> + +<blockquote> +<p><tt>Alice W. Land</tt></p> +</blockquote> +<p>Notice how we here used a <tt>.filter</tt> to skip any non-<tt>Literal</tt> names (which would not have the <tt>.getLexicalForm()</tt> method).</p> +<div class="section"> +<h3><a name="Typed_literals"></a>Typed literals</h3> +<p>Non-String value types are represented in RDF as <i>typed literals</i>; which is similar to (but not the same as) Java native types. A typed literal is a combination of a <i>string representation</i> (e.g. “13.37”) and a data type IRI, e.g. <tt><http://www.w3.org/2001/XMLSchema#float></tt>. RDF reuse the XSD datatypes.</p> +<p>A collection of the standardized datatype <tt>IRI</tt>s are provided in Simple’s <a href="apidocs/org/apache/commons/rdf/simple/Types.html">Types</a> class, which we can use with <tt>createLiteral</tt> by adding the corresponding <tt>import</tt>:</p> + +<div class="source"> +<div class="source"> +<pre>import org.apache.commons.rdf.simple.Types; +// ... +IRI playerRating = rdf.createIRI("playerRating"); +Literal aliceRating = rdf.createLiteral("13.37", Types.XSD_FLOAT); +graph.add(alice, playerRating, aliceRating); +</pre></div></div> +<p>Note that Commons RDF does not currently provide converters from/to native Java data types and the RDF string representations.</p></div> +<div class="section"> +<h3><a name="Language-specific_literals"></a>Language-specific literals</h3> +<p>We live in a globalized world, with many spoken and written languages. While we can often agree about a concept like <tt><Football></tt>, different languages might call it differently. The distinction in RDF between identified resources and literal values, mean we can represent names or labels for the same thing.</p> +<p>Rather than introducing language-specific predicates like <tt><name_in_english></tt> and <tt><name_in_norwegian></tt> it is usually better in RDF to use <i>language-typed literals</i>:</p> + +<div class="source"> +<div class="source"> +<pre>Literal footballInEnglish = rdf.createLiteral("football", "en"); +Literal footballInNorwegian = rdf.createLiteral("fotball", "no"); + +graph.add(football, name, footballInEnglish); +graph.add(football, name, footballInNorwegian); +</pre></div></div> +<p>The language tags like <tt>"en"</tt> and <tt>"no"</tt> are identified by <a class="externalLink" href="https://tools.ietf.org/html/bcp47">BCP47</a> - you can’t just make up your own but must use one that matches the language. It is possible to use localized languages as well, e.g.</p> + +<div class="source"> +<div class="source"> +<pre>Literal footballInAmericanEnglish = rdf.createLiteral("soccer", "en-US"); +graph.add(football, name, footballInAmericanEnglish); +</pre></div></div> +<p>Note that Commons RDF does not currently provide constants for the standardized languages or methods to look up localized languages.</p></div></div> +<div class="section"> +<h2><a name="Blank_nodes_-_when_you_dont_know_the_identity"></a>Blank nodes - when you don’t know the identity</h2> +<p>Sometimes you don’t know the identity of a resource. This can be the case where you know the <i>existence</i> of a resource, similar to “someone” or “some” in English. For instance,</p> + +<div class="source"> +<div class="source"> +<pre><Charlie> <knows> _:someone . +_:someone <plays> <Football> . +</pre></div></div> +<p>We don’t know who this <tt>_:someone</tt> is, it could be <tt><Bob></tt> (which we know plays football), it could be someone else, even <tt><Alice></tt> (we don’t know that she doesn’t play football).</p> +<p>In RDF we represent <tt>_:someone</tt> as a <i>blank node</i> - it’s a resource without a global identity. Different RDF files can all talk about <tt>_:blanknode</tt>, but they would all be different resources. Crucially, a blank node can be used in multiple triples within the same graph, so that we can relate a subject to a blank node resource, and then describe that resource (usually incomplete).</p> +<p>Let’s add the blank node statements to our graph:</p> + +<div class="source"> +<div class="source"> +<pre>BlankNode someone = rdf.createBlankNode(); +graph.add(charlie, knows, someone); +graph.add(someone, plays, football); +BlankNode someoneElse = rdf.createBlankNode(); +graph.add(charlie, knows, someoneElse); +</pre></div></div> +<p>Every call to <tt>rdf.createBlankNode()</tt> creates a new, unrelated blank node with an internal identifier. Let’s have a look:</p> + +<div class="source"> +<div class="source"> +<pre>for (Triple heKnows : graph.iterate(charlie, knows, null)) { + if (! (heKnows.getObject() instanceof BlankNodeOrIRI)) { + continue; + } + BlankNodeOrIRI who = (BlankNodeOrIRI)heKnows.getObject(); + System.out.println("Charlie knows "+ who); + for (Triple whoPlays : graph.iterate(who, plays, null)) { + System.out.println(" who plays " + whoPlays.getObject()); + } +} +</pre></div></div> + +<blockquote> +<p><tt>Charlie knows _:ae4115fb-86bf-3330-bc3b-713810e5a1ea</tt> <br /> <tt>who plays <Football></tt> <br /> <tt>Charlie knows _:884d5c05-93a9-3709-b655-4152c2e51258</tt></p> +</blockquote> +<p>As we see above, given a <tt>BlankNode</tt> instance it is perfectly valid to ask the same <tt>Graph</tt> about further triples relating to the <tt>BlankNode</tt>.</p> +<div class="section"> +<h3><a name="Blank_node_labels"></a>Blank node labels</h3> +<p>In Commons RDF it is also possible to create a blank node from a <i>name</i> - which can be useful if you don’t want to keep (or look up) the <tt>BlankNode</tt> instance to later add statements about the same node.</p> +<p>Let’s first delete the old BlankNode statements:</p> + +<div class="source"> +<div class="source"> +<pre>graph.remove(null,null,someone); +graph.remove(someone,null,null); +</pre></div></div> +<p>And now we’ll try an alternate approach:</p> + +<div class="source"> +<div class="source"> +<pre>// no Java variable for the new BlankNode instance +graph.add(charlie, knows, rdf.createBlankNode("someone")); +// at any point later (with the same RDF instance) +graph.add(rdf.createBlankNode("someone"), plays, football); +</pre></div></div> +<p>Running the <tt>"Charlie knows"</tt> query again should still work, but now return a different identifier.</p> + +<blockquote> +<p><tt>Charlie knows _:5e2a75b2-33b4-3bb8-b2dc-019d42c2215a</tt> <br /> <tt>who plays <Football></tt> <br /> <tt>Charlie knows _:884d5c05-93a9-3709-b655-4152c2e51258</tt></p> +</blockquote> +<p>You may notice that with <tt>SimpleRDF</tt> the string <tt>"someone"</tt> does not survive into the string representation of the <tt>BlankNode</tt> label <tt>_:someone</tt>, other <tt>RDF</tt> implementations may support that.</p> +<p>Note that it needs to be the same <tt>RDF</tt> instance to recreate the same <i>“someone”</i> <tt>BlankNode</tt>. This is a Commons RDF-specific behaviour to improve cross-graph compatibility, other RDF frameworks may save the blank node using the provided name as a blank node label, which in some cases could cause collisions (but perhaps more readable output).</p></div> +<div class="section"> +<h3><a name="Open_world_assumption"></a>Open world assumption</h3> +<p>How to interpret a blank node depends on the assumptions you build into your RDF application - it could be thought of as a logical “there exists a resource that..” or a more pragmatic “I don’t know/care about the resource’s IRI”. Blank nodes can be useful if your RDF model describes intermediate resources like “a person’s membership of an organization” or “a participant’s result in a race” which it often is not worth maintaining identifiers for.</p> +<p>It is common on the semantic web to use the <a class="externalLink" href="http://wiki.opensemanticframework.org/index.php/Overview_of_the_Open_World_Assumption">open world assumption</a> - if it is not stated as a <i>triple</i> in your graph, then you don’t know if something is is true or false, for instance if <tt><Alice> <plays> <Football> .</tt> </p> +<p>Note that the open world assumption applies both to <tt>IRI</tt>s and <tt>BlankNode</tt>s, that is, you can’t necessarily assume that the resources <tt><Alice></tt> and <tt><Charlie></tt> describe two different people just because they have two different identifiers - in fact it is very common that different systems use different identifiers to describe the same (or pretty much the same) thing in the real world.</p> +<p>It is however common for applications to “close the world”; saying “given this information I have gathered as RDF, I’ll assume these resources are all separate things in the world, then do I then know if <tt><Alice> <plays> <Football></tt> is false?”.</p> +<p>Using logical <i>inference rules</i> and <i>ontologies</i> is one method to get stronger assumptions and conclusions. Note that building good rules or ontologies requires a fair bit more knowledge than what can be conveyed in this short tutorial.</p> +<p>It is out of scope for Commons RDF to support the many ways to deal with logical assumptions and conclusions, however you may find interest in using <a href="implementations.html#Apache_Jena">Jena implementation</a> combined with Jena’s <a class="externalLink" href="https://jena.apache.org/documentation/ontology/">ontology API</a>.</p></div></div> + </td> + </tr> + </table> + </div> + + <div class="footer"> + <p>Copyright © 2015-2016 + <a href="https://www.apache.org/">The Apache Software Foundation</a>. + All Rights Reserved.</p> + +<div class="center">Apache Commons, Apache, the Apache feather logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div> + </div> + </body> + +</html>