Reputation: 2578
Could anyone please explain to me the use of the xs:list
datatype? This could fit nicely for my application, as the .xml file should have a list (of labels) that I need to create list of object with that label. My question is: Do I have to loop through the items of the list (and fill a collection inside my programm with them) or is there some automated mechanism that fills a collection with a XML list? If I have to do it manually, whats the difference between a xs:list
and a string separated by whitespaces?
I hope I managed to get my question across!
EDIT: Im using Qt to parse XML. Probably the SAX route.
Upvotes: 1
Views: 615
Reputation: 2578
Actually, the class QXmlQuery
does exactly what I wanted.
Its method bool QXmlQuery::evaluateTo ( QStringList * target ) const
requires a sequence of xs:string
values and fills target
with them.
Upvotes: 0
Reputation: 21638
Since you're not indicating a specific processor (e.g. JAXB or XSD.EXE or etc.) one cannot be specific... Although, as a general rule, list (and unions for that matter) are poorly supported.
In an ideal world, tools are to see it is a list, and the generated code (in an XML to code binding scenario) should provide you with a field, type of array, that would give you the things parsed already. Where tools fall short, you have to do it by hand, no difference there.
However, if you also do validation, then at least each item in the list will be neatly validated for you; whereas without it, you're - again - on your own.
Upvotes: 2
Reputation: 80166
If you use xs:list
then it will be parsed and exposed as a collection/array data structure if you are using code generators. If you just use a string separated by white spaces then it will be exposed as a regular string and you will be responsible for parsing.
The difference is only if you are using xsd based code generators. If you are parsing using low-level api's like SAX or DOM then there is no difference.
Upvotes: 2