简体   繁体   中英

How to write condition in XML Schema?

Is it possible to write condition in XML schema? I need to write restriction for start and end time. So that difference between start and end time must be greater than 1:00 hour. I am not sure how to do that? Sorry for my english i am not native speaker and thanks for help in advance.

 <?xml version='1.0' ?>
  <course xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="schema.xsd">
  <footnote></footnote>
  <sln>10637</sln>
  <prefix>ACCTG</prefix>
  <crs>230</crs>
  <lab></lab>
  <sect>01</sect>
  <title>INT FIN ACCT</title>
  <credit>1.0</credit>
  <days>TU,TH</days>
  <times>
     <start>7:45</start>
     <end>9:00</end>
  </times>
  <place>
      <bldg>TODD</bldg>
      <room>230</room>
  </place>
  <instructor>B. MCELDOWNEY</instructor>
  <limit>0112</limit>
  <enrolled>0108</enrolled>
</course>

If start and end were of type duration, you could write

Since they aren't, you will have to convert them to durations first:

(I'm assuming your format is HH:MM)

And then you'll have to find an XSD 1.1 processor, since xs:assert is only available with XSD 1.1. There are currently two XSD 1.1 processors available, Saxon and Xerces.

No, XML Schema is not sufficient for this. You need something like Schematron. A Schematron schema can be translated into an XSLT that validates XML documents against the schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM