Validating an XML against an XSD - root element not found

Discussion in 'Java' started by Andrew Thompson, Sep 23, 2007.

  1. AAArrrghh! I have been trying to validate XML
    files against XSD files when both are on the
    local file system, on and off for the last month.

    It is 'almost' working, except that the validator
    always reports that the *root* element of the XML
    file is missing (for a JNLP file, that would be
    the jnlp element). Frustratingly, apart from that,
    it seems to work as I expect.

    Here is a zip of the current files (a build file,
    the Java source, and some XML and XSD files).
    <http://www.physci.org/test/xml/xmlvalidate.zip>
    (under 30 Kb). If you run the build.xml 'launch'
    task, it should compile (build etc.) and throw the
    GUI onto screen.

    The problem can be seen by openning (for example)
    yaxv.jnlp (which has an intentionally invalid
    attribute - 'tootip') into the left hand side of
    the GUI, then loading the JNLP-6.0.xsd into the
    RHS of the GUI and clicking the Validate button
    (lower left of GUI, above the list).

    This will produce an error list of three items.
    The second and third relate to the 'tootip', but
    I cannot figure why I am getting the first error...
    "cvc-elt. 1: Cannot find the delcaration of element 'jnlp'."

    If I validate the documents using the ant
    xmlvalidate task, it does not show that
    first error. That suggests it is not a
    problem with the XSD file (which I developed
    based on an initial DTD->XSD conversion by
    Piotr Kobzda), but the GUI code I am using.

    Can anybody spot the problem that is causing
    the first error, and advise how I can 'suppress
    it'?

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
     
    Andrew Thompson, Sep 23, 2007
    #1
    1. Advertising

  2. Solved!

    After a lot of searching, it turned out all I needed
    to do was add was this line when configuring the
    DocumentBuilderFactory..

    factory.setAttribute(
    "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
    ",
    schemaSource.toString());

    Now, to move on with the testing.

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via http://www.javakb.com
     
    Andrew Thompson, Sep 24, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. simon ames
    Replies:
    1
    Views:
    517
    Joerg Jooss
    Apr 11, 2004
  2. Replies:
    0
    Views:
    401
  3. FabioFR
    Replies:
    1
    Views:
    349
    FabioFR
    Sep 2, 2004
  4. Replies:
    1
    Views:
    568
  5. =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=

    Validating XML against XSD

    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=, Jun 20, 2007, in forum: XML
    Replies:
    3
    Views:
    501
    The Magpie
    Jun 22, 2007
Loading...

Share This Page