Here's a much more precise explanation. I have scalled down to pure JAXB to
understand to problem.
I have generated my java classes using this command:
xjc -d ./src MySchema.xsd
Everything compiles. Nice!. Here's a part of my xsd in problem:
...
.....
Here's the generated **EN** class:
....
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EN", propOrder = {
"content"
})
@XmlSeeAlso({
ON.class,
PN.class,
TN.class
})
public class EN {
@XmlElementRefs({
@XmlElementRef(name = "delimiter", namespace =
"urn:hl7-org:v3", type = JAXBElement.class),
@XmlElementRef(name = "validTime", namespace =
"urn:hl7-org:v3", type = JAXBElement.class),
@XmlElementRef(name = "suffix", namespace = "urn:hl7-org:v3",
type = JAXBElement.class),
@XmlElementRef(name = "prefix", namespace = "urn:hl7-org:v3",
type = JAXBElement.class),
@XmlElementRef(name = "family", namespace = "urn:hl7-org:v3",
type = JAXBElement.class),
@XmlElementRef(name = "given", namespace = "urn:hl7-org:v3",
type = JAXBElement.class)
})
@XmlMixed
protected List content;
......
Here's the related XML example file in problem (fits with the above
XSD) :
...
Smith
John
...
Here's the java code doing the unmarshalling in problem:
...
for (Serializable s :
pPersonName.getValue().getContent()) {
if (s instanceof String) {
System.out.print((String) s);
} else {
String tag = ((JAXBElement)
s).getName().getLocalPart();
if (s instanceof EnFamily) {
EnFamily chunk = (EnFamily)
((JAXBElement) s).getValue();
System.out.print("(" + tag +
":");
}
}
}
...
And here's my problem: The class **EnFamily** extracted from a
JAXBElement does not contain any values. It should contain "Smith". It
seems it is not unmarshalling correctly.
Any help appreciated!
--
View this message in context:
http://cxf.547215.n5.nabble.com/How-to-get-String-values-out-of-a-JAXBElement-object-tp3424129p3782616.html
Sent from the cxf-user mailing list archive at Nabble.com.