You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Kishore Reddy <ki...@hotmail.com> on 2000/12/04 21:37:45 UTC
basic question on xml scmeha - help me
I am XML beginner.
I have very basic question on xml scmeha.
I am trying to parse (SAX Parser) simple xml using schema
and got the following error. Attached are simple xml file
and schema. Please help me in this regard.
I am using xerces parser "xerces-1_2_2".
/****************************************/
java SAXParserDemo simple.xml
start Document
[Fatal Error] simp.xsd:2:7: The XML declaration may
only appear at the very beginning of the document.
** Parsing error
Line : 2
URI : file:///home/kchapati/xerces_parser/test/simple.xml
Message : General Schema Error: Stopping after fatal error:
The XML declaration may only appear at the very
beginning of the document..
** Parsing error
Line : 2
URI : file:///home/kchapati/xerces_parser/test/simple.xml
Message : General Schema Error: Can't get back Schema
document's root
element :file:///home/kchapati/xerces_parser/test/simp.xsd.
grammar not found
** Parsing error
Line : 2
URI : file:///home/kchapati/xerces_parser/test/simple.xml
Message : Element type "Top" must be declared.
start element : Top
** Parsing error
Line : 3
URI : file:///home/kchapati/xerces_parser/test/simple.xml
Message : Element type "Telephone" must be declared.
start element : Telephone
end element : Telephone
end element : Top
end Document
/*******************************************
/------- xml file "simple.xml" -------------------/
<?xml version="1.0" encoding="UTF-8"?>
<Top xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='simp.xsd' >
<Telephone> 9725074850 </Telephone>
</Top>
/%%%%%%%%%%%%% schema "simp.xsd" %%%%%%%%%%%%%%/
<?xml version="1.0" encoding="UTF-8"?>
<schema>
<element name="Top" >
<element name="Telephone" type="string" />
</element>
</schema>
_____________________________________________________________________________________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
Re: basic question on xml scmeha - help me
Posted by Eric Ye <er...@locus.apache.org>.
Next time, please post this kind of quesiton on xerces-j-deve mailing list.
Your xml file is not well-formed,
Just as the error message said, the XMLDecl has to be placed in the VERY
beginning of the file, there could be nothting, not even spaces and new line
before a XMLDecl, this is prescribed by the XML 1.0 spec.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Kishore Reddy" <ki...@hotmail.com>
To: <xe...@xml.apache.org>
Sent: Monday, December 04, 2000 12:37 PM
Subject: basic question on xml scmeha - help me
>
> I am XML beginner.
> I have very basic question on xml scmeha.
>
> I am trying to parse (SAX Parser) simple xml using schema
> and got the following error. Attached are simple xml file
> and schema. Please help me in this regard.
>
> I am using xerces parser "xerces-1_2_2".
>
> /****************************************/
> java SAXParserDemo simple.xml
>
> start Document
> [Fatal Error] simp.xsd:2:7: The XML declaration may
> only appear at the very beginning of the document.
> ** Parsing error
> Line : 2
> URI : file:///home/kchapati/xerces_parser/test/simple.xml
> Message : General Schema Error: Stopping after fatal error:
> The XML declaration may only appear at the very
> beginning of the document..
> ** Parsing error
> Line : 2
> URI : file:///home/kchapati/xerces_parser/test/simple.xml
> Message : General Schema Error: Can't get back Schema
> document's root
> element :file:///home/kchapati/xerces_parser/test/simp.xsd.
> grammar not found
> ** Parsing error
> Line : 2
> URI : file:///home/kchapati/xerces_parser/test/simple.xml
> Message : Element type "Top" must be declared.
> start element : Top
> ** Parsing error
> Line : 3
> URI : file:///home/kchapati/xerces_parser/test/simple.xml
> Message : Element type "Telephone" must be declared.
> start element : Telephone
> end element : Telephone
> end element : Top
> end Document
>
> /*******************************************
>
> /------- xml file "simple.xml" -------------------/
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Top xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation='simp.xsd' >
> <Telephone> 9725074850 </Telephone>
> </Top>
>
> /%%%%%%%%%%%%% schema "simp.xsd" %%%%%%%%%%%%%%/
>
> <?xml version="1.0" encoding="UTF-8"?>
> <schema>
>
> <element name="Top" >
> <element name="Telephone" type="string" />
> </element>
>
> </schema>
>
>
>
____________________________________________________________________________
_________
> Get more from the Web. FREE MSN Explorer download :
http://explorer.msn.com
>
>