You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Nina Juliadotter <nv...@it.uts.edu.au> on 2004/02/09 06:26:44 UTC

Errors running code from provided documentation

Hi!

I'm trying to parse an xml schema, but is not very successful.
As I havn't found any sample applications to look at, I tried
to use the documentation on
http://ws.apache.org/jaxme/xs/syntax.html.

So in an attempt to use the code provided, my class is (copied
straight from the source above):

import java.io.FileInputStream;
import org.xml.sax.InputSource;
import org.apache.ws.jaxme.xs.XSParser;
import org.apache.ws.jaxme.xs.xml.*;

  public class myParser
  {
    public static void main(String[] args) throws Exception
    {
      FileInputStream fs = new FileInputStream(args[0]);
      InputSource is = new InputSource(fs);
      //is.setSystemId(fs.toURL().toString()); //ignore this,
as FileInputStream doesn't actually have a method
'toURL'.
      XSParser parser = new XSParser();
      XsESchema schema = parser.parseSyntax(is); //line 21
    }
  }

My ant file 'build.xml' is:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="run" name="syntaxParser">
      <path id="generate.class.path">
        <pathelement
location="/W2SProject/jars/incubated-jaxme-0.2/lib/jaxme2.jar"/>
        <pathelement
location="/W2SProject/jars/incubated-jaxme-0.2/lib/jaxmejs.jar"/>
        <pathelement
location="/W2SProject/jars/incubated-jaxme-0.2/lib/jaxmexs.jar"/>
        <pathelement location="/jwsdp-1.3/jaxb/lib/jaxb-api.jar"/>
        <pathelement
location="/jwsdp-1.3/jwsdp-shared/lib/jax-qname.jar"/>
        <pathelement
location="/jwsdp-1.3/jwsdp-shared/lib/namespace.jar"/>
        <pathelement
location="/jwsdp-1.3/jwsdp-shared/lib/namespace.jar"/>
        <pathelement location="." />
      </path>

      <target name="clean">
        <delete dir="build/src/*" quiet="true"/>
        <delete dir="build/classes/*" quiet="true"/>
      </target>

        <!-- compile Java source files -->
    <target name="compile" depends="clean">

        <!-- compile all of the java sources -->
        <echo message="Compiling the java source files..."/>
        <javac srcdir="." destdir="." debug="on">
            <classpath refid="generate.class.path" />
        </javac>
    </target>

    <target name="run" depends="compile">
        <echo message="Running the sample application..."/>
        <java classname="myParser" fork="true" output="out.txt">
            <classpath refid="generate.class.path" />
            <arg file="RestaurantSchema.xsd" />
        </java>
    </target>
</project>

And the error message I get is:

org.xml.sax.SAXNotRecognizedException: Property:
http://java.sun.com/xml/jaxp/properties/schemaLanguage
	at
org.apache.crimson.parser.XMLReaderImpl.setProperty(XMLReaderImpl.java:272)
	at
org.apache.crimson.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:190)
	at
org.apache.ws.jaxme.xs.xml.impl.XsObjectFactoryImpl.newXMLReader(XsObjectFactoryImpl.java:348)
	at org.apache.ws.jaxme.xs.XSParser.parseSyntax(XSParser.java:155)
	at myParser.main(myParser.java:21)
Exception in thread "main"

I believe the reason for the error message with the variable
'schema' not being initialised properly. There is however
nothing wrong with the schema url I provide.

I feel  really lost trying to use JaxMe to parse an xml schema,
as there really isn't much documentation. It would be helpful
to see an entire little application (java class and build
file), as I'm not sure if I've missed something in my ant
file...?

Can anybody with more experience help me please?

nvjuliad



---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: Errors running code from provided documentation

Posted by Jochen Wiedmann <jo...@ispsoft.de>.
Hi,

Nina Juliadotter wrote:

> org.xml.sax.SAXNotRecognizedException: Property:
> http://java.sun.com/xml/jaxp/properties/schemaLanguage
> 	at
> org.apache.crimson.parser.XMLReaderImpl.setProperty(XMLReaderImpl.java:272)
> 	at

the exception is thrown, because your XML parser isn't able to validate an 
XML document which is specified by a schema. Most probably you are using the 
Crimson parser, that comes with the JDK 1.4.

Two possible reasons to continue:

- Your XML document does indeed contain a schema specification. In other
   words, you wish to validate the schema. If so, you should use another
   XML Parser, for example Apache Xerces.

- You have no need to validate the schema, you simply want to parse it.
   If so, use the method XSParser.setValidating(false).


 > I feel  really lost trying to use JaxMe to parse an xml schema,
 > as there really isn't much documentation. It would be helpful
 > to see an entire little application (java class and build
 >  file), as I'm not sure if I've missed something in my ant
 > file...?

The JaxMeXS test suite might help you. See buildxs.xml, target "test"
and the "xs.junit" package for details. Btw, patches to the docs are
welcome.


Jochen


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org