1

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>
4

2 回答 2

2

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.

于 2013-03-31T09:45:52.297 回答
1

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.

于 2013-03-31T01:11:16.753 回答