[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML Schema: Getting lookup tables from DB


load dataset from xml
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.