typings set to number for xsd:double and xsd:float

closes: #113
main
elf-pavlik 3 weeks ago
parent 5425b90ab4
commit c7a9c9b414
  1. 2
      packages/schema-converter-shex/src/typing/ShexJTypingTransformer.ts
  2. 2
      packages/schema-converter-shex/test/testData/activityPub.ts
  3. 13
      packages/schema-converter-shex/test/testData/simple.ts

@ -287,6 +287,8 @@ export const ShexJTypingTransformer = ShexJTraverser.createTransformer<
return dom.type.string;
case "http://www.w3.org/2001/XMLSchema#byte":
case "http://www.w3.org/2001/XMLSchema#decimal":
case "http://www.w3.org/2001/XMLSchema#double":
case "http://www.w3.org/2001/XMLSchema#float":
case "http://www.w3.org/2001/XMLSchema#int":
case "http://www.w3.org/2001/XMLSchema#integer":
case "http://www.w3.org/2001/XMLSchema#long":

File diff suppressed because one or more lines are too long

@ -8,13 +8,15 @@ export const simple: TestData = {
shexc: `
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ns: <https://ns.example/>
PREFIX example: <https://example.com/>
example:EmployeeShape { # An <EmployeeShape> has:
foaf:givenName xsd:string+, # at least one givenName.
foaf:familyName xsd:string, # one familyName.
foaf:phone IRI*, # any number of phone numbers.
foaf:mbox IRI # one FOAF mbox.
foaf:mbox IRI, # one FOAF mbox.
ns:someDouble xsd:double # just to test the data type.
}
`,
sampleTurtle: `
@ -24,7 +26,8 @@ export const simple: TestData = {
foaf:givenName "Robert"^^xsd:string, "Taylor"^^xsd:string ;
foaf:familyName "Johnson"^^xsd:string ;
# no phone number needed
foaf:mbox <mailto:rtj@example.com>
foaf:mbox <mailto:rtj@example.com> ;
ns:someDouble "1e4"^^xsd:double ;
.
`,
baseNode: "http://a.example/Employee7",
@ -47,7 +50,11 @@ export const simple: TestData = {
"@id": "http://xmlns.com/foaf/0.1/mbox",
"@type": "@id",
},
someDouble: {
"@id": "https://ns.example/someDouble",
"@type": "http://www.w3.org/2001/XMLSchema#double",
},
},
successfulTypings:
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface Employee {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n givenName: LdSet<string>;\n familyName: string;\n phone?: LdSet<{\n "@id": string;\n }>;\n mbox: {\n "@id": string;\n };\n}\n\n',
'import { LdSet, LdoJsonldContext } from "@ldo/ldo"\n\nexport interface Employee {\n "@id"?: string;\n "@context"?: LdoJsonldContext;\n givenName: LdSet<string>;\n familyName: string;\n phone?: LdSet<{\n "@id": string;\n }>;\n mbox: {\n "@id": string;\n };\n someDouble: number;\n}\n\n',
};

Loading…
Cancel
Save