[jdom-interest] Schema Validation Error

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


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:35 PM
    Subject: Re: [jdom-interest] Schema Validation Error


    Yes this other solution is something in the body 
    --------------------------------------------------------
    ...
            <Body>
                    <Hello>hello</Hello>
                            </Body>
    </ESBMessage>
    --------------------------------------------------------

    And I have no error , but I have modified the file xsd
    But maybe it's another thing...
    For example, I don't use     Document tmpdoc = builder.build(new StringReader(myDocument.toString()));
    but only builder.build(fichierxml);


    -----------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!--W3C Schema generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
     <xs:element name="Body">
      <xs:complexType>
        <xs:sequence>
           <xs:element name="Hello"/>
        </xs:sequence>
      </xs:complexType>
      
     </xs:element>
     <xs:element name="ESBMessage">
    ...
    -------------------------------------------------------------



    Here is my code ( your code in comment ) . 

        /***
         * 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");
         * /
        
        String fichierxml = args[0];     
        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",
        "file:///C:/mytest.xsd");
        try {
              builder.build(fichierxml);
            // If there are no well-formedness errors,
            // then no exception is thrown
     ...



    Chris

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


      Chris,

      I changed the XML, to have something in the body

      <?xml version="1.0" encoding="UTF-8"?>
      <ESBMessage>
              <Header>
                      <MessageId>mahesh</MessageId>
                      <OrigSys>ICOM</OrigSys>
                      <origSubSys>ICOMS1</origSubSys>
              </Header>
              <Body>
                      <Hello>hello</Hello>
                              </Body>
      </ESBMessage>

      It still gives the same error.

      I suspect, it fails even before it validates, somewhere in the parsing. I  have seen some reference to the problem in the archives, but no concrete solution.

      Do you use the xerces parser

      Regards

      Mahesh


--------------------------------------------------------------------------
      From: Christian Avril [mailto:christian.avril at dpma.finances.gouv.fr]
      Sent: Thu 3/24/2005 11:10 AM
      To: Trikannad, Mahesh
      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/777ae234/attachment.htm


More information about the jdom-interest mailing list