{"id":15372067,"url":"https://github.com/xquery/simpletype","last_synced_at":"2026-03-02T19:37:31.492Z","repository":{"id":4603502,"uuid":"5746657","full_name":"xquery/simpletype","owner":"xquery","description":"simple datatype validation with schematron","archived":false,"fork":false,"pushed_at":"2012-09-10T09:31:33.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T10:32:37.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xquery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-10T08:19:08.000Z","updated_at":"2014-05-21T23:47:49.000Z","dependencies_parsed_at":"2022-08-24T17:50:54.045Z","dependency_job_id":null,"html_url":"https://github.com/xquery/simpletype","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xquery/simpletype","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fsimpletype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fsimpletype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fsimpletype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fsimpletype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xquery","download_url":"https://codeload.github.com/xquery/simpletype/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fsimpletype/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284939277,"owners_count":27087872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T13:49:31.557Z","updated_at":"2025-11-17T19:02:34.816Z","avatar_url":"https://github.com/xquery.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# simpletype\n\nWhen I start a project, its useful to be able to validate against XML\nSchema primitive datatypes, without having to fully drink the XML\nSchema koolaid.\n\nBy using a [schematron](http://en.wikipedia.org/wiki/Schematron) wrapper and a simple `st:type` attribute in my\nxml I can achieve simple type validation as well as provide good\nabstraction for any future validation (be it schematron asserts or XML\nSchema).\n\nThis can probably be characterised as a 'tactical' approach to\nvalidation .. I am fully aware of\n[NVDL](http://www.google.com/url?sa=t\u0026rct=j\u0026q=\u0026esrc=s\u0026source=web\u0026cd=1\u0026cad=rja\u0026ved=0CCIQFjAA\u0026url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FNamespace-based_Validation_Dispatching_Language\u0026ei=IqlNUIiHKs3IswajrYCADg\u0026usg=AFQjCNFIkNLDK-jtAgeGr8dx0_dcPgwyVQ\u0026sig2=B6M5nSR7p0xZawDvbSSexA)\nand the goodness of [XML Schema\nv1.1](http://www.google.com/url?sa=t\u0026rct=j\u0026q=\u0026esrc=s\u0026source=web\u0026cd=1\u0026cad=rja\u0026ved=0CCoQFjAA\u0026url=http%3A%2F%2Fwww.xmlprague.cz%2F2012%2Fpresentations%2FWhats_new_3.0_XPath_XSLT_XSD_1_1.pdf\u0026ei=tqdNUMyQIIrLswaWgoGACg\u0026usg=AFQjCNFkn0VVtYHo7WyVxZ05wQFDHZHuYA\u0026sig2=RHh_2_vwUDquW0J0bDcXhQ])\nbut every once in a while this approach suits me.\n\nSchematron simpletype schema takes advantage of 'castable as' idiom;\n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cschema xmlns='http://purl.oclc.org/dsdl/schematron'\n        xmlns:xs='http://www.w3.org/2001/XMLSchema'       \n        queryBinding='xslt2'\u003e\n    \u003cns prefix='st' uri='http://webcomposite.com/simpletype'/\u003e  \n    \u003cpattern name=\"XML Schema primitive types\"\u003e\n        \u003crule context=\"*[@st:type eq 'xs:string']\"\u003e\n            \u003cassert test=\". castable as xs:string\"\u003enot a xs:string\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:integer']\"\u003e\n            \u003cassert test=\". castable as xs:integer\"\u003enot an xs:integer\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:boolean']\"\u003e\n            \u003cassert test=\". castable as xs:boolean\"\u003enot xs:boolean\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:decimal']\"\u003e\n            \u003cassert test=\". castable as xs:decimal\"\u003enot a xs:decimal\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:float']\"\u003e\n            \u003cassert test=\". castable as xs:float\"\u003enot an xs:float\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:double']\"\u003e\n            \u003cassert test=\". castable as xs:double\"\u003enot an xs:double\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:duration']\"\u003e\n            \u003cassert test=\". castable as xs:duration\"\u003enot an xs:duration\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:dateTime']\"\u003e\n            \u003cassert test=\". castable as xs:dateTime\"\u003enot an xs:dateTime\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:time']\"\u003e\n            \u003cassert test=\". castable as xs:time\"\u003enot an xs:time\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:date']\"\u003e\n            \u003cassert test=\". castable as xs:date\"\u003enot an xs:date\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:gYearMonth']\"\u003e\n            \u003cassert test=\". castable as xs:gYearMonth\"\u003enot an xs:gYearMonth\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:gYear']\"\u003e\n            \u003cassert test=\". castable as xs:gYear\"\u003enot an xs:gYear\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:gMonthDay']\"\u003e\n            \u003cassert test=\". castable as xs:gMonthDay\"\u003enot an xs:gMonthDay\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:gDay']\"\u003e\n            \u003cassert test=\". castable as xs:gDay\"\u003enot an xs:gDay\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:gMonth']\"\u003e\n            \u003cassert test=\". castable as xs:gMonth\"\u003enot an xs:gMonth\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:hexBinary']\"\u003e\n            \u003cassert test=\". castable as xs:hexBinary\"\u003enot an xs:hexBinary\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:base64Binary']\"\u003e\n            \u003cassert test=\". castable as xs:base64Binary\"\u003enot an xs:base64Binary\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:anyURI']\"\u003e\n            \u003cassert test=\". castable as xs:anyURI\"\u003enot an xs:anyURI\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:QName']\"\u003e\n            \u003cassert test=\". castable as xs:QName\"\u003enot an xs:QName\u003c/assert\u003e\n        \u003c/rule\u003e\n        \u003crule context=\"*[@st:type eq 'xs:NCName']\"\u003e\n            \u003cassert test=\". castable as xs:NCName\"\u003enot an xs:NCName\u003c/assert\u003e\n        \u003c/rule\u003e\n    \u003c/pattern\u003e\n\u003c/schema\u003e\n\n```\n\nTo use in your xml, just declare the `st` namespace and apply an\n`st:type` to an element.\n\n```\n\u003croot xmlns:st=\"http://webcomposite.com/simpletype\"\u003e\n    \u003celement st:type=\"xs:string\"\u003e1a2 watch spot run\u003c/element\u003e\n    \u003celement st:type=\"xs:integer\"\u003e12\u003c/element\u003e\n\u003c/root\u003e\n```\n\nThe limitations of this approach is that you are not applying types to\nattributes (fine with me).\n\n\n## Using\n\nFirst you must [install schematron](http://www.bentoweb.org/refs/TCDL2.0/tsdtf_schematron.html)\n\nTo demonstrate run schematron, validating tests.xml with simpletype.sch\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxquery%2Fsimpletype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxquery%2Fsimpletype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxquery%2Fsimpletype/lists"}