I need to define XSD for this XML. I used value as complex type . but when i use value as complex type i am not able to parse the string value from Value in JAXB. I am getting a object only. If i declare value as simple type(String) i am not able to read the filename.what should i do..please help.
The schema 1.0 of w3c may not be expressive enough to fulfill seemingly an implicit condition that you've in mind, namely, if it has a non-whitespace text child (like "some string" in the first two datapoint), the element filename must be absent and conversely if filename element is present there must not be any non-whitespace non-negligible text node as its sibling. The best the schema can do is this.
I am using JAXB parser. i changed the schema as per your suggestion. Now i am able to read only normal string. I am not able to read the content inside the file name.. Do i have to use two XSD?
Joined: Jan 18, 2011
Do i have to use two XSD?
No. But as an aside, to use two xsd? in what sense?
Now i am able to read only normal string. I am not able to read the content inside the file name..
There may not be only one way to read correctly everything, but there sure are many ways to not be able to read the content inside the file name... If you want help, show a scaled down sample of how you do it. The xsd component I posted is capable of validating the value element for sure: only it is allowing slight more structure than your sample xml care to show - but sample is a sample, it is not supposed to be exhaustive or tacitly disallow everything not appeared in the sample. If you stick to your sample xml, it certainly won't blow up.
subject: JAXB- how to define XSD for XML with varying elements and parse using JAXB