Guys I'm new to xml in Java.
I have the following task. I need to parse some xml files (specificallyh xcb-proto [X11]) to generate the equivalent request protocol in java. There is already a well defined xsd and the respective xml for the protocol. What is the best and easiest approach/parser to solve this?
Example of existant xml content:
<request name="SetScreenSaver" opcode="107">
<pad bytes="1" />
<field type="INT16" name="timeout" />
<field type="INT16" name="interval" />
<field type="CARD8" name="prefer_blanking" enum="Blanking" />
<field type="CARD8" name="allow_exposures" enum="Exposures" />
</request>
This will generate a Java DOM (?) Object. And them with this I need to generate the given code in Java. For this case is:
Desired output:
public void setScreenSaver(int timeout, int interval, int preferBlanking, int allowExposures) {
RequestOutputStream o = outputStream;
synchronized (o) {
o.beginRequest(107, 0, 1); // Major Opcode , Minor Opcode, ReqLength
o.writeInt16(timeout);
o.writeInt16(interval);
o.writeInt8(preferBlanking);
o.writeInt8(allowExposures);
o.send();
}
}
It seems that XSOM is the one that gives the easier approach...
PS: I have never manipulated xml files in Java :3