[jdom-interest] Schema Validation Error

Christian Avril christian.avril at dpma.finances.gouv.fr
Thu Mar 24 09:36:12 PST 2005


  Of course I need the build. But builder.build is good for parsing and validate 
  If I only want to validate my file XML,  I don't need to use the object Document 

  Just this

      // start parsing...
           try {
           
            builder.build(fichierxml);  // parsing and validate !
            System.out.println(fichierxml + " is well formed.");
           } catch (IOException ioe) {
               System.out.println(" prob read file " + fichierxml );
           } catch (JDOMException e) { // indicates a well-formedness or validity error
                System.out.println(fichierxml + " is not valid.");
                System.out.println(e.getMessage());
           }


  I can use , for another example , the object Document, if I want parsing, validate AND later use methods of the object Document, but it's another story.
  Like this

   Document doc = builder.build(fichierxml);       
   ...
   doc.getRootElement()

  Regards

  Chris
    ----- Original Message ----- 
    From: Trikannad, Mahesh 
    To: Christian Avril 
    Sent: Thursday, March 24, 2005 5:57 PM
    Subject: RE: [jdom-interest] Schema Validation Error


    Chris,

    I did not understand your solution.

    Are you suggesting not doing the build at all. Would that cause NO Validation to occur.

    How do you validate in your code.

    Appreciate your help

    Mahesh


----------------------------------------------------------------------------
    From: Christian Avril [mailto:christian.avril at dpma.finances.gouv.fr]
    Sent: Thu 3/24/2005 11:40 AM
    To: Trikannad, Mahesh
    Subject: Fw: [jdom-interest] Schema Validation Error


    Yes, if I use , like you           builder.build(new StringReader(fichierxml));
    I have the error !!!

    xml/tri.xml is not valid.

    Error on line 1: Content is not allowed in prolog.

    Why don't you try without ....

    builder.build(myDocument)  or the name of the args if there is one

    Chris




    ----- Original Message ----- 
    From: Christian AVRIL 
    To: Trikannad, Mahesh 
    Sent: Thursday, March 24, 2005 5:10 PM
    Subject: Re: [jdom-interest] Schema Validation Error


    I have not exactly the same error but it sounds the error is :
    Element 'Body' must have no character or element information item [children],
    because the type's content type is empty.

    So you can write in your file xsd 
    this
     <xs:element name="Body">
     </xs:element>
    or this 
     <xs:element name="Body"/>
    if it's not a complexType ( because it is empty ) 

    Or you can have something into the <Body>something...</body> if it's a complexType ?

    Regards

    Chris
      ----- Original Message ----- 
      From: Trikannad, Mahesh 
      To: Christian Avril 
      Sent: Thursday, March 24, 2005 4:56 PM
      Subject: RE: [jdom-interest] Schema Validation Error



      Here is the xsd file.

      Regards

      Mahesh


--------------------------------------------------------------------------

      From: Christian Avril [mailto:christian.avril at dpma.finances.gouv.fr]
      Sent: Thu 3/24/2005 10:37 AM
      To: Trikannad, Mahesh
      Subject: Re: [jdom-interest] Schema Validation Error


      Hi, 

      Have you please a schemaFileName  ( like namefile.xsd  ) and can you send it

      Chris
        ----- Original Message ----- 
        From: Trikannad, Mahesh 
        To: jdom-interest at jdom.org 
        Sent: Thursday, March 24, 2005 4:14 PM
        Subject: [jdom-interest] Schema Validation Error


        Hi All,



        I get the following error, when I do a schema validation.



        Error on line 1: Content is not allowed in prolog.



        I want through, the jdom archives, but did not get a resolution. Some say it is a parser problem. Iam using xerces.jar, the one distributed via the jdom-1.0 distriution.

        Some say, it is a windows file encoding problem. I tried saving it , with notepad in different formats, that did not work



        The XML is as follows



        <?xml version="1.0" encoding="UTF-8"?>

        <ESBMessage>

              <Header>

                    <MessageId>mahesh</MessageId>

                    <OrigSys>ICOM</OrigSys>

                    <origSubSys>ICOMS1</origSubSys>

              </Header>

              <Body>

                          </Body>

        </ESBMessage>



        The code for schema validation

        -------



        SAXBuilder builder =

                                              new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);

                                            builder.setFeature("http://apache.org/xml/features/validation/schema", true);

                                            builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",

                                                                    schemaFileName);

                    

                                            

                                            Document tmpdoc = builder.build(new StringReader(myDocument.toString()));

                                            System.out.println("myValidate Done");



        Appreciate your experiences. 



        Mahesh Trikannad



              This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

             



------------------------------------------------------------------------


        _______________________________________________
        To control your jdom-interest membership:
        http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
            This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

           

          This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

         
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050324/2d5a01dc/attachment.htm


More information about the jdom-interest mailing list