473,706 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beginner's problem when using jing Relax NG validator through JARVinterface


I am trying to learn to use jing through JARV interface and I have read
JARV User's Guide (http://iso-relax.sourceforge.net/JARV/JARV.html).
I have downloaded jingjarv-examples.zip from JARV User's Guide page and
latest jing version 20030619 from jing home page.

I can run jing successfully from command line like this (which I guess
proves that schema should be correct)

C:\Temp\APU> java -jar jing.jar schema.xsd valid.xml

C:\Temp\APU> java -jar jing.jar schema.xsd invalid.xml
C:\Temp\APU\inv alid.xml:4:12: error: required elements missing

But for some reason I don't get any java program to perform validation
using JARV interface. For example if I try to run precompiled
SingleThreadDri ver that comes in jingjarv-examples.zip package this is
what happens.

C:\Temp\APU>jav a SingleThreadDri ver schema.xsd valid.xml
driver is com.thaiopensou rce.relaxng.jar v.VerifierFacto ryImpl

C:\Temp\APU>jav a SingleThreadDri ver schema.xsd invalid.xml
driver is com.thaiopensou rce.relaxng.jar v.VerifierFacto ryImpl

So it doesn't throw any exception but it doesn't print any messages
either after finding driver (Of course I don't know if this class is
compiled from same source code that is included in package).

I can successfully compile the SingleThreadDri ver.java by myself but
after that the class throws java.lang.NullP ointerException if I try to
run it. I have added few debug printing lines to the code to locate the
source of the exception (I have added the modified
SingleThreadDri ver.java, schema.xsd, valid.xml and invalid.xml files to
the end of the message). So this is what happens:

C:\Temp\APU>set CLASSPATH

CLASSPATH=C:\AP PS\j2sdk1.4.1_0 3\lib\tools.jar ;.\jing.jar;.\i sorelax.jar;.\s axon.jar;.\xerc esImpl.jar;.\xm l-apis.jar;.

C:\Temp\APU>jav ac SingleThreadDri ver.java

C:\Temp\APU>jav a SingleThreadDri ver schema.xsd invalid.xml
driver is com.thaiopensou rce.relaxng.jar v.VerifierFacto ryImpl
parsing schema.xsd
schema != null
Exception in thread "main" java.lang.NullP ointerException
at
com.thaiopensou rce.relaxng.jar v.VerifierHandl erImpl.reset(Un known Source)
at
com.thaiopensou rce.relaxng.imp l.PatternValida tor.<init>(Unkn own Source)
at
com.thaiopensou rce.relaxng.jar v.VerifierHandl erImpl.<init>(U nknown Source)
at
com.thaiopensou rce.relaxng.jar v.VerifierImpl. <init>(Unknow n Source)
at
com.thaiopensou rce.relaxng.jar v.SchemaImpl.ne wVerifier(Unkno wn Source)
at SingleThreadDri ver.main(Single ThreadDriver.ja va:39)

The NullPointerExce ption occurs in this line

Verifier verifier = schema.newVerif ier();

and based on the debug printing at least schema object is not null so
exception must occur inside newVerifier method.

So finally the actual question. Do you know based on my explanation what
goes wrong? Can I use jing alone directly from java program or do I need
some other libraries than what comes in jing-20030619.zip package
(isorelax.jar, jing.jar, saxon.jar, xercesImpl.jar, xml-apis.jar)?

One thing that I noticed is that there is different namespace URI used
in SingleThreadDri ver.java and schema.xsd (I copied schema example from
internet). I tried to change these URIs also but I didn't notice any
effects with changing the URIs to match each other.

And here are the example files:
-------------------------------

---SingleThreadDri ver.java starts after this line---

import org.iso_relax.v erifier.*;
import java.io.File;

public class SingleThreadDri ver
{
public static void main( String[] args ) throws Exception {
if(args.length< 1) {
System.out.prin tln("SingleThre adDriver <schema> <document>
....");
return;
}

// find a JARV implementation. This will find JingJarv if
// it is in the classpath.
VerifierFactory factory = VerifierFactory .newInstance(
"http://relaxng.org/ns/structure/0.9");
if(factory==nul l) {
System.out.prin tln("No JARV implementation found");
return;
}

System.out.prin tln("driver is "+factory.getCl ass().getName() );

// use VerifierFactory to compile schemas.
// if errors are found in the schema, an exception will be thrown.
// thus in a real application, you should catch it.
System.out.prin tln("parsing "+args[0]);
Schema schema = factory.compile Schema(new File(args[0]));

// TEST!!! Check if schema is null and thus causes null pointer
exception
if (schema == null) {
System.out.prin tln("schema == null");
} else {
System.out.prin tln("schema != null");
}

// the newVerifier method will create a Verifier object,
// which will perform actual validation.
Verifier verifier = schema.newVerif ier();

// TEST!!! Test if we succeeded to create new Verifier
System.out.prin tln("Did we reach this point?");

for( int i=1; i<args.length; i++ ) {
System.out.prin tln("validating "+args[i]);

// validate documents
if( verifier.verify (new
File(args[i]).toURL().toExt ernalForm()) )
System.out.prin tln("valid");
else
System.out.prin tln("invalid");
}
}
}

---schema.xsd starts after this line---
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary ="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="addressBo ok">
<zeroOrMore>
<element name="card">
<element name="name">
<text/>
</element>
<element name="email">
<text/>
</element>
</element>
</zeroOrMore>
</element>
</start>
</grammar>

---valid.xml starts after this line---
<?xml version="1.0" encoding="UTF-8"?>
<addressBook>
<card>
<name>John Smith</name>
<email>js@examp le.com</email>
</card>
<card>
<name>Fred Bloggs</name>
<email>fb@examp le.net</email>
</card>
</addressBook>

---invalid.xml starts after this line---
<?xml version="1.0" encoding="UTF-8"?>
<addressBook>
<card>
<email>js@examp le.com</email>
</card>
<card>
<name>Fred Bloggs</name>
<email>fb@examp le.net</email>
</card>
</addressBook>

Jul 20 '05 #1
0 3719

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1124
by: Ducky Sherwood | last post by:
Aahz wrote: >Before the meeting, we'll continue the tradition started last month and >meet at 6pm for dinner, somewhere around downtown Palo Alto. Ducky >Sherwood is handling that; please send RSVPs to ducky@osafoundation.org >Discussion of dinner plans is handled on the BayPIGgies mailing list. >(I'm assuming we're going to Jing Jing again, but Ducky will post a >correction if I'm wrong. ;-) > >
6
2487
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. I've made a small list of some good and bad points of both. These points don't really go into the grammar aspects of these languages, but are more about secondary aspects. The grammar aspects are different, but both are suitable for validating...
2
597
by: Colin | last post by:
Hi, I am having some trouble using css correctly and I was wondering if a subscriber to this newsgroup might be able to offer some suggestions. The problem refers to the page http://www.gloworms.org.uk/index.htm My intention was to put the whole page in a dark box which sits on a
2
1784
by: Stephen | last post by:
Can I reference another style as a definition for a style? Such as... ..footerlink { font-size: 9px;} ..headerlink { font-size: .footerlink.fontsize } .... so that I can just change the .footerlink font size and automatically change the .headerlink font size?
8
4746
by: Jing Cheng | last post by:
Hi, I'm using ifstream reading data from a file, as following: ifstream finput("track.dat"); if(finput.fail()){ cerr << "Open input DATA file error!\n"; exit(-1);
5
1460
by: redsoxnut | last post by:
Can someone take a look at http://www.grooveswitch.com and help me figure out what's causing the misalignment? I just converted my entire site to a tableless design and am hung up on this final point. Thanks for any help you can give and I'm willing to work on it, not just get an answer spoon fed to me.
13
1422
by: jcsnippets.atspace.com | last post by:
Hi everybody, A few days ago I decided to get my site validated, so I have begun to clean up the first page to get an impression of what I should and should not do. To be able to get the site validated, I have to get rid of a lot of old style layout (tables, etcetera...), but I'd very much like to keep the original look and feel of the site. I have literally spent the entire evening working on the title and menu part
1
1412
by: Gerben Abbink | last post by:
Hi, Accoring to the specs (http://www.thaiopensource.com/relaxng/nrl.html), it should be possible to use Namespace Routing Language (NLR) with Jing ("A sample implementation of NRL is included in Jing."), but how? Should i specify the NLR files as a command-line parameter? thank you, - Gerben
1
1883
by: Torsten Munkelt | last post by:
Hi, I want to validate an XML document applying a combination of RELAX NG and Schematron. I have not found an appropriate validator. Would you please send me links to such validators. I would like to easily access it from within Java and from console. Thank you very much for your answers in advance.
0
8697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9056
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7912
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5939
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4710
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2503
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2096
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.