summaryrefslogtreecommitdiffstats
path: root/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php')
-rw-r--r--core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php39
1 files changed, 28 insertions, 11 deletions
diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php
index 9e7902b..5811fb2 100644
--- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php
+++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php
@@ -5,7 +5,7 @@
*
* LICENSE
*
- * Copyright (c) 2012 Nicholas J Humfrey.
+ * Copyright (c) 2012-2013 Nicholas J Humfrey.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,10 +32,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package EasyRdf
- * @copyright Copyright (c) 2009-2012 Nicholas J Humfrey
+ * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey
* Copyright (c) 1997-2006 Aduna (http://www.aduna-software.com/)
* @license http://www.opensource.org/licenses/bsd-license.php
- * @version $Id$
*/
/**
@@ -44,7 +43,7 @@
* http://www.w3.org/TR/rdfa-core/
*
* @package EasyRdf
- * @copyright Copyright (c) 2012 Nicholas J Humfrey
+ * @copyright Copyright (c) 2012-2013 Nicholas J Humfrey
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class EasyRdf_Parser_Rdfa extends EasyRdf_Parser
@@ -373,6 +372,28 @@ class EasyRdf_Parser_Rdfa extends EasyRdf_Parser
$lang = $node->getAttribute('lang');
}
+ // HTML+RDFa 1.1: ignore rel and rev unless they contain CURIEs.
+ foreach (array('rel', 'rev') as $attr) {
+ if ($node->hasAttribute('property') and $node->hasAttribute($attr)) {
+ // Quick check in case there are no CURIEs to deal with.
+ if (strpos($node->getAttribute($attr), ':') === false) {
+ $node->removeAttribute($attr);
+ } else {
+ // Only keep CURIEs.
+ $curies = array();
+ foreach (preg_split("/\s+/", $node->getAttribute($attr)) as $token) {
+ if (strpos($token, ':')) {
+ $curies[] = $token;
+ }
+ }
+ $node->setAttribute($attr, implode(' ', $curies));
+ }
+ }
+ }
+
+ $rels = $this->processUriList($node, $context, $node->getAttribute('rel'));
+ $revs = $this->processUriList($node, $context, $node->getAttribute('rev'));
+
if (!$node->hasAttribute('rel') and !$node->hasAttribute('rev')) {
// Step 5: Establish a new subject if no rel/rev
if ($property and is_null($content) and is_null($datatype)) {
@@ -439,8 +460,6 @@ class EasyRdf_Parser_Rdfa extends EasyRdf_Parser
$subject = $context['object'];
}
- $rels = $this->processUriList($node, $context, $node->getAttribute('rel'));
- $revs = $this->processUriList($node, $context, $node->getAttribute('rev'));
}
# FIXME: better place for this?
@@ -519,8 +538,8 @@ class EasyRdf_Parser_Rdfa extends EasyRdf_Parser
$datatype = $this->processUri($node, $context, $datatype, true);
}
- if ($node->nodeName === 'data' and $node->hasAttribute('value')) {
- $value['value'] = $node->getAttribute('value');
+ if ($content !== null) {
+ $value['value'] = $content;
} elseif ($node->hasAttribute('datetime')) {
$value['value'] = $node->getAttribute('datetime');
$datetime = true;
@@ -531,9 +550,7 @@ class EasyRdf_Parser_Rdfa extends EasyRdf_Parser
foreach ($node->childNodes as $child) {
$value['value'] .= $child->C14N();
}
- } elseif ($content !== null) {
- $value['value'] = $content;
- } elseif (is_null($datatype) and empty($rel) and empty($rev)) {
+ } elseif (is_null($datatype) and empty($rels) and empty($revs)) {
$value['value'] = $this->getUriAttribute(
$node,
$context,