Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

non recoverable error unexpected

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I parse an XML file which is valid according to a XSD schema (XML Spy told me!) but my error handler (Im using Xerces as parser) gives me the following error for each tag of my xml file :

-----------------
Recoverable Error: Element type "message" must be declared. (file:///c:/Documents/mt599.xml:3,127)
Recoverable Error: Element type "header" must be declared. (file:///c:/Documents/mt599.xml:4,10)
Recoverable Error: Element type "receiver" must be declared. (file:///c:/Documents/mt599.xml:5,13)
Recoverable Error: Element type "sender" must be declared. (file:///c:/Documents/mt599.xml:6,11)
Recoverable Error: Element type "body" must be declared. (file:///c:/Documents/mt599.xml:8,8)
Recoverable Error: Element type "transactionRef" must be declared. (file:///c:/Documents/mt599.xml:9,19)
Recoverable Error: Element type "relRef" must be declared. (file:///c:/Documents/mt599.xml:10,11)
Recoverable Error: Element type "narrative" must be declared. file:///c:/Documents/mt599.xml:11,14)
Recoverable Error: Element type "text" must be declared. (file:///c:/Documents/mt599.xml:12,10)
-----------------
What could be the error ? Here are my xml and xsd files :
mt599.xml
---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.2 U (http://www.xmlspy.com) by Christophe Grosjean (BSB) -->
<message xsi:noNamespaceSchemaLocation="file:///C:/Documents/mt599.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<receiver>Commerzbank Financial Products GMBH</receiver>
<sender>Banque Puilaetco SCS</sender>
</header>
<body>
<transactionRef>1234567890</transactionRef>
<relRef>CT99030401</relRef>
<narrative>
<text>This is a test message for sending</text>
<text>data to the SWIFT network in order</text>
<text>to see if we are able to get an ack</text>
<text>nowlegment with a generic MT599</text>
</narrative>
</body>
</message>
---------------------
mt599.xsd :
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="message" type="messageType"/>
<xsd:complexType name="messageType">
<xsd:sequence>
<xsd:element name="header" type="headerType"/>
<xsd:element name="body" type="bodyType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="headerType">
<xsd:sequence>
<xsd:element name="receiver" type="xsd:string"/>
<xsd:element name="sender" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="bodyType">
<xsd:sequence>
<xsd:element name="transactionRef" type="xsd:string"/>
<xsd:element name="relRef" type="xsd:string" minOccurs="0"/>
<xsd:element name="narrative" type="narrativeType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="narrativeType">
<xsd:sequence>
<xsd:element name="text" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
-------------------------------
I will apreciate very much if someone could tell me what's wrong.
Christophe
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!