Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Automatically creating data validation module from XSD

by Zaxo (Archbishop)
on Aug 10, 2007 at 04:19 UTC ( #631699=note: print w/replies, xml ) Need Help??

in reply to Automatically creating data validation module from XSD

I think Tie::Constrained will do what you want. It will let you tie a scalar from your structure to some particular condition through a boolean coderef.

An attempt to assign an invalid value (meaning it fails the condition) invokes a failure function which you can define for each type.

Inheritance is the preferred way to specialize Tie::Constrained to a type.

I've discussed and demonstrated Tie::Constrained in several pm articles: To Validate Data In Lvalue Subs, Tie Me Up, Tie Me Down, Re^2: Writing general code: real world example - and doubts! (reply to you!), and in the my Dog $spot; thread.

Part of the problem of combining attributes automatically under Tie::Constrained can be handled by the trick I showed in FunkOpera: Abstracting Perl Operators (where did I get that silly name? . . .). The skeletal shown there overloads operators to combine coderefs to return a coderef which combines their returns in the suitable way.

Sorry, I've never done anything significant with xml, so I don't really understand what I can take as given in your problem. I think the base types would need to be hand encoded, but user-defined ones might be automated through some XML magic and an extension of the unfortunately named

After Compline,

  • Comment on Re: Automatically creating data validation module from XSD

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://631699]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2016-10-25 23:50 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.