Simplify term definition creation, disallow @type in property generator.

This commit is contained in:
Dave Longley 2013-02-11 14:24:55 -05:00
parent b7cf6df479
commit 5c5ab819d7

View file

@ -4147,18 +4147,16 @@ class JsonLdProcessor {
$property_generator = array(); $property_generator = array();
$ids = $id; $ids = $id;
foreach($ids as $id) { foreach($ids as $id) {
if(!is_string($id)) { if(!is_string($id) || $id === '@type') {
throw new JsonLdException( throw new JsonLdException(
'Invalid JSON-LD syntax; property generators must consist of ' . 'Invalid JSON-LD syntax; property generators must consist of ' .
'an @id array containing only strings.', 'an @id array containing only strings and no string can be ' .
'"@type".',
'jsonld.SyntaxError', array('context' => $local_ctx)); 'jsonld.SyntaxError', array('context' => $local_ctx));
} }
// expand @id if it is not @type // expand @id
if($id !== '@type') { $property_generator[] = $this->_expandIri(
$id = $this->_expandIri( $active_ctx, $id, array('base' => true), $local_ctx, $defined);
$active_ctx, $id, array('base' => true), $local_ctx, $defined);
}
$property_generator[] = $id;
} }
// add sorted property generator as @id in mapping // add sorted property generator as @id in mapping
sort($property_generator); sort($property_generator);
@ -4172,13 +4170,9 @@ class JsonLdProcessor {
'jsonld.SyntaxError', array('context' => $local_ctx)); 'jsonld.SyntaxError', array('context' => $local_ctx));
} }
else { else {
// add @id to mapping, expanding it if it is not @type // add @id to mapping
if($id !== '@type') { $mapping->{'@id'} = $this->_expandIri(
// expand @id to full IRI $active_ctx, $id, array('base' => true), $local_ctx, $defined);
$id = $this->_expandIri(
$active_ctx, $id, array('base' => true), $local_ctx, $defined);
}
$mapping->{'@id'} = $id;
} }
} }
else { else {