alcamo/rdf-literal-workbench 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alcamo/rdf-literal-workbench

Composer 安装命令:

composer require alcamo/rdf-literal-workbench

包简介

RDF literal creation and validation

README 文档

README

namespace alcamo\rdf_literal_workbench;

use alcamo\rdf_literal\StringLiteral;
use alcamo\uri\FileUriFactory;

include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';

$factory = new LiteralFactory();

$factory->getSchema()->addUris(
    [
        (new FileUriFactory)->create(
            dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor'
                . DIRECTORY_SEPARATOR . 'alcamo'
                . DIRECTORY_SEPARATOR . 'dom'
                . DIRECTORY_SEPARATOR . 'xsd'
                . DIRECTORY_SEPARATOR . 'xhtml-datatypes-1.xsd'
        )
    ]
);

$ncNameType =
    $factory->getSchema()->getGlobalType(LiteralFactory::XH11D_NS . ' Pixels');

$literal1 = $factory->create(1024, $ncNameType);

echo "$literal1: class " . get_class($literal1) . PHP_EOL;

$typeMap = new LiteralTypeMap();

$typeMap->validateLiteral($literal1);

$literal2 = new StringLiteral('foo', LiteralFactory::XSD_NS . '#QName');

$typeMap->validateLiteral($literal2);

This example is contained in this package as a file in the bin directory. It will output

1024: class alcamo\rdf_literal\NonNegativeIntegerLiteral
PHP Fatal error:  Uncaught alcamo\exception\DataValidationFailed: Validation failed; literal datatype http://www.w3.org/2001/XMLSchema QName not derived from default datatype http://www.w3.org/2001/XMLSchema string in /home/rve/src/alcamo-rdf-literal-workbench/src/LiteralTypeMap.php:62

Unlike alcamo\rdf_literal\LiteralFactory, the class alcamo\rdf_literal_workbench\LiteralFactory contains an XML schema and hence is aware of the type hierarchy. Thus, the above call to create() creates an instance of NonNegativeIntegerLiteral since the factory knows that the simple type xh11d:Pixels is derived from xsd:NonNegativeInteger.

The class alcamo\rdf_literal\LiteralTypeMap, which contains an XML Schema as well, can be used to validate whether the datatype of a literal is actually supported by the literal class, i.e. derived from its defaut type. In the above example, $literal1 is valid while $literal2 is not. The literal classes themselves do not check this because they would need an XML schema for this.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固