xml validation

Posted on 2004-11-02
Last Modified: 2013-11-23

 I am creating an xml document using DOM implementation by Xerces in java . I would like to validate each element using the pre-defined xml schema when its(xml file) created rather than validate the whole file at a time. Basically the idea is to get rid of the invalid xml elements (may get due to database errors) at the time of creating xml file itself. I know to set the validation features on the domparser to validate the whole file but need to know how can I validate element by element i.e on the fly. Can anyone help me with a snippet of the code to do this....

Thanks in advance !!!

Question by:pgoel
    LVL 1

    Expert Comment

    Whoa, know almost nothing of this, but its interesting.
    My limited knowledge of XML Parses tell me to ask you if you have considered
    DTD's although i dont know how they work I know they are used to check
    XML tags and invalidate the ones that dont match up to the DTD syntax.

    If you like, i could do some research later on at lunch time and help you out.

    But maybe you are too far an expert and already know DTDs, which, if you are I ask you
    to share the details here, so I can learn some :D

    Thanks in advance.
    LVL 6

    Accepted Solution


    there you find a book to download: javaandxml i think it was chapter 9!

    good luck

    to celdric:

    DTD just lets you check if a tag is present, madatory or optinal, but lets you not validate it´s value, therefore you use shemas...
    LVL 1

    Expert Comment

    Interesting, im gonna check the link too :D
    Regards mighty!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Top Freelancers to Complete Java Projects

    Source the talented Expert Exchange community
    for top quality work on your Java projects.

    Hire the best. Collaborate easily. Get quality work.

    Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now