The reference to the DTD file in the line...

   <!DOCTYPE Catolog SYSTEM "Catalog.dtd">

isn't resolvable by the XML parser probably because it doesn't exist in the
directory from which you started Orion.  You must either use an absolute file
specification or a valid URL.

Mike


Derek Akers wrote:

> I am having a problem parsing an xml file using the following code, trying
> to validate the enclosed xml files...
>
> i keep getting the following error:
>
> ** Parsing error, line 2, uri null
>    Relative URI "Catalog.dtd"; can not be resolved without a document URI.
>
> can anyone help?  sorry for the length...
>
> public boolean checkXML (String source) // source is a file name string
> passed from the web
>  {
>    Document doc;
>    String path = "d:/orion/applications/eldan/eldan-web/xml/" + source;
>
>   if (source == null)
>    System.out.println("\nValidator:checkXML: source string is null");
>
>    try
>    {
>      DocumentBuilderFactory docBuilderFactory =
> DocumentBuilderFactory.newInstance();
>      docBuilderFactory.setValidating(true);
>      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
>      Validator v =  new Validator();
>
>      FileInputStream xmlStream = new FileInputStream(path);
>
> //     URL url = v.getClass().getResource(path);
> //       doc = docBuilder.parse (url.toString());
>
>      doc = docBuilder.parse(xmlStream);
>      valid = true;
>      System.out.println("\nxml valid");
>
>      } // end try
>    catch (SAXParseException err)
>    {
>     System.out.println("exception 1");
>     System.out.println ("** Parsing error"
>     + ", line " + err.getLineNumber ()
>     + ", uri " + err.getSystemId ());
>    System.out.println("   " + err.getMessage ());
>     // print stack trace as below
>
>   } // end catch 1
>    catch (SAXException e)
>    {
>     System.out.println("exception 2");
>     Exception x = e.getException ();
>        ((x == null) ? e : x).printStackTrace ();
>    } // end catch 2
>    catch (Throwable t)
>   {
>     System.out.println("exception 3");
>    t.printStackTrace ();
>   } // end catch 3
>   return valid;
>   } // end checkXML
> ----------------------------------------------------------------------------
> --------------------------
> Catalog.xml
> ----------------------------------------------------------------------------
> --------------------------
> <?xml version='1.0' encoding='UTF-8' ?>
> <!DOCTYPE Catolog SYSTEM "Catalog.dtd">
> <Catolog>
>  <Product ID = "1273">
>   <ProductName>Air Jordan</ProductName>
>   <Description>The best basketball shoe in town.</Description>
>   <Price>140.99</Price>
>  </Product>
>  <Product ID = "1274">
>   <ProductName>Nike Zoom</ProductName>
>   <Description>An amazing crosstrainer.</Description>
>   <Price>75.99</Price>
>  </Product>
>  <Product ID = "1276">
>   <ProductName>Addidas Predator</ProductName>
>   <Description>The best aspect of soccer today.</Description>
>   <Price>219.99</Price>
>  </Product>
>  <Product ID = "1279">
>   <ProductName>Addidas Turbo</ProductName>
>   <Description>The lightweight shoe for the future.</Description>
>   <Price>99.99</Price>
>  </Product>
> </Catolog>
> ----------------------------------------------------------------------------
> --------------------------
> Catalog.dtd
> ----------------------------------------------------------------------------
> --------------------------
> <!ELEMENT Catalog  (Product+ )>
>
> <!ELEMENT Product  (ProductName , Description , Price )>
> <!ATTLIST Product  ID CDATA  #REQUIRED >
> <!ELEMENT ProductName  (#PCDATA )>
> <!ATTLIST ProductName  e-dtype NMTOKEN  #FIXED 'string' >
> <!ELEMENT Description  (#PCDATA )>
> <!ATTLIST Description  e-dtype NMTOKEN  #FIXED 'string' >
> <!ELEMENT Price  (#PCDATA )>
> <!ATTLIST Price  e-dtype NMTOKEN  #FIXED 'fixed.14.4' >
> ----------------------------------------------------------------------------
> --------------------------
>
> Derek Akers
>
> Internet Application Developer
> Eldan Software, Toronto
>
> www.eldan.com

--
Mike Clark
Clarkware Consulting
Enterprise Java Architecture, Design, Development
http://www.clarkware.com



Reply via email to