How to use the rdflib.Literal function in rdflib

To help you get started, we’ve selected a few rdflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dan-f / modelld / test / field.spec.js View on Github external
it('rejects values that are mis-matched with their type', () => {
      const subject = rdf.NamedNode.fromValue('https://example.com/profile#me')
      const predicate = rdf.NamedNode.fromValue('http://www.w3.org/ns/solid/terms#read')
      const datatype = rdf.NamedNode.fromValue('http://www.w3.org/2001/XMLSchema#boolean')
      const object = new rdf.Literal('foo', null, datatype)
      const quad = rdf.quad(subject, predicate, object)
      expect(() => {
        hasRead.fromQuad(quad)
      }).toThrow(/Cannot parse/)
    })
github fletcher91 / link-redux / src / components / __tests__ / PropertyBase.spec.ts View on Github external
it("uses the render store when the property argument is given", () => {
            const opts = ctx.fullCW(subject);

            const linkedProp = new Literal("Some prop");
            const comp = getComp(linkedProp);
            const elem = mount(opts.wrapComponent(comp)).find(CustomClass).instance();

            expect(elem.getLinkedObjectProperty(NS.schema("text"))).toEqual(new Literal("text"));
        });
github fletcher91 / link-redux / src / components / __tests__ / PropertyBase.spec.ts View on Github external
it("uses the render store when the property argument is given", () => {
            const opts = ctx.fullCW(subject);

            const linkedProp = new Literal("Some prop");
            const comp = getComp(linkedProp);
            const elem = mount(opts.wrapComponent(comp)).find(CustomClass).instance();

            expect(elem.getLinkedObjectProperty(NS.schema("text"))).toEqual(new Literal("text"));
        });
github dan-f / modelld / test / field.spec.js View on Github external
it('parses unknown datatypes as strings', () => {
      const object = new rdf.Literal(
        'foo', null, rdf.NamedNode.fromValue('https://example.com/datatypes#unknown')
      )
      const quad = rdf.quad(
        rdf.NamedNode.fromValue('https://example.com/profile/#me'),
        vocab.foaf('name'),
        object
      )
      const field = name.fromQuad(quad)
      expect(field.value).toBe('foo')
    })
  })
github fletcher91 / link-redux / test / fixtures.ts View on Github external
const sFull = (id: NamedNode, attrs: Test) => {
    return [
        typeObject(id)[0],
        new Statement(id, NS.schema("name"), new Literal(attrs.title || "title"), NS.example("default")),
        new Statement(id, NS.schema("text"), new Literal(attrs.text || "text"), NS.example("default")),
        new Statement(id, NS.schema("author"), new NamedNode(attrs.author || "http://example.org/people/0"), NS.example("default")),
        new Statement(id, NS.schema("dateCreated"), Literal.fromDate(new Date("2019-01-01")), NS.example("default")),
        new Statement(id, NS.ex("timesRead"), Literal.fromValue(5), NS.example("default")),
        new Statement(id, NS.example("tags"), NS.example("tag/0"), NS.example("default")),
        new Statement(id, NS.example("tags"), NS.example("tag/1"), NS.example("default")),
        new Statement(id, NS.example("tags"), NS.example("tag/2"), NS.example("default")),
        new Statement(id, NS.example("tags"), NS.example("tag/3"), NS.example("default")),
    ];
};
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
const comp = link({
                author: defaultNS.schema("author"),
                name: [defaultNS.schema("name"), defaultNS.rdfs("label")],
                tags: {
                    label: defaultNS.example("tags"),
                    limit: Infinity,
                },
                text: defaultNS.schema("text"),
            })(TestComponent);
            opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));

            const elem = mount(opts.wrapComponent());

            expect(elem.find(TestComponent)).toHaveLength(1);
            expect(elem.find(TestComponent)).not.toHaveProp("label");
            expect(elem.find(TestComponent)).toHaveProp("name", new Literal("title"));
            expect(elem.find(TestComponent)).toHaveProp("text", new Literal("text"));
            expect(elem.find(TestComponent)).toHaveProp("author", new NamedNode("http://example.org/people/0"));
            expect(elem.find(TestComponent)).toHaveProp("tags", [
                defaultNS.example("tag/0"),
                defaultNS.example("tag/1"),
                defaultNS.example("tag/2"),
                defaultNS.example("tag/3"),
            ]);
        });
github fletcher91 / link-redux / test / fixtures.js View on Github external
const sTitle = (id, title) => [
  new rdf.Statement(exNS(id), schema('name'), new rdf.Literal(title)),
];
github fletcher91 / link-redux / test / fixtures.js View on Github external
const sFull = (id, attrs) => {
  const iri = exNS(id);
  return [
    typeObject(id)[0],
    new rdf.Statement(iri, schema('name'), new rdf.Literal(attrs.title || 'title')),
    new rdf.Statement(iri, schema('text'), new rdf.Literal(attrs.text || 'text')),
    new rdf.Statement(iri, schema('author'), new rdf.NamedNode(attrs.author || 'http://example.org/people/0')),
  ];
};