Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Writing to DTD Document

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Writing to DTD Document

    Hi,

    I'm a student for software engineering and i'm doing my final project about merging XML documents by merging their DTD's.
    I'm using oracle.xml.parser.v2 Package for this task,
    I'm using DOMParser.parseDTD.getDoctype() to get the DTD documents, and the DTD Object to get the ElementDecl and AttrDecl to do the comparison between the two DTD files.
    The problem is when I want to create new ElementDecl that suits both DTD and than add it to a new DTD file but I don't see any ADD, INSERT, APPEND or SET methods in the DTD class, just GETs methods, so I can't figure out how to write a new DTD file.

    Thanks.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,337
    My Mood
    Hungover
    Thanks
    143
    Thanked 624 Times in 535 Posts

    Default Re: Writing to DTD Document

    This thread has been cross posted here:

    http://www.java-forums.org/xml/52349-writing-dtd-document.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing to DTD Document

    sorry, didn't knew about Cross Posting ,this question is posted on :

    javaprogrammingforums
    java-forums.org
    java.net
    codeguru.com
    forums.oracle.com

    no help for now,
    it is very important for me so if anyone have any clues or ideas please, please, please reply.

    sorry again.

  4. #4
    Member
    Join Date
    Dec 2011
    Posts
    48
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Writing to DTD Document

    Consider using oracle.xml.parser.v2.NodeFactory

    NodeFactory (OracleŽ XML Java API Reference)

    PS. Sorry, on further inspection, it appears that the APIs treat the DTD as read only, and you can only create non-DTD nodes through the NodeFactory!

    DTD class gives you the methods to read your DTD. You will have to serially construct your merged DTD because there is no way to update that part of the DOM model through the API, by the looks of things. It is not that difficult though is it? Just concatenate the serialized representations of the nodes in the correct order and print them to a PrintStream?
    Last edited by 2by4; December 12th, 2011 at 03:28 PM.

  5. #5
    Member
    Join Date
    Dec 2011
    Posts
    48
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Writing to DTD Document

    Just found this which confirms what I posted above..

    Interface DocumentType

    Each Document has a doctype attribute whose value is either null or a DocumentType object. The DocumentType interface in the DOM Core provides an interface to the list of entities that are defined for the document, and little else because the effect of namespaces and the various XML schema efforts on DTD representation are not clearly understood as of this writing.

    DOM Level 3 doesn't support editing DocumentType nodes. DocumentType nodes are read-only.
    Document Object Model Core

    So there you go. The latest DOM Model does not support editing the DTD through the model. You will have to construct it serially and print it out to your own PrintStream. :-)
    Last edited by 2by4; December 12th, 2011 at 03:44 PM.

Similar Threads

  1. How to set Document Filter
    By nimishalex in forum AWT / Java Swing
    Replies: 0
    Last Post: December 27th, 2010, 02:32 AM
  2. Scanning Document Issue
    By redvenice in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 20th, 2010, 08:18 AM
  3. Upload Image / Document
    By systech44 in forum Java Servlet
    Replies: 1
    Last Post: August 11th, 2010, 09:42 AM
  4. How to read an XML document in Java with DOM Parse?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 20th, 2008, 07:04 AM
  5. How to read an XML document in Java with DOM Parse?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 20th, 2008, 07:04 AM

Tags for this Thread