• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URGENT - Grammar in XML for Schema

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
I have an XML document and its corresponding Schema. While parsing it with the SAX2 Parser, I first of all get the error message that the specified grammar-"http://www.w3.org" - is not found. Then its unable to recognise the schema specified in the XML and hence flashes the error message for each element & attribute that it must be declared.
I would be very greatful if someone could help me find a solution.
I am using Xerces and writing the application in Java.
For your reference I am giving the XML and Schema that is being used.
---------------
XML Document
---------------
<?xml version="1.0" encoding="UTF-8"?>
<Person xmlns="http://www.w3.org" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:SchemaLocation="C:\SchemaValidation\schema_test.xsd">
<RoleNo>XI-12</RoleNo>
<Age>12</Age>
</Person>
-----------------
XML Schema
-----------------
<?xml version="1.0"?>
<xsd:schema targetNamespace="http://www.w3.org" xmlns="http://www.w3.org" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:element name="Person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RoleNo" type="xsd:string"/>
<xsd:element name="Age" type="xsd:short"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Hope for an immediate response.
Regards.

[This message has been edited by Lakshmi Ramachandran (edited June 28, 2001).]
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
U sample code shows two namespace declarations why is that?
1. xmlns="http://www.w3.org"
2. xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
I believe the second one is enough to run ur application.
Try this one also,
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation='C:\SchemaValidation\schema_test.xsd'>

Regards,
mahendran
 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mahendran,
Thank you for your response. I have specified two namespaces as the first one is taken as the default and the second for xsi prefix namespace. The problem "Grammar not found." is solved now as the file to recognise the grammar mentioned in the XML document while parsing was actually missing in the jar file which was in use. I am very sorry for this as I was unaware of the fact that my jar was corrupted.
Thanks for your help.
Regards,
Lakshmi

[This message has been edited by Lakshmi Ramachandran (edited July 01, 2001).]
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lakshmi,
I am having exactly the same problem with the schema, that is, the parser can't find the schema and I get the error "Grammar not found". Do you have both the XML doc and the schema in a jar file?
Where should I put the schema? This or similar doesn't seem to work :
<personnel xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:SchemaLocation="C:\thesis\schema\personal.xsd">
Regards,
/Manuel
[This message has been edited by Manuel Palacio (edited July 02, 2001).]
 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manuel,
Put the XML as well as the Schema in the same location as that of the application which is doing the task of parsing and validation. That works fine !
Regards.
Lakshmi

 
Manuel Palacio
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strange. I put everything in the same directory but still I get the same error: "grammar not found"
What should the xsi:SchemaLocation look like?
I am using -cp c:\jdk1.3\xerces.jar;. in the same directory where the application + the xml and xsd files are located but I get the above error.
Thanks for any tips!
 
Manuel Palacio
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now it's working. It seems that I didn't have the latest jar file.
I downloaded this file:
Xerces-J-tools.1.4.1.zip
when I should have downloaded this one:
Xerces-J-bin.1.4.1.zip
Sorry!
 
reply
    Bookmark Topic Watch Topic
  • New Topic