[Biojava-l] JAXP

Schreiber, Mark mark.schreiber@agresearch.co.nz
Tue, 26 Jun 2001 10:36:11 +1200


Hi,

I've been trying to use JAXP for XML parsing with the following snippet of
code:


        InputStream is = new FileInputStream(args[0]);
        InputStreamReader isr = new InputStreamReader(is);
        char[] data = new char[is.available()];
        isr.read(data);
        String xmldata = new String(data);
        InputSource source = new InputSource(new StringReader(xmldata));
        //System.out.print(xmldata);
        saxParser.parse(xmldata, this);


However no matter what XML file I use I always seem to get the following
error: (In this case from the Biojava build.xml)

Does anyone know of a possible reason for this error?



no protocol: <?xml version="1.0"?>

<!--

  Ant build file for the entire biojava tree
        
  see:
  <a href="http://jakarta.apache.org/ant">Ant Project Homepage</a>
  <a href="http://home.wxs.nl/~ajkuiper/ant.html">Ant User Manual</a>
  <a
href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">Download</a>
        
  targets:

    compile
    package      builds the biojava.jar file (default)
    javadocs
    dist
    dist-zip    'binary' release (jar & documentation) in zip format
    dist-tgz    'binary' release (jar & documentation) in tar.gz format
    dist-both    both dist-zip & dist-tgz
    clean        cleans up the build & dist directories

  author:  Michael Heuer
  version: $Id: build.xml,v 1.4 2001/02/17 00:36:53 raemig Exp $
        
  portions Copyright (c) 1999-2000 The Apache Software Foundation.
        
-->
        
<project default="package" basedir=".">

  <target name="init">
    <tstamp />
    <property name="name" value="biojava"/>
    <property name="version" value="pre-1.1"/>
                
    <property name="build.compiler" value="classic"/>
        
    <property name="readme" value="./README"/>
    <property name="license" value="./LICENSE"/>
    <property name="src.dir" value="./src"/>
    <property name="manifest.dir" value="./manifest"/>
    <property name="manifest.file" value="defaultmanifest.txt"/>
    <property name="resources.dir" value="./resources"/>

    <property name="classpath"
value="xerces.jar:jakarta-regexp.jar:bytecode.jar" />

    <property name="packages" value="org.*"/>
        
    <property name="build.dir" value="./ant-build"/>
    <property name="build.src" value="./ant-build/src"/>
    <property name="build.dest" value="./ant-build/classes"/>
    <property name="build.javadocs" value="./ant-build/docs"/>

    <property name="dist.root" value="./dist"/>
    <property name="dist.dir" value="${dist.root}/${name}-${version}"/>
  </target>
        
  <!-- Prepares the build directory -->
  <target name="prepare" depends="init">
    <mkdir dir="${build.dir}"/>
  </target>

  <!-- Prepares the source code -->
  <target name="prepare-src" depends="init,prepare">

    <!-- create directories -->
    <mkdir dir="${build.src}"/>
    <mkdir dir="${build.dest}"/>

    <!-- copy src files -->
    <!-- copydir src="${src.dir}" dest="${build.src}" excludes="CVS,cvs"/
-->
    <copy todir="${build.src}">
      <fileset dir="${src.dir}">
        <exclude name="**/CVS/**" />
      </fileset>
    </copy>

    <!-- copy manifest -->
    <!-- copydir src="${manifest.dir}" dest="${build.src}"
includes="${manifest.file}"/ -->
    <copy todir="${build.src}">
      <fileset dir="${manifest.dir}">
        <include name="${manifest.file}" />
      </fileset>
    </copy>

    <!-- copy resources -->
    <!-- copydir src="${resources.dir}" dest="${build.src}"
excludes="CVS,cvs"/ -->
    <copy todir="${build.dest}">
      <fileset dir="${resources.dir}">
        <exclude name="**/CVS/**" />
      </fileset>
    </copy>
  </target>
        
  <!-- Compiles the source directory -->
  <target name="compile" depends="init,prepare-src">
    <javac
      srcdir="${build.src}"
      destdir="${build.dest}"
      classpath="${classpath}"
      depend="yes"
    />
  </target>
        
  <!-- Creates the class package -->
  <target name="package" depends="init,compile">
    <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
         manifest="${build.src}/${manifest.file}" includes="org/**"/>
  </target>
        
  <!-- Creates the API documentation -->
  <target name="javadocs" depends="init,prepare-src">
    <mkdir dir="${build.javadocs}"/>
    <javadoc packagenames="${packages}"
        sourcepath="${build.src}"
        destdir="${build.javadocs}"
        author="true"
        version="true"
        use="true"
        windowtitle="${name} API"
        doctitle="${name}"
    />
  </target>
        
  <!-- Creates the distribution -->
  <target name="dist" depends="init,package,javadocs">
    <mkdir dir="${dist.root}"/>
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/lib"/>
    <mkdir dir="${dist.dir}/docs"/>

    <copyfile src="${readme}" dest="${dist.dir}"/>
    <copyfile src="${license}" dest="${dist.dir}"/>
 
    <copyfile src="${build.dir}/${name}.jar"
dest="${dist.dir}/lib/${name}.jar"/>
    <copydir src="${build.javadocs}" dest="${dist.dir}/docs"/>
  </target>

  <!-- zips the dist -->
  <target name="dist-zip" depends="init,dist">
    <zip zipfile="${name}-${version}.zip" basedir="${dist.dir}"
includes="**"/>
  </target>

  <!-- tgzs the dist -->
  <target name="dist-tgz" depends="init,dist">
    <tar tarfile="${name}-${version}.tar" basedir="${dist.root}"
includes="**"/>
    <gzip zipfile="${name}-${version}.tar.gz" src="${name}-${version}.tar"/>
  </target>

  <!-- zip & tgz -->
  <target name="dist-both" depends="init,dist-zip,dist-tgz"/>

  <!-- Cleans everything -->
  <target name="clean" depends="init">
    <deltree dir="${build.dir}"/>
    <deltree dir="${dist.root}"/>
    <delete file="${name}-${version}.tar.gz"/>
    <delete file="${name}-${version}.tar"/>
    <delete file="${name}-${version}.zip"/>
  </target>

  <target name="sync">
    <cvs command="update" />
    <AntCall target="package"/>
    <cvs command="commit" />
  </target>

</project>
java.net.MalformedURLException: no protocol: <?xml version="1.0"?>

<!--

  Ant build file for the entire biojava tree
        
  see:
  <a href="http://jakarta.apache.org/ant">Ant Project Homepage</a>
  <a href="http://home.wxs.nl/~ajkuiper/ant.html">Ant User Manual</a>
  <a
href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">Download</a>
        
  targets:

    compile
    package      builds the biojava.jar file (default)
    javadocs
    dist
    dist-zip    'binary' release (jar & documentation) in zip format
    dist-tgz    'binary' release (jar & documentation) in tar.gz format
    dist-both    both dist-zip & dist-tgz
    clean        cleans up the build & dist directories

  author:  Michael Heuer
  version: $Id: build.xml,v 1.4 2001/02/17 00:36:53 raemig Exp $
        
  portions Copyright (c) 1999-2000 The Apache Software Foundation.
        
-->
        
<project default="package" basedir=".">

  <target name="init">
    <tstamp />
    <property name="name" value="biojava"/>
    <property name="version" value="pre-1.1"/>
                
    <property name="build.compiler" value="classic"/>
        
    <property name="readme" value="./README"/>
    <property name="license" value="./LICENSE"/>
    <property name="src.dir" value="./src"/>
    <property name="manifest.dir" value="./manifest"/>
    <property name="manifest.file" value="defaultmanifest.txt"/>
    <property name="resources.dir" value="./resources"/>

    <property name="classpath"
value="xerces.jar:jakarta-regexp.jar:bytecode.jar" />

    <property name="packages" value="org.*"/>
        
    <property name="build.dir" value="./ant-build"/>
    <property name="build.src" value="./ant-build/src"/>
    <property name="build.dest" value="./ant-build/classes"/>
    <property name="build.javadocs" value="./ant-build/docs"/>

    <property name="dist.root" value="./dist"/>
    <property name="dist.dir" value="${dist.root}/${name}-${version}"/>
  </target>
        
  <!-- Prepares the build directory -->
  <target name="prepare" depends="init">
    <mkdir dir="${build.dir}"/>
  </target>

  <!-- Prepares the source code -->
  <target name="prepare-src" depends="init,prepare">

    <!-- create directories -->
    <mkdir dir="${build.src}"/>
    <mkdir dir="${build.dest}"/>

    <!-- copy src files -->
    <!-- copydir src="${src.dir}" dest="${build.src}" excludes="CVS,cvs"/
-->
    <copy todir="${build.src}">
      <fileset dir="${src.dir}">
        <exclude name="**/CVS/**" />
      </fileset>
    </copy>

    <!-- copy manifest -->
    <!-- copydir src="${manifest.dir}" dest="${build.src}"
includes="${manifest.file}"/ -->
    <copy todir="${build.src}">
      <fileset dir="${manifest.dir}">
        <include name="${manifest.file}" />
      </fileset>
    </copy>

    <!-- copy resources -->
    <!-- copydir src="${resources.dir}" dest="${build.src}"
excludes="CVS,cvs"/ -->
    <copy todir="${build.dest}">
      <fileset dir="${resources.dir}">
        <exclude name="**/CVS/**" />
      </fileset>
    </copy>
  </target>
        
  <!-- Compiles the source directory -->
  <target name="compile" depends="init,prepare-src">
    <javac
      srcdir="${build.src}"
      destdir="${build.dest}"
      classpath="${classpath}"
      depend="yes"
    />
  </target>
        
  <!-- Creates the class package -->
  <target name="package" depends="init,compile">
    <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
         manifest="${build.src}/${manifest.file}" includes="org/**"/>
  </target>
        
  <!-- Creates the API documentation -->
  <target name="javadocs" depends="init,prepare-src">
    <mkdir dir="${build.javadocs}"/>
    <javadoc packagenames="${packages}"
        sourcepath="${build.src}"
        destdir="${build.javadocs}"
        author="true"
        version="true"
        use="true"
        windowtitle="${name} API"
        doctitle="${name}"
    />
  </target>
        
  <!-- Creates the distribution -->
  <target name="dist" depends="init,package,javadocs">
    <mkdir dir="${dist.root}"/>
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/lib"/>
    <mkdir dir="${dist.dir}/docs"/>

    <copyfile src="${readme}" dest="${dist.dir}"/>
    <copyfile src="${license}" dest="${dist.dir}"/>
 
    <copyfile src="${build.dir}/${name}.jar"
dest="${dist.dir}/lib/${name}.jar"/>
    <copydir src="${build.javadocs}" dest="${dist.dir}/docs"/>
  </target>

  <!-- zips the dist -->
  <target name="dist-zip" depends="init,dist">
    <zip zipfile="${name}-${version}.zip" basedir="${dist.dir}"
includes="**"/>
  </target>

  <!-- tgzs the dist -->
  <target name="dist-tgz" depends="init,dist">
    <tar tarfile="${name}-${version}.tar" basedir="${dist.root}"
includes="**"/>
    <gzip zipfile="${name}-${version}.tar.gz" src="${name}-${version}.tar"/>
  </target>

  <!-- zip & tgz -->
  <target name="dist-both" depends="init,dist-zip,dist-tgz"/>

  <!-- Cleans everything -->
  <target name="clean" depends="init">
    <deltree dir="${build.dir}"/>
    <deltree dir="${dist.root}"/>
    <delete file="${name}-${version}.tar.gz"/>
    <delete file="${name}-${version}.tar"/>
    <delete file="${name}-${version}.zip"/>
  </target>

  <target name="sync">
    <cvs command="update" />
    <AntCall target="package"/>
    <cvs command="commit" />
  </target>

</project>
	at java.net.URL.<init>(URL.java:473)
	at java.net.URL.<init>(URL.java:376)
	at java.net.URL.<init>(URL.java:330)
	at com.sun.xml.parser.InputEntity.init(InputEntity.java:140)
	at com.sun.xml.parser.Parser.parseInternal(Parser.java:463)
	at com.sun.xml.parser.Parser.parse(Parser.java:284)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:100)
	at nz.co.agresearch.XML.XmlSnpScanner.main(XmlSnpScanner.java:487)




Mark Schreiber
Bioinformatics
AgResearch Invermay
PO Box 50034
Mosgiel
New Zealand

PH: +64 3 489 9175