How to render no data node as ?
I generated xml through jaxb , but the problem is when the data is empty then the rendered node is <node />
. I want it to be <node></node>
here is my codes :
@XmlRootElement(name = "record")
public class ReglementXMLBean {
private String CODE_FOUR;
private String NUM_FACT;
private String FACT_FOU;
private String DTE_REG;
private String REF_REG;
private String MODE_REG;
private String MT_REG_DEV;
private String MT_REG;
private String DEVISE;
private String TYPE_REG;
public String getCODE_FOUR() {
return CODE_FOUR;
}
@XmlElement
public void setCODE_FOUR(String cODE_FOUR) {
CODE_FOUR = cODE_FOUR;
}
public String getNUM_FACT() {
return NUM_FACT;
}
@XmlElement
public void setNUM_FACT(String nUM_FACT) {
NUM_FACT = nUM_FACT;
}
public String getFACT_FOU() {
return FACT_FOU;
}
@XmlElement
public void setFACT_FOU(String fACT_FOU) {
FACT_FOU = fACT_FOU;
}
public String getDTE_REG() {
return DTE_REG;
}
@XmlElement
public void setDTE_REG(String dTE_REG) {
DTE_REG = dTE_REG;
}
public String getREF_REG() {
return REF_REG;
}
@XmlElement
public void setREF_REG(String rEF_REG) {
REF_REG = rEF_REG;
}
public String getMODE_REG() {
return MODE_REG;
}
@XmlElement
public void setMODE_REG(String mODE_REG) {
MODE_REG = mODE_REG;
}
public String getMT_REG_DEV() {
return MT_REG_DEV;
}
@XmlElement
public void setMT_REG_DEV(String mT_REG_DEV) {
MT_REG_DEV = mT_REG_DEV;
}
public String getMT_REG() {
return MT_REG;
}
@XmlElement
public void setMT_REG(String mT_REG) {
MT_REG = mT_REG;
}
public String getDEVISE() {
return DEVISE;
}
@XmlElement
public void setDEVISE(String dEVISE) {
DEVISE = dEVISE;
}
public String getTYPE_REG() {
return TYPE_REG;
}
@XmlElement
public void setTYPE_REG(String tYPE_REG) {
TYPE_REG = tYPE_REG;
}
}
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
ReglementXMLBean reglementXMLBean = new ReglementXMLBean();
while ((line = br.readLine()) != null) {
String colonnes = line.split(cvsSplitBy);
reglementXMLBean.setCODE_FOUR(colonnes[0]);
reglementXMLBean.setNUM_FACT(colonnes[1]);
reglementXMLBean.setFACT_FOU(colonnes[2]);
reglementXMLBean.setDTE_REG(colonnes[3]);
reglementXMLBean.setREF_REG(colonnes[4]);
reglementXMLBean.setMODE_REG(colonnes[5]);
reglementXMLBean.setMT_REG_DEV(colonnes[6]);
reglementXMLBean.setMT_REG(colonnes[7]);
reglementXMLBean.setDEVISE(colonnes[8]);
reglementXMLBean.setTYPE_REG(colonnes[9]);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ReglementXMLBean.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(reglementXMLBean, out);
jaxbMarshaller.marshal(reglementXMLBean, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
jaxb
add a comment |
I generated xml through jaxb , but the problem is when the data is empty then the rendered node is <node />
. I want it to be <node></node>
here is my codes :
@XmlRootElement(name = "record")
public class ReglementXMLBean {
private String CODE_FOUR;
private String NUM_FACT;
private String FACT_FOU;
private String DTE_REG;
private String REF_REG;
private String MODE_REG;
private String MT_REG_DEV;
private String MT_REG;
private String DEVISE;
private String TYPE_REG;
public String getCODE_FOUR() {
return CODE_FOUR;
}
@XmlElement
public void setCODE_FOUR(String cODE_FOUR) {
CODE_FOUR = cODE_FOUR;
}
public String getNUM_FACT() {
return NUM_FACT;
}
@XmlElement
public void setNUM_FACT(String nUM_FACT) {
NUM_FACT = nUM_FACT;
}
public String getFACT_FOU() {
return FACT_FOU;
}
@XmlElement
public void setFACT_FOU(String fACT_FOU) {
FACT_FOU = fACT_FOU;
}
public String getDTE_REG() {
return DTE_REG;
}
@XmlElement
public void setDTE_REG(String dTE_REG) {
DTE_REG = dTE_REG;
}
public String getREF_REG() {
return REF_REG;
}
@XmlElement
public void setREF_REG(String rEF_REG) {
REF_REG = rEF_REG;
}
public String getMODE_REG() {
return MODE_REG;
}
@XmlElement
public void setMODE_REG(String mODE_REG) {
MODE_REG = mODE_REG;
}
public String getMT_REG_DEV() {
return MT_REG_DEV;
}
@XmlElement
public void setMT_REG_DEV(String mT_REG_DEV) {
MT_REG_DEV = mT_REG_DEV;
}
public String getMT_REG() {
return MT_REG;
}
@XmlElement
public void setMT_REG(String mT_REG) {
MT_REG = mT_REG;
}
public String getDEVISE() {
return DEVISE;
}
@XmlElement
public void setDEVISE(String dEVISE) {
DEVISE = dEVISE;
}
public String getTYPE_REG() {
return TYPE_REG;
}
@XmlElement
public void setTYPE_REG(String tYPE_REG) {
TYPE_REG = tYPE_REG;
}
}
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
ReglementXMLBean reglementXMLBean = new ReglementXMLBean();
while ((line = br.readLine()) != null) {
String colonnes = line.split(cvsSplitBy);
reglementXMLBean.setCODE_FOUR(colonnes[0]);
reglementXMLBean.setNUM_FACT(colonnes[1]);
reglementXMLBean.setFACT_FOU(colonnes[2]);
reglementXMLBean.setDTE_REG(colonnes[3]);
reglementXMLBean.setREF_REG(colonnes[4]);
reglementXMLBean.setMODE_REG(colonnes[5]);
reglementXMLBean.setMT_REG_DEV(colonnes[6]);
reglementXMLBean.setMT_REG(colonnes[7]);
reglementXMLBean.setDEVISE(colonnes[8]);
reglementXMLBean.setTYPE_REG(colonnes[9]);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ReglementXMLBean.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(reglementXMLBean, out);
jaxbMarshaller.marshal(reglementXMLBean, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
jaxb
1
Can you explain why you need this? Because the meaning of<node/>
is exactly the same as<node></node>
and any sane XML parser will parse them in the same way. In other words, this should not matter.
– Jesper
2 days ago
it s a requirement from my boss :) lol
– pheromix
2 days ago
1
Possible duplicate of How to generate end tag for empty elelemt in XML using JAXB
– pirho
2 days ago
add a comment |
I generated xml through jaxb , but the problem is when the data is empty then the rendered node is <node />
. I want it to be <node></node>
here is my codes :
@XmlRootElement(name = "record")
public class ReglementXMLBean {
private String CODE_FOUR;
private String NUM_FACT;
private String FACT_FOU;
private String DTE_REG;
private String REF_REG;
private String MODE_REG;
private String MT_REG_DEV;
private String MT_REG;
private String DEVISE;
private String TYPE_REG;
public String getCODE_FOUR() {
return CODE_FOUR;
}
@XmlElement
public void setCODE_FOUR(String cODE_FOUR) {
CODE_FOUR = cODE_FOUR;
}
public String getNUM_FACT() {
return NUM_FACT;
}
@XmlElement
public void setNUM_FACT(String nUM_FACT) {
NUM_FACT = nUM_FACT;
}
public String getFACT_FOU() {
return FACT_FOU;
}
@XmlElement
public void setFACT_FOU(String fACT_FOU) {
FACT_FOU = fACT_FOU;
}
public String getDTE_REG() {
return DTE_REG;
}
@XmlElement
public void setDTE_REG(String dTE_REG) {
DTE_REG = dTE_REG;
}
public String getREF_REG() {
return REF_REG;
}
@XmlElement
public void setREF_REG(String rEF_REG) {
REF_REG = rEF_REG;
}
public String getMODE_REG() {
return MODE_REG;
}
@XmlElement
public void setMODE_REG(String mODE_REG) {
MODE_REG = mODE_REG;
}
public String getMT_REG_DEV() {
return MT_REG_DEV;
}
@XmlElement
public void setMT_REG_DEV(String mT_REG_DEV) {
MT_REG_DEV = mT_REG_DEV;
}
public String getMT_REG() {
return MT_REG;
}
@XmlElement
public void setMT_REG(String mT_REG) {
MT_REG = mT_REG;
}
public String getDEVISE() {
return DEVISE;
}
@XmlElement
public void setDEVISE(String dEVISE) {
DEVISE = dEVISE;
}
public String getTYPE_REG() {
return TYPE_REG;
}
@XmlElement
public void setTYPE_REG(String tYPE_REG) {
TYPE_REG = tYPE_REG;
}
}
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
ReglementXMLBean reglementXMLBean = new ReglementXMLBean();
while ((line = br.readLine()) != null) {
String colonnes = line.split(cvsSplitBy);
reglementXMLBean.setCODE_FOUR(colonnes[0]);
reglementXMLBean.setNUM_FACT(colonnes[1]);
reglementXMLBean.setFACT_FOU(colonnes[2]);
reglementXMLBean.setDTE_REG(colonnes[3]);
reglementXMLBean.setREF_REG(colonnes[4]);
reglementXMLBean.setMODE_REG(colonnes[5]);
reglementXMLBean.setMT_REG_DEV(colonnes[6]);
reglementXMLBean.setMT_REG(colonnes[7]);
reglementXMLBean.setDEVISE(colonnes[8]);
reglementXMLBean.setTYPE_REG(colonnes[9]);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ReglementXMLBean.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(reglementXMLBean, out);
jaxbMarshaller.marshal(reglementXMLBean, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
jaxb
I generated xml through jaxb , but the problem is when the data is empty then the rendered node is <node />
. I want it to be <node></node>
here is my codes :
@XmlRootElement(name = "record")
public class ReglementXMLBean {
private String CODE_FOUR;
private String NUM_FACT;
private String FACT_FOU;
private String DTE_REG;
private String REF_REG;
private String MODE_REG;
private String MT_REG_DEV;
private String MT_REG;
private String DEVISE;
private String TYPE_REG;
public String getCODE_FOUR() {
return CODE_FOUR;
}
@XmlElement
public void setCODE_FOUR(String cODE_FOUR) {
CODE_FOUR = cODE_FOUR;
}
public String getNUM_FACT() {
return NUM_FACT;
}
@XmlElement
public void setNUM_FACT(String nUM_FACT) {
NUM_FACT = nUM_FACT;
}
public String getFACT_FOU() {
return FACT_FOU;
}
@XmlElement
public void setFACT_FOU(String fACT_FOU) {
FACT_FOU = fACT_FOU;
}
public String getDTE_REG() {
return DTE_REG;
}
@XmlElement
public void setDTE_REG(String dTE_REG) {
DTE_REG = dTE_REG;
}
public String getREF_REG() {
return REF_REG;
}
@XmlElement
public void setREF_REG(String rEF_REG) {
REF_REG = rEF_REG;
}
public String getMODE_REG() {
return MODE_REG;
}
@XmlElement
public void setMODE_REG(String mODE_REG) {
MODE_REG = mODE_REG;
}
public String getMT_REG_DEV() {
return MT_REG_DEV;
}
@XmlElement
public void setMT_REG_DEV(String mT_REG_DEV) {
MT_REG_DEV = mT_REG_DEV;
}
public String getMT_REG() {
return MT_REG;
}
@XmlElement
public void setMT_REG(String mT_REG) {
MT_REG = mT_REG;
}
public String getDEVISE() {
return DEVISE;
}
@XmlElement
public void setDEVISE(String dEVISE) {
DEVISE = dEVISE;
}
public String getTYPE_REG() {
return TYPE_REG;
}
@XmlElement
public void setTYPE_REG(String tYPE_REG) {
TYPE_REG = tYPE_REG;
}
}
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
ReglementXMLBean reglementXMLBean = new ReglementXMLBean();
while ((line = br.readLine()) != null) {
String colonnes = line.split(cvsSplitBy);
reglementXMLBean.setCODE_FOUR(colonnes[0]);
reglementXMLBean.setNUM_FACT(colonnes[1]);
reglementXMLBean.setFACT_FOU(colonnes[2]);
reglementXMLBean.setDTE_REG(colonnes[3]);
reglementXMLBean.setREF_REG(colonnes[4]);
reglementXMLBean.setMODE_REG(colonnes[5]);
reglementXMLBean.setMT_REG_DEV(colonnes[6]);
reglementXMLBean.setMT_REG(colonnes[7]);
reglementXMLBean.setDEVISE(colonnes[8]);
reglementXMLBean.setTYPE_REG(colonnes[9]);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ReglementXMLBean.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(reglementXMLBean, out);
jaxbMarshaller.marshal(reglementXMLBean, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
jaxb
jaxb
asked 2 days ago
pheromixpheromix
5,570155093
5,570155093
1
Can you explain why you need this? Because the meaning of<node/>
is exactly the same as<node></node>
and any sane XML parser will parse them in the same way. In other words, this should not matter.
– Jesper
2 days ago
it s a requirement from my boss :) lol
– pheromix
2 days ago
1
Possible duplicate of How to generate end tag for empty elelemt in XML using JAXB
– pirho
2 days ago
add a comment |
1
Can you explain why you need this? Because the meaning of<node/>
is exactly the same as<node></node>
and any sane XML parser will parse them in the same way. In other words, this should not matter.
– Jesper
2 days ago
it s a requirement from my boss :) lol
– pheromix
2 days ago
1
Possible duplicate of How to generate end tag for empty elelemt in XML using JAXB
– pirho
2 days ago
1
1
Can you explain why you need this? Because the meaning of
<node/>
is exactly the same as <node></node>
and any sane XML parser will parse them in the same way. In other words, this should not matter.– Jesper
2 days ago
Can you explain why you need this? Because the meaning of
<node/>
is exactly the same as <node></node>
and any sane XML parser will parse them in the same way. In other words, this should not matter.– Jesper
2 days ago
it s a requirement from my boss :) lol
– pheromix
2 days ago
it s a requirement from my boss :) lol
– pheromix
2 days ago
1
1
Possible duplicate of How to generate end tag for empty elelemt in XML using JAXB
– pirho
2 days ago
Possible duplicate of How to generate end tag for empty elelemt in XML using JAXB
– pirho
2 days ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252838%2fhow-to-render-no-data-node-as-node-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252838%2fhow-to-render-no-data-node-as-node-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Can you explain why you need this? Because the meaning of
<node/>
is exactly the same as<node></node>
and any sane XML parser will parse them in the same way. In other words, this should not matter.– Jesper
2 days ago
it s a requirement from my boss :) lol
– pheromix
2 days ago
1
Possible duplicate of How to generate end tag for empty elelemt in XML using JAXB
– pirho
2 days ago