Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2009, 08:37 AM
Registered User
 
Join Date: Feb 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default is there a similar construct to if-statements in xsd?

Is it possible to use a xsd schema against an xml file that validates the xml file in the following ways:
1. if coursecode is empty, location must equal 8
2. if signupdate < todaysdate then totalpayment = amount - 100

Thanks
 
Old March 24th, 2009, 08:46 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

The W3C XML schema language in version 1 does not allow you to model such constraints.
You might want to try Schematron instead. And the version 1.1 of the W3C schema language that is under development will allow you to model such constraints too I think.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 24th, 2009, 08:59 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Not in XSD 1.0. In 1.1 (you can try it out with Saxon-SA 9.1) you can write assertions, for example

<xs:assert test="coursecode != '' or location eq 8.2"/>
<xs:assert test="signupdate ge current-dateTime() or totalpayment = amount - 100"/>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Construct checkbox with Javascript BananaJim Javascript How-To 4 April 30th, 2012 02:32 AM
XSD.EXE Gen’d C# Deserializing w/ .xsd Subst Group greenstone XML 0 November 9th, 2007 09:27 PM
Use variables or other construct? jacob XSLT 4 November 15th, 2005 08:06 AM
Merging XSD files in one XSD file by using what? haoxuqian XML 1 November 4th, 2005 01:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.