• 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

xerces : Parsingproblem when "include" one or more Schema in another

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
My problem is that i parse an xml-document and validate it against a schema. but the schema has multiple other schemas included (i'm using "include" not "import" because all schemas using the same namespace). and the sax parser (from xerces) can't find these schemas, because he is obviously searching in the wrong directory - in fact in the dirctory of the application, not in the directory of the including schema. the path, within the "include" attribute is given relativ to the including schema.
i'm using java 1.3.1 and have tried different xerces versions. With xerces 2.0.0 and higher, the sax parser seems not to validate at all. xerces 1.4.4 do validate but doesn't find the included schemas.
here is the java code:
SAXParser saxParser = new SAXParser();
saxParser.setContentHandler(handler);
saxParser.setErrorHandler(handler);
InputStream ioStream =null;
try
{
saxParser.setFeature
("http://xml.org/sax/features/validation",true);
saxParser.setFeature
("http://apache.org/xml/features/validation/schema", true);
saxParser.setFeature
("http://apache.org/xml/features/validation/schema-full-checking", true);
InputStreamReader inputstream = new InputStreamReader(m_oStream,"UTF-8");
InputSource inputsource = new InputSource(inputstream);
saxParser.parse(inputsource);

heres a fragment of the including schema (Reply.xsd) (against this an xml file is validated)
<xs:schema targetNamespace="www.interface.de" xmlns="www.interface.de" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="./KOM.xsd"/>
<xs:include schemaLocation="./Ort.xsd"/>
<xs:element name="Reply">
<xs:complexType name="reply">
<xs:choice>
<xs:sequence>
<xs:element name="AKOM" type="auditkom" minOccurs="0"/>
<xs:element name="AOrt" type="auditort" minOccurs="0"/>
.....
these to schemas (KOM, Ort) were not found, when the parser validates an xml file. all schemas are in the same dirctory (an other then the application directory). and the absolut path to the Reply.xsd (which is found) is given in the xml file.
can't sax from xerces handle "include" from xml-schema? or is there a version wich can?
Thanks & Regards,
Sascha
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...sascha,
ur way of approach is very good in programming....when we r speaking about the parsers,U need to use the latest versions in ur programming...as far as UR code in java is concerned, it is absolutely correct and the problem is with the parser....u have tried with sax parser which is not handling the "include" from xml-schema, but have U tried "MSXML 4.0" parser....in india,iam using using this parser and am much comfortable using this one and why dont U try out for this....
this is the only parser which can help U, if not there's no other parser which can handle ur "include" attrib.....
bye sascha,
have a nice day.
with regards,
RAJA
 
Sascha Henning
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, raja.
thanks for reply! i have looked for "MSXML 4.0" and i've found it. But i need to use it, in an java-application and i have not found any java libaries for the parser. if i want only validate an xml-file, i use "XML-Spy". and this tool has no problem with "include" and a relative path. but i need a solution for java-applications. thats the point. xerces has no problem with "include" if i use an absolut path to the schema (only relative its a problem)
So, is there a way to use "MSXML 4.0" (or any other parser)for java to solve the problem?
thanks & regards
sascha
 
raja guthi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...sascha,
i gone through many books to find out a solution for ur problem after reading ur message...atlast, this is what I found in a book....
XML Parser for Java(XML 4.0,as it sometimes called) has an interface that allows U to take a string of XML-formatted text,pick the XML,tags out of it and use those tags as ur keys for extracting the tagged information. It seperates U from the need to deal with the string text directly-there's no need to foolwith the text stringdirectly. Whaz more,XML Parser for Java supports the XML Namespace standard.....
even after this, if U find difficult in ur code to execute the i can say that its impossible to use the "include" attrib in ur java code....
sascha, iam j ust a student at NIIT in INDIA....may be, i may go wrong somewhere but forgive me if I had redirected ur mind....
this is the maximum i can think of and if U found any solution, dont forget to mail me at: raja4745@yahoo.com...
waiting for ur mail...
with affeciton,
RAJA
 
reply
    Bookmark Topic Watch Topic
  • New Topic