R – XSD and Date Range Validation

daterangevalidationxsd

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>

Best Answer

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.