[0] [1] [2] [3]

PHP Script


<?php
// For terms of use see LICENSE.txt in this distribution.
include('simplerdf-php5.php');
exampleName('RDF/XML Saving demonstration'"Demonstrating the saving flexibility. Easy to read XML output that is easy to configure.");
// Create new SimpleRDF
$rdf=new SimpleRdf();
$rdf->loadFile('simplerdf-php5-02.in');

// This is the list of all triples we parsed from RDF source... You do not need to give any attention to this...
h1('Saving with compact settings');
$rdf->tidyMaxDepth=4// How many nested sententces?
$rdf->tidyMaxAttrs=32// How many XML attributes in one element?
$rdf->tidyAttrMaxLength=64// How long XML literal stored as XML attribute can be?
echo $rdf->saveXml();

h1('Saving with less compact settings');
$rdf->tidyMaxDepth=1// How many nested sententces?
$rdf->tidyMaxAttrs=0// How many XML attributes in one element?
$rdf->tidyAttrMaxLength=0// How long XML literal stored as XML attribute can be?
echo $rdf->saveXml();

// This is the list of all triples we parsed from RDF source... You do not need to give any attention to this...
h1('All N-Triples');
echo 
$rdf->saveNt();

saveOutput(__FILE__);

?>

Input


<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns:cd="http://www.recshop.fake/cd/"> 

<cd:CD-Audio
 rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
  <cd:artist>Bob Dylan</cd:artist>
  <cd:year>1985</cd:year>
  <cd:country>USA</cd:country>
  <cd:company>Columbia</cd:company>
  <cd:price>
    <rdf:Alt>
          <rdf:li xml:lang="en">
            <rdf:PriceInfo>
              <cd:currency>GBP</cd:currency>
              <cd:amount>9</cd:amount>              
            </rdf:PriceInfo>
           </rdf:li>
          <rdf:li xml:lang="de">
            <rdf:PriceInfo>
              <cd:currency>EUR</cd:currency>
              <cd:amount>12</cd:amount>              
            </rdf:PriceInfo>
           </rdf:li>
        </rdf:Alt>
  </cd:price>
</cd:CD-Audio>
</rdf:RDF>

Output


::::::::::::::::::::::::RDF/XML Saving demonstration:::::::::::::::::::::::
:: Demonstrating the saving flexibility. Easy to read XML output that is
:: easy to configure.
:::::::::::::::::::::::SimpleRDF v0.2.10 (2004-11-19)::::::::::::::::::::::

----------------------[ Saving with compact settings ]---------------------
<?xml version="1.0"?>
<!-- Generated by SimpleRDF v0.2.10 <http://simplerdf.sourceforge.net> -->
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <fake:CD-Audio xmlns:fake="http://www.recshop.fake/cd/" about="http://www.recshop.fake/cd/Empire Burlesque" fake:artist="Bob Dylan" fake:year="1985" fake:country="USA" fake:company="Columbia">
    <fake:price>
      <rdf:Alt about="_:SimpleRDF_id2290928">
        <rdf:li>
          <rdf:PriceInfo about="_:SimpleRDF_id2286933" fake:currency="GBP" fake:amount="9"/>
          <rdf:PriceInfo about="_:SimpleRDF_id2288947" fake:currency="EUR" fake:amount="12"/>
        </rdf:li>
      </rdf:Alt>
    </fake:price>
  </fake:CD-Audio>
</rdf:RDF>
-------------------[ Saving with less compact settings ]-------------------
<?xml version="1.0"?>
<!-- Generated by SimpleRDF v0.2.10 <http://simplerdf.sourceforge.net> -->
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <fake:CD-Audio xmlns:fake="http://www.recshop.fake/cd/" about="http://www.recshop.fake/cd/Empire Burlesque">
    <fake:artist rdf:parseType="Literal">Bob Dylan</fake:artist>
    <fake:year rdf:parseType="Literal">1985</fake:year>
    <fake:country rdf:parseType="Literal">USA</fake:country>
    <fake:company rdf:parseType="Literal">Columbia</fake:company>
    <fake:price rdf:resource="_:SimpleRDF_id2290928"/>
  </fake:CD-Audio>
  <rdf:Alt about="_:SimpleRDF_id2290928">
    <rdf:li rdf:resource="_:SimpleRDF_id2286933"/>
    <rdf:li rdf:resource="_:SimpleRDF_id2288947"/>
  </rdf:Alt>
  <rdf:PriceInfo about="_:SimpleRDF_id2286933">
    <fake:currency xmlns:fake="http://www.recshop.fake/cd/" rdf:parseType="Literal">GBP</fake:currency>
    <fake:amount xmlns:fake="http://www.recshop.fake/cd/" rdf:parseType="Literal">9</fake:amount>
  </rdf:PriceInfo>
  <rdf:PriceInfo about="_:SimpleRDF_id2288947">
    <fake:currency xmlns:fake="http://www.recshop.fake/cd/" rdf:parseType="Literal">EUR</fake:currency>
    <fake:amount xmlns:fake="http://www.recshop.fake/cd/" rdf:parseType="Literal">12</fake:amount>
  </rdf:PriceInfo>
</rdf:RDF>
-----------------------------[ All N-Triples ]-----------------------------
<http://www.recshop.fake/cd/Empire Burlesque>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>    <http://www.recshop.fake/cd/CD-Audio> .
<http://www.recshop.fake/cd/Empire Burlesque>    <http://www.recshop.fake/cd/artist>    "Bob Dylan" .
<http://www.recshop.fake/cd/Empire Burlesque>    <http://www.recshop.fake/cd/year>    "1985" .
<http://www.recshop.fake/cd/Empire Burlesque>    <http://www.recshop.fake/cd/country>    "USA" .
<http://www.recshop.fake/cd/Empire Burlesque>    <http://www.recshop.fake/cd/company>    "Columbia" .
<http://www.recshop.fake/cd/Empire Burlesque>    <http://www.recshop.fake/cd/price>    _:SimpleRDF_id2290928 .
_:SimpleRDF_id2290928    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt> .
_:SimpleRDF_id2290928    <http://www.w3.org/1999/02/22-rdf-syntax-ns#li>    _:SimpleRDF_id2286933 .
_:SimpleRDF_id2286933    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#PriceInfo> .
_:SimpleRDF_id2286933    <http://www.recshop.fake/cd/currency>    "GBP"@en .
_:SimpleRDF_id2286933    <http://www.recshop.fake/cd/amount>    "9"@en .
_:SimpleRDF_id2290928    <http://www.w3.org/1999/02/22-rdf-syntax-ns#li>    _:SimpleRDF_id2288947 .
_:SimpleRDF_id2288947    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#PriceInfo> .
_:SimpleRDF_id2288947    <http://www.recshop.fake/cd/currency>    "EUR"@de .
_:SimpleRDF_id2288947    <http://www.recshop.fake/cd/amount>    "12"@de .
___________________________________________________________________________
SimpleRDF v0.2.10 <http://simplerdf.sourceforge.net>,RDF/XML parser for PHP5
Generated using PHP 5.0.2 on Fri Nov 19 09:15:55 2004