My favorites | Sign in
Project Logo
                
Changes to /trunk/docs/digg-rdfa.php
r0 vs. r167   Edit
  Compare: vs.   Format:
Revision r167
Go to: 
Project members, sign in to write a code review
/trunk/docs/digg-rdfa.php /trunk/docs/digg-rdfa.php   r167
  1 <?php
  2 /**
  3 * XML_GRDDL
  4 *
  5 * Copyright (c) 2008, Daniel O'Connor <daniel.oconnor@gmail.com>.
  6 * All rights reserved.
  7 *
  8 * PHP version 5
  9 *
  10 * Redistribution and use in source and binary forms, with or without
  11 * modification, are permitted provided that the following conditions
  12 * are met:
  13 *
  14 * * Redistributions of source code must retain the above copyright
  15 * notice, this list of conditions and the following disclaimer.
  16 *
  17 * * Redistributions in binary form must reproduce the above copyright
  18 * notice, this list of conditions and the following disclaimer in
  19 * the documentation and/or other materials provided with the
  20 * distribution.
  21 *
  22 * * Neither the name of Daniel O'Connor nor the names of his
  23 * contributors may be used to endorse or promote products derived
  24 * from this software without specific prior written permission.
  25 *
  26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  29 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  30 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  32 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  34 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  36 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37 * POSSIBILITY OF SUCH DAMAGE.
  38 *
  39 * @category Semantic_Web
  40 * @package XML_GRDDL
  41 * @author Daniel O'Connor <daniel.oconnor@gmail.com>
  42 * @copyright 2008 Daniel O'Connor
  43 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  44 * @version SVN: $Id: namespace-documents2.php 23 2008-03-01 04:00:26Z daniel.oconnor $
  45 * @link http://code.google.com/p/xmlgrddl/
  46 */
  47
  48 require_once 'XML/GRDDL.php';
  49 require_once 'Log.php';
  50
  51 /**
  52 * An XML document with two namespace transformations
  53 *
  54 * Compare the results to
  55 * http://www.w3.org/2001/sw/grddl-wg/td/two-transforms-output.rdf
  56 */
  57
  58 $url = 'http://digg.com/';
  59
  60 $options = XML_GRDDL::getDefaultOptions();
  61 $options['log'] = Log::singleton('console');
  62 $grddl = XML_GRDDL::factory('xsl', $options);
  63
  64 $data = $grddl->fetch($url);
  65
  66 $data = $grddl->appendProfiles($data, array('http://ns.inria.fr/grddl/rdfa/'));
  67
  68 $stylesheets = $grddl->inspect($data, $url);
  69
  70 $rdfXml = array();
  71 foreach ($stylesheets as $stylesheet) {
  72 $rdfXml[] = $grddl->transform($stylesheet, $data);
  73 }
  74
  75 $result = array_reduce($rdfXml, array($grddl, 'merge'));
  76
  77 print $result;
Hosted by Google Code