我有以下XML(1.0):
GrandChildElements
所有子元素和孙元素都有不同的名称。
我的问题是:如何在XSD中将同一个元素(非子元素)中Childelement1
的总数限制为小于5?例如,如果GrandChildElement
列出了3 ChildElement2
,那么GrandChildElements
最多只能有void truncate( char *str, size_t len )
{
size_t r; // index from which we read the next character (source)
size_t w; // index to which we write the next character (target)
size_t l; // Temp counter
r = w = 0;
l = len;
while ( str[r] )
{
if ( str[r] == ' ' ) // If we see a blank, reset the counter
{ // and write the blank to the target index
l = len;
str[w++] = str[r++];
}
else if ( l ) // If we don't see a blank and our counter
{ // isn't 0, write the character to the
--l; // target index, advance both source and
str[w++] = str[r++]; // target indices, decrement the counter
}
else // If we don't see a blank and the counter
{ // is 0, advance the source index.
r++;
}
}
str[w] = 0; // Make sure the result is 0-terminated
}
。