/** * This implementation of the CrosswalkFilter * simply removes statements from the incoming meta-data * description that are not in the target description's schema. * @see Filter::process() * @param $input MetadataDescription * @return MetadataDescription */ function &process(&$input) { // Create the target description $output = new MetadataDescription($this->_toSchema); // Compare the property names of the incoming description with // the property names allowed in the target schema. $sourceProperties = $input->getSetPropertyNames(); $targetProperties = $output->getPropertyNames(); $propertiesToBeRemoved = array_diff($sourceProperties, $targetProperties); // Remove statements for properties that are not in the target schema. $statements =& $input->getStatements(); foreach ($propertiesToBeRemoved as $propertyToBeRemoved) { assert(isset($statements[$propertyToBeRemoved])); unset($statements[$propertyToBeRemoved]); } // Set the remaining statements in the target description $success = $output->setStatements($statements); assert($success); return $output; }