views:

89

answers:

2

How would I write the XSD to validate the StartDate element and EndDate element are within the Quarter element and Year element? Thanks.

<OrganizationName>Chevron</OrganizationName>
<Quarter>4</Quarter>
<Year>2010</Year>
<Fuel>
 <FuelPathwayCode>CARBOBCB001</FuelPathwayCode>
 <PhysicalPathwayCode>PP001</PhysicalPathwayCode>
 <transaction-item type="Production or Import">
  <StartDate>2010-04-01</StartDate>
  <EndDate>2010-04-15</EndDate>
  <Amount>1000</Amount>
  <BusinessPartnerID>2</BusinessPartnerID>
  <Description>Test description</Description>
 </transaction-item>
+2  A: 

I think this is beyond the scope of what you can do in XSD. I don't think it supports inter element validation like that. Consider using X/Query or XSLT.

Francis Upton
+1 exactly, it doesn't.
marc_s
A: 

You could use the duration type instead of an enddate datetime. Currently duration type allows for negative values, though you could probably extend it to your own type to disallow that ability. This way you would never have an end time before start.

duration is at the bottom

Kevin Peno