I'm currently trying to map a part of a XML file but I can't find a proper way to it.
Here the XML file :
<tag.1>
...
<tag.2>
<tag.3>
<ns:tag.4 xmlns:ns="" att.4.1="" att.4.2=""/>
<ns:tag.5 xmlns:ns="" att.5.1="" att.5.2=""/>
<ns:tag.6 xmlns:ns="" att.6.1="" att.6.2=""/>
<ns:tag.7 xmlns:ns="" att.7.1="" att.7.2=""/>
<ns:tag.8 xmlns:ns="" att.8.1="" att.8.2=""/>
...
<ns:tag.9 xmlns:ns="" att.9.1="" att.9.2=""/>
<ns:tag.9 xmlns:ns="" att.9.1="" att.9.2=""/>
<ns:tag.9 xmlns:ns="" att.9.1="" att.9.2=""/>
...
</tag.3>
</tag.2>
Here's the target OO structure :
class Foo {
private Tag.4 tag.4;
private Tag.5 tag.5;
private Tag.6 tag.6;
private Tag.7 tag.7;
private Tag.8 tag.8;
private List<Tag.9> listTag.9;
}
class Tag.4 {
private String att.4.1;
private String att.4.2;
}
class Tag.5 {
private String att.5.1;
private String att.5.2;
}
class Tag.6 {
private String att.6.1;
private String att.6.2;
}
class Tag.7 {
private String att.7.1;
private String att.7.2;
}
class Tag.8 {
private String att.8.1;
private String att.8.2;
}
class Tag.9 {
private String att.9.1;
private String att.9.2;
}
I've tried in sereral ways, without success :
@XmlRootElement(name="tag.1")
class Foo {
@XmlElement(namespace="bar")
private Tag.4 tag.4;
}
@XmlRootElement(name="tag.3")
class Foo {
@XmlElement(name="tag.4", namespace="bar")
private Tag.4 tag.4;
}
@XmlRootElement(name="tag.1/tag.2/tag.3")
class Foo {
@XmlElement(name="tag.4", namespace="bar")
private Tag.4 tag.4;
}
@XmlRootElement(name="tag.1")
class Foo {
@XmlElement(name="tag.2/tag.3/tag.4" namespace="bar")
private Tag.4 tag.4;
}
In summary, I try to access tags 2 levels lower than the root without having to map the intermediate level.
Here's a link to the XML file I'm working on: YQL query
Thank you for reading and sorry for any mistakes.