Re: XML Schema: Getting lookup tables from DB
Hi Craig, Long, Craig Z wrote: >I have a schema file that will validate large lookup tables. I'm wanting to >include another .XSD in my main .XSD that will grab the lookup table >information. For example: States are identified by two characters i.e. HI = >Hawaii, instead of enumerating these state codes I want to get them from a >data base. The state codes are easy, my issue would be codes that identify >many organizations that may change often -- can this be done using XML >Schema? > Interesting question. One answer might be the use of URL addressable (REST-compatible) web services. You could pick up a dynamically generated enum at schema-load time by having, for example, <xs:include schemaLocation="http://myServer/lookups.dll?trans=states&typeName=statesType&format=schemaEnum" /> If you don't want to use enums at all (maybe the dataset is too large) then you could use a schematron assertion to individually check fields online at runtime, for example: <sch:schema xmlns:sch="http://www.ascc.net/xml/schematron"> <sch:ns prefix="cdyne" uri="http://ws.cdyne.com/" /> <sch:title>Schematron Validator for cardlist</sch:title> <sch:pattern name="valid card number"> <sch:rule context="card"> <sch:assert test="document(concat('https://secure.cdyne.com/creditcardverify/luhnchecker.asmx/CheckCC?CardNumber=', @number))/cdyne:ReturnIndicator/cdyne:CardValid = 'true'">Invalid card number</sch:assert> </sch:rule> </sch:pattern> </sch:schema> (this actually works - apologies to cdyne.com if the service starts getting hammered) Obviously the choice between schema build time, schema load time and field validation time calls involves performance, server workload and versional integrity issues which should be considered carefully. Francis.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format