N
Neil Whitlow
I understand constraints on elements for the most part, but haven't
been able to find an explanation of a constraint that depends on other
elements within the document.
Assume I have something along the lines of the following in a
document:
<DataSet>
<DataTable name="InvoiceTable">
<DataColumn>InvoiceID</DataColumn>
<DataColumn>VendorID</DataColumn>
etc, etc, etc.
</DataTable>
<DataTable name="VendorTable">
<DataColumn>VendorID</DataColumn>
<DataColumn>VendorName</DataColumn>
etc, etc, etc.
</DataTable>
<Relation>
<ParentTable name="VendorTable" relatedcolumn="VendorID">
</ParentTable>
<ChildTable name="InvoiceTable" relatedcolumn="VendorID">
</ChildTable>
</Relation>
</DataSet>
I have minoccurs = 1/max occurs = unbounded on the DataTable element.
I may have as many or as few as I want as long as I have 1. The
Relation element is purely optional, minoccurs = 0.
What I cannot figure out is how to require "at least 2" DataTable
elements **IF** there is a Relation element in the document. I still
want to keep the general rule for DataTables to be (1 to unbounded),
UNLESS there is a Relation element that means two are required.
How do can you get the schema to look for the presence of other
elements in the document in order to validate a constraint like that?
Is there some special constraint I'm missing where you can specify
some XPath query as an attribute (an Xpath query that looks for the
presence of a Relation element)?
I'd also like it to enforce that the name attribute of the Parent and
Child tables in the Relation are actually the names of DataTable
elements that appear earlier in the document.
And as overkill, what about making sure that the relatedcolumn
attributes are the names of actual DataColumns that appear in the
given DataTable nodes.
Any help or direction anyone could provide on this would be most
appreciated.
been able to find an explanation of a constraint that depends on other
elements within the document.
Assume I have something along the lines of the following in a
document:
<DataSet>
<DataTable name="InvoiceTable">
<DataColumn>InvoiceID</DataColumn>
<DataColumn>VendorID</DataColumn>
etc, etc, etc.
</DataTable>
<DataTable name="VendorTable">
<DataColumn>VendorID</DataColumn>
<DataColumn>VendorName</DataColumn>
etc, etc, etc.
</DataTable>
<Relation>
<ParentTable name="VendorTable" relatedcolumn="VendorID">
</ParentTable>
<ChildTable name="InvoiceTable" relatedcolumn="VendorID">
</ChildTable>
</Relation>
</DataSet>
I have minoccurs = 1/max occurs = unbounded on the DataTable element.
I may have as many or as few as I want as long as I have 1. The
Relation element is purely optional, minoccurs = 0.
What I cannot figure out is how to require "at least 2" DataTable
elements **IF** there is a Relation element in the document. I still
want to keep the general rule for DataTables to be (1 to unbounded),
UNLESS there is a Relation element that means two are required.
How do can you get the schema to look for the presence of other
elements in the document in order to validate a constraint like that?
Is there some special constraint I'm missing where you can specify
some XPath query as an attribute (an Xpath query that looks for the
presence of a Relation element)?
I'd also like it to enforce that the name attribute of the Parent and
Child tables in the Relation are actually the names of DataTable
elements that appear earlier in the document.
And as overkill, what about making sure that the relatedcolumn
attributes are the names of actual DataColumns that appear in the
given DataTable nodes.
Any help or direction anyone could provide on this would be most
appreciated.