logo       

Related Msgs: audio.musicbrai...    enbd.general/20...    ietf.idr/2002-0...    java.ant-contri...    gnu.make.genera...    qplus.devel/200...    video.freevo.cv...    os.netbsd.ports...    yellowdog.gener...    xfree86.cvs/200...    search.nutch.us...    freedesktop.xse...    programming.swi...    capabilities.ge...    telephony.pbx.a...    mail.sylpheed.c...    db.firebase.por...    boot-loaders.u-...    recreation.radi...    netbsd.bugs/200...    web.zope.plone....    user-groups.lin...   

RE: Offline validation works on MS Windows but fails under Linux: msg#00013

Subject: RE: Offline validation works on MS Windows but fails under Linux
Nikhil

Thanks for the response. I think JAXP way is to use org.xml.sax.EntityResolver, 
but I am not sure

Best regards

Benjamin

-----Original Message-----
From: Nikhil Dinesh [mailto:nikhild@xxxxxxxxxxxxxx]
Sent: 08 May 2006 16:34
To: j-users@xxxxxxxxxxxxxxxxx
Subject: RE: Offline validation works on MS Windows but fails under
Linux


I'm not sure why it breaks on Linux and not on Windows, it could be that
in your Windows system the imported schema is fortuitously in the default
search directory and gets loaded from there instead of the classpath?

One way to resolve this issue, without ordering schemas is to set the:

org.apache.xerces.xni.parser.XMLEntityResolver and perhaps use it with an
org.apache.xerces.xni.grammars.GrammarLoader. Javadocs at:

http://xerces.apache.org/xerces2-j/javadocs/xni/index.html

There may be an equivalent way to accomplish this using just JAXP.

Best,
-Nikhil

On Mon, 8 May 2006, Kopic Benjamin wrote:

> This seems to be resolved by changing the following line:
>
> java.io.InputStream[] _schemas = { _mpd, _mh };
>
> to
>
> java.io.InputStream[] _schemas = { _mh, _mpd };
>
> Just in case someone else has experienced this.
>
> Best regards
>
> Benjamin
>
> -----Original Message-----
> From: Kopic Benjamin [mailto:Benjamin.Kopic@xxxxxxxxxxx]
> Sent: 08 May 2006 14:36
> To: j-users@xxxxxxxxxxxxxxxxx
> Subject: Offline validation works on MS Windows but fails under Linux
>
>
> Hi
>
> We use Xerces J 2.7.1 to process XML files that validate against XML 
> Schemata. However, the offline validation fails when run on Linux, although 
> it works fine under MS Windows 2000. The API we use is dom4j ( 
> http://www.dom4j.org/) and JAXP, but I doubt that the problem is in those 
> APIs.
>
> This is the code snippet that does the validation:
>
>
> reader.setXMLReaderClassName("org.apache.xerces.parsers.SAXParser");
> reader.setFeature(" http://apache.org/xml/features/validation/schema";, true);
>
> String mpdSchemaSource = System.getProperty("mpd-eph");
> String messageheaderSchemaSource = System.getProperty("messageheader-eph");
>
> String JAXP_SCHEMA_SOURCE = " 
> http://java.sun.com/xml/jaxp/properties/schemaSource";;
> String JAXP_SCHEMA_LANGUAGE = " 
> http://java.sun.com/xml/jaxp/properties/schemaLanguage";;
> String W3C_XML_SCHEMA = " http://www.w3.org/2001/XMLSchema";;
>
> try {
>  // retrieve schemata as InputStream from CLASSPATH
>  java.io.InputStream _mpd = 
> getClass().getClassLoader().getResourceAsStream(mpdSchemaSource);
>  java.io.InputStream _mh = 
> getClass().getClassLoader().getResourceAsStream(messageheaderSchemaSource);
>  java.io.InputStream[] _schemas = { _mpd, _mh };
>
>  reader.setProperty(JAXP_SCHEMA_SOURCE, _schemas);
>  reader.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
> }
> catch (Exception ex) {
>  // log the error
> }
>
> reader.read(fileObj);
>
> if (errorHandler.hasErrors()) {
>  // not OK
>  // always under Linux
> }
> else {
>  // OK
>  // always under MS Windows
> }
>
>
> The schemata are loaded correctly (I have verified that by outputing the 
> InputStream objects to a file). One of the things we do, however, is using 
> <xsd:import> to import "message-header" schema into "mpd" schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
>  xmlns:xsd=" http://www.w3.org/2001/XMLSchema";
>  xmlns:mh=" http://www.emea.eu.int/EuroPharm/1.0/message-header";
>  xmlns:mpd=" http://www.emea.eu.int/EuroPharm/1.0/mpd";
>  targetNamespace=" http://www.emea.eu.int/EuroPharm/1.0/mpd";
>  elementFormDefault="qualified"
>  attributeFormDefault="unqualified">
>
>  <xsd:import schemaLocation="messageheader-eph-1.0.xsd" namespace=" 
> http://www.emea.eu.int/EuroPharm/1.0/message-header"/ 
> <http://www.emea.eu.int/EuroPharm/1.0/message-header> >
>
>  <xsd:element name="mpd">
>   <xsd:annotation>
>    <xsd:documentation>This is a Dictionary feed file 
> format....</xsd:documentation>
>   </xsd:annotation>
>   <xsd:complexType>
>    <xsd:sequence>
>     <xsd:element name="messageheader" type="mh:MessageHeader"/>
>     <xsd:group ref="mpd:DictionaryEntriesGroup"/>
>    </xsd:sequence>
>   </xsd:complexType>
>  </xsd:element>
>  <!-- ... and the rest -->
>
>
>
> The error I get is the following:
>
> src-resolve: Cannot resolve the name 'mh:MessageHeader' to a(n) 'type 
> definition' component.
> schema_reference.4: Failed to read schema document 
> 'file:///home/oracle/europharm/feed_ben/inbox/messageheader-eph-1.0.xsd', 
> because 1) could not find the document; 2) the document could not be read; 3) 
> the root element of the document is not &lt;xsd:schema&gt;.
>
>
> I suspect the problem is with this import directive in the schema definition, 
> and the error message certainly points to it. The directory, 
> /home/oracle/europharm/feed_ben/inbox/, is the location of XML files, while 
> schemata are located in the CLASSPATH (in a JAR file).
>
> Does anyone know how could I resolve this?
>
> Best regards,
> --
> Benjamin Kopic
> European Medicines Agency (EMEA)
> IT Development - Communications & Networking
> 7 Westferry Circus
> Canary Wharf
> London
> E14 4HB
> Tel. +44(0)20 7523 7417
> Fax. +44(0)20 7418 8669
> benjamin.kopic@xxxxxxxxxxx
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all known viruses by EMEA.
> ________________________________________________________________________
>
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all known viruses by EMEA.
> ________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: j-users-help@xxxxxxxxxxxxxxxxx


________________________________________________________________________
This e-mail has been scanned for all known viruses by EMEA.
________________________________________________________________________



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo