XSD and Date Range Validation
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开发者_C百科>
<BusinessPartnerID>2</BusinessPartnerID>
<Description>Test description</Description>
</transaction-item>
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.
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
精彩评论