Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

from XML doc to DTD

Posted on 2004-04-29
4
Medium Priority
?
260 Views
Last Modified: 2013-11-19
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].parent);

            if (tablesinfo[b].columns[r].parent.compareTo(tablesinfo[b].tname) ==
                0) {
              if (tablesinfo[b].columns[r].ctype.compareTo("ID") == 0) {
                Attr attr = doc.createAttribute(tablesinfo[b].columns[r].cname);
                attr = el.setAttributeNode(attr);
                out.print("<" + tablesinfo[b].columns[r].cname + ">");
                out.flush();
                out.print("</" + tablesinfo[b].columns[r].cname + ">");
                out.flush();

              }
              else {
                // Create Table's original columns NODES!
                Element c = doc.createElement(tablesinfo[b].columns[r].cname);
                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].parent;
              System.out.print(" - Subelement#" + countnest + nest[countnest] +
                               "has cols : ");
              countnest++;
              sube = doc.createElement(nest[countnest - 1]);
              el.appendChild(sube);
              out.print("<" + sube.getNodeName() + ">");
              out.flush();

              do {
                System.out.println("- Col#" + r + " is :" +
                                   tablesinfo[b].columns[r].cname);
                Element c = doc.createElement(tablesinfo[b].columns[r].cname);
                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[countnest - 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.err);
    } //end catch
  }
0
Comment
Question by:ousa
  • 2
2 Comments
 

Accepted Solution

by:
joshuasherlock earned 500 total points
ID: 11012009
If you just want to create a one off DTD based on the XML you can try XMLSPY 2004 (www.altova.com). this will auto generate a DTD for you. However, as you are decided the format of the XML programatically you could write a generic DTD that defines the format that you expect your program to produce.

Another alternative is to use XSLT and your databases XML extensions (for example, the Oracle XDK with XSQL). First, you would  to extract the data from the database in a standard XML format then use XSL to transform the XML into your desired format. Would reduce the amount of coding needed but would require a bit of a learning curve on XSLT.

With more information on the nature of the problem I may be able to be more specific
0
 

Expert Comment

by:joshuasherlock
ID: 11709867
Thanks Modulo
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question