• Post Reply Bookmark Topic Watch Topic
  • New Topic

schema validation  RSS feed

sanjay dube
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi this is my code for schema validation :
import oracle.xml.parser.schema.*;
import oracle.xml.parser.v2.*;
import java.net.*;
import java.io.*;
import org.w3c.dom.*;
import java.util.*;
import oracle.sql.CHAR;
import java.sql.SQLException;
public class SchemaUtil
public static String validation(CHAR xml, CHAR xsd)
throws Exception
//Build Schema Object
XSDBuilder builder = new XSDBuilder();

byte [] docbytes = xsd.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(docbytes);
XMLSchema schemadoc = (XMLSchema)builder.build(in,null);
//Parse the input XML document with Schema Validation
docbytes = xml.getBytes();
in = new ByteArrayInputStream(docbytes);
DOMParser dp = new DOMParser();
// Set Schema Object for Validation
dp.setPreserveWhitespace (true);

StringWriter sw = new StringWriter();
dp.setErrorStream (new PrintWriter(sw));

dp.parse (in);
sw.write("The input XML parsed without errors.\n");
catch (XMLParseException pe)
sw.write("Parser Exception: " + pe.getMessage());
catch (Exception e)
sw.write("NonParserException: " + e.getMessage());
return sw.toString();

This code works fine for all xml content . But for one new schema this code fails
this schema contains something liek this
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xs:include schemaLocation="response_schema.xsd"/>
error code is
Java call terminated by uncaught Java exception: oracle.xml.parser.schema.XSDException:
no protocol: response_schema.xsd
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!