Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xquery/simpletype
simple datatype validation with schematron
https://github.com/xquery/simpletype
Last synced: 20 days ago
JSON representation
simple datatype validation with schematron
- Host: GitHub
- URL: https://github.com/xquery/simpletype
- Owner: xquery
- Created: 2012-09-10T08:19:08.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-10T09:31:33.000Z (about 12 years ago)
- Last Synced: 2024-10-05T05:11:53.172Z (about 1 month ago)
- Homepage:
- Size: 121 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# simpletype
When I start a project, its useful to be able to validate against XML
Schema primitive datatypes, without having to fully drink the XML
Schema koolaid.By using a [schematron](http://en.wikipedia.org/wiki/Schematron) wrapper and a simple `st:type` attribute in my
xml I can achieve simple type validation as well as provide good
abstraction for any future validation (be it schematron asserts or XML
Schema).This can probably be characterised as a 'tactical' approach to
validation .. I am fully aware of
[NVDL](http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCIQFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FNamespace-based_Validation_Dispatching_Language&ei=IqlNUIiHKs3IswajrYCADg&usg=AFQjCNFIkNLDK-jtAgeGr8dx0_dcPgwyVQ&sig2=B6M5nSR7p0xZawDvbSSexA)
and the goodness of [XML Schema
v1.1](http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCoQFjAA&url=http%3A%2F%2Fwww.xmlprague.cz%2F2012%2Fpresentations%2FWhats_new_3.0_XPath_XSLT_XSD_1_1.pdf&ei=tqdNUMyQIIrLswaWgoGACg&usg=AFQjCNFkn0VVtYHo7WyVxZ05wQFDHZHuYA&sig2=RHh_2_vwUDquW0J0bDcXhQ])
but every once in a while this approach suits me.Schematron simpletype schema takes advantage of 'castable as' idiom;
```
not a xs:string
not an xs:integer
not xs:boolean
not a xs:decimal
not an xs:float
not an xs:double
not an xs:duration
not an xs:dateTime
not an xs:time
not an xs:date
not an xs:gYearMonth
not an xs:gYear
not an xs:gMonthDay
not an xs:gDay
not an xs:gMonth
not an xs:hexBinary
not an xs:base64Binary
not an xs:anyURI
not an xs:QName
not an xs:NCName
```
To use in your xml, just declare the `st` namespace and apply an
`st:type` to an element.```
1a2 watch spot run
12```
The limitations of this approach is that you are not applying types to
attributes (fine with me).## Using
First you must [install schematron](http://www.bentoweb.org/refs/TCDL2.0/tsdtf_schematron.html)
To demonstrate run schematron, validating tests.xml with simpletype.sch