ousa
asked on
from XML doc to DTD
how to convert from XML document to DTD using jbuilder
i do the fooling but not yet could solve the problem
this program convert from db to xml (supposed to do that)
out.write("<" + el.getNodeName() + ">");
out.flush();
for (int r = 0; r < tablesinfo[b].tsize; r++) {
System.out.println("\n - r = " + r);
System.out.println("\n - table parent = " +
tablesinfo[b].columns[r].p arent);
if (tablesinfo[b].columns[r]. parent.com pareTo(tab lesinfo[b] .tname) ==
0) {
if (tablesinfo[b].columns[r]. ctype.comp areTo("ID" ) == 0) {
Attr attr = doc.createAttribute(tables info[b].co lumns[r].c name);
attr = el.setAttributeNode(attr);
out.print("<" + tablesinfo[b].columns[r].c name + ">");
out.flush();
out.print("</" + tablesinfo[b].columns[r].c name + ">");
out.flush();
}
else {
// Create Table's original columns NODES!
Element c = doc.createElement(tablesin fo[b].colu mns[r].cna me);
el.appendChild(c);
out.print("<" + c.getNodeName() + ">");
out.flush();
out.print("</" + c.getNodeName() + ">");
out.flush();
Node parent = c.getParentNode();
c = (Element) parent;
}
}
else {
// Create NEST Node's Nodes...
nest[countnest] = tablesinfo[b].columns[r].p arent;
System.out.print(" - Subelement#" + countnest + nest[countnest] +
"has cols : ");
countnest++;
sube = doc.createElement(nest[cou ntnest - 1]);
el.appendChild(sube);
out.print("<" + sube.getNodeName() + ">");
out.flush();
do {
System.out.println("- Col#" + r + " is :" +
tablesinfo[b].columns[r].c name);
Element c = doc.createElement(tablesin fo[b].colu mns[r].cna me);
sube.appendChild(c);
out.print("<" + c.getNodeName() + ">");
out.flush();
out.print("</" + c.getNodeName() + ">");
out.flush();
r++;
}
while ( (r < tablesinfo[b].tsize) &&
(tablesinfo[b].columns[r].
parent.compareTo(nest[coun tnest - 1]) == 0));
out.print("</" + sube.getNodeName() + ">");
out.flush();
r--;
}
}
out.write("</" + el.getNodeName() + ">");
out.flush();
}
}
out.print("</" + rootEl.getNodeName() + ">");
out.flush();
out.close();
}
catch (Exception e) {
e.printStackTrace(System.e rr);
} //end catch
}
i do the fooling but not yet could solve the problem
this program convert from db to xml (supposed to do that)
out.write("<" + el.getNodeName() + ">");
out.flush();
for (int r = 0; r < tablesinfo[b].tsize; r++) {
System.out.println("\n - r = " + r);
System.out.println("\n - table parent = " +
tablesinfo[b].columns[r].p
if (tablesinfo[b].columns[r].
0) {
if (tablesinfo[b].columns[r].
Attr attr = doc.createAttribute(tables
attr = el.setAttributeNode(attr);
out.print("<" + tablesinfo[b].columns[r].c
out.flush();
out.print("</" + tablesinfo[b].columns[r].c
out.flush();
}
else {
// Create Table's original columns NODES!
Element c = doc.createElement(tablesin
el.appendChild(c);
out.print("<" + c.getNodeName() + ">");
out.flush();
out.print("</" + c.getNodeName() + ">");
out.flush();
Node parent = c.getParentNode();
c = (Element) parent;
}
}
else {
// Create NEST Node's Nodes...
nest[countnest] = tablesinfo[b].columns[r].p
System.out.print(" - Subelement#" + countnest + nest[countnest] +
"has cols : ");
countnest++;
sube = doc.createElement(nest[cou
el.appendChild(sube);
out.print("<" + sube.getNodeName() + ">");
out.flush();
do {
System.out.println("- Col#" + r + " is :" +
tablesinfo[b].columns[r].c
Element c = doc.createElement(tablesin
sube.appendChild(c);
out.print("<" + c.getNodeName() + ">");
out.flush();
out.print("</" + c.getNodeName() + ">");
out.flush();
r++;
}
while ( (r < tablesinfo[b].tsize) &&
(tablesinfo[b].columns[r].
parent.compareTo(nest[coun
out.print("</" + sube.getNodeName() + ">");
out.flush();
r--;
}
}
out.write("</" + el.getNodeName() + ">");
out.flush();
}
}
out.print("</" + rootEl.getNodeName() + ">");
out.flush();
out.close();
}
catch (Exception e) {
e.printStackTrace(System.e
} //end catch
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks Modulo