- From: Vaishali Dighe <VDighe@pharmanet.com>
- Date: Fri, 25 Jan 2002 16:59:58 -0500 (EST)
- To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Dear Sir:
I have an XSD file something like this.
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:annotation>
<xsd:documentation xml:lang="en">
</xsd:documentation>
</xsd:annotation>
<xsd:element type="WITHDRAWType" name="WITHDRAW"/>
<xsd:complexType name="WITHDRAWType">
<!-- Made up of simple definitions. -->
</xsd:complexType>
</xsd:schema>
I have an instance file and OracleXML Schema Validator sample program.
import oracle.xml.parser.schema.*;
import oracle.xml.parser.v2.*;
import oracle.xml.parser.v2.XMLParser;
import java.net.*;
import java.io.*;
import org.w3c.dom.*;
import java.util.*;
public class XSDSetSchema
{
public static void main(String[] args) throws Exception
{
if (args.length != 2)
{
System.out.println("Usage: java XSDSample <schema_file>
<xml_file>");
return;
}
XSDBuilder builder = new XSDBuilder();
URL url = createURL(args[0]);
// Build XML Schema Object
XMLSchema schemadoc = (XMLSchema)builder.build(url);
process(args[1], schemadoc);
}
public static void process(String xmlURI, XMLSchema schemadoc)
throws Exception
{
DOMParser dp = new DOMParser();
URL url = createURL (xmlURI);
// Set Schema Object for Validation
dp.setXMLSchema(schemadoc);
dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
dp.setPreserveWhitespace (true);
dp.setErrorStream (System.out);
try
{
System.out.println("Parsing "+xmlURI);
dp.parse (url);
System.out.println("The input file <"+xmlURI+"> parsed without
errors");
}
catch (XMLParseException pe)
{
System.out.println("Parser Exception: " + pe.getMessage());
}
catch (Exception e)
{
System.out.println ("NonParserException: " + e.getMessage());
}
}
// Helper method to create a URL from a file name
static URL createURL(String fileName)
{
URL url = null;
try
{
url = new URL(fileName);
}
catch (MalformedURLException ex)
{
File f = new File(fileName);
try
{
String path = f.getAbsolutePath();
// This is a bunch of weird code that is required to
// make a valid URL on the Windows platform, due
// to inconsistencies in what getAbsolutePath returns.
String fs = System.getProperty("file.separator");
if (fs.length() == 1)
{
char sep = fs.charAt(0);
if (sep != '/')
path = path.replace(sep, '/');
if (path.charAt(0) != '/')
path = '/' + path;
}
path = "file://" + path;
url = new URL(path);
}
catch (MalformedURLException e)
{
System.out.println("Cannot create url for: " + fileName);
System.exit(0);
}
}
return url;
}
}
When I run,
> java XSDSetSchema out.xsd withdraw.xml
I get error :
<Line 38, Column 26>: XSD-2028: (Error) Invalid reference: ':WITHDRAWType'
Exception in thread "main" oracle.xml.parser.schema.XSDException: Invalid
reference: ':WITHDRAWType
at
oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:471)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:258)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:240)
at XSDSetSchema.main(XSDSetSchema.java:26)
I don't understand why WITHDRAWType is INVALID ref. b'se it has been defined
Thanks for your time
Sincerely,
Vaishali Dighe
Vaishali Dighe
Analyst, IT Development
PharmaNet, Inc
504 Carnegie Center
Princeton, NJ 08540
Tel: (609)-951-6859
vdighe@pharmanet.com
Received on Saturday, 26 January 2002 15:30:40 UTC