Программисты JAVA общаются здесь
-
Anonymous
Как исключить тег «xs:type» при расширении переходного процесса
Сообщение
Anonymous »
Желаемый результат:
Легкое переключение между
и
Мой код
Код: Выделить всё
@XmlRootElement(name= "root")
public class Root {
@XmlElement(name="child")
public Child child
}
@XmlRootElement(name= "root")
public class ExtendedRoot extends Root {
@XmlElement(name="child")
public ExtendedChild child
}
@XmlTransient
public class Child {
// prop1, prop2
}
@XmlType(propOrder = {"prop1", "prop3","prop4", "prop2"})
public class ExtendedChild extends Child {
// prop3, prop4
}
System.setProperty("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory")
Class clazz = extendChild ? ExtendedRoot.class : Root.class;
JAXBContext jc = JAXBContext.newInstance(clazz);
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(formattedJob, tempFile);
Фактический результат
Как исключить этот xs:type=... из дочернего тега?
Подробнее здесь:
https://stackoverflow.com/questions/792 ... -transient
1734946144
Anonymous
[h4]Желаемый результат:[/h4]
Легкое переключение между
[code]
..
..
[/code]
и
[code]
..
..
..
..
[/code]
[h4]Мой код[/h4]
[code]@XmlRootElement(name= "root")
public class Root {
@XmlElement(name="child")
public Child child
}
@XmlRootElement(name= "root")
public class ExtendedRoot extends Root {
@XmlElement(name="child")
public ExtendedChild child
}
@XmlTransient
public class Child {
// prop1, prop2
}
@XmlType(propOrder = {"prop1", "prop3","prop4", "prop2"})
public class ExtendedChild extends Child {
// prop3, prop4
}
System.setProperty("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory")
Class clazz = extendChild ? ExtendedRoot.class : Root.class;
JAXBContext jc = JAXBContext.newInstance(clazz);
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(formattedJob, tempFile);
[/code]
Фактический результат
[code]
..
..
..
..
[/code]
Как исключить этот xs:type=... из дочернего тега?
Подробнее здесь: [url]https://stackoverflow.com/questions/79296985/how-to-exclude-xstype-tag-when-extending-a-transient[/url]