can xsd ensure node count and not care about order

Nestor

New Member
I've tried several approaches to creating a schema for this problem, but I haven't had any success. I'm not really sure if it's possible.Basically, suppose I have a root node \[code\]<root>\[/code\] and it can have children \[code\]<A>\[/code\], \[code\]<B>\[/code\], and \[code\]<C>\[/code\].For each iteration of the program outputting the xml, A, B, and C nodes are made and appended as children to the root. Though, each iteration doesn't always use each A, B, and C... in which case it outputs no node. So I get something like this as an example:\[code\]<A>sfs</A> <!-- first iteration used A, B, and C --><B>sfs</B><C>ss</C><A>fff</A> <!-- second iteration used A, and C, not B --><C>ss</C><B>fff</B> <!-- third iteration used only B -->\[/code\]I didn't write the program that outputs it in this way, and have no real power over the format.What I do know for example, is there can never be more than 10 A's, 2 C's, 5 B's ever. Though, the order isn't guaranteed. So all I wanted was an XSD to determine that there are only A, B, and C nodes inside root and that there are no more than 10 A's, 2 C's, and 5 B's.I can achieve the first part by using xs:choice and maxOccurs unbounded. Which guarantees only A, B, and C nodes, but I can't seem to figure a way to enforce the number of them.Is there some clever workaround for this issue?
 
Back
Top