public class Schema
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
Schema(long nativeHandle)
This class is used for creating XML Schema object using nativeHandle.
|
Modifier and Type | Method and Description |
---|---|
protected long |
getNativeHandle()
Returns the native handle of the schema object.
|
ResourceOwner |
getResourceOwner()
This method is used for internal purpose
|
protected static Schema |
newSchema(byte[] schemaBytes)
Creates the new schema object from the bytes having the schema
information.
|
protected Schema(long nativeHandle)
protected static Schema newSchema(byte[] schemaBytes)
XMLException
if there is any error with schema.schemaBytes
- the schema byte array
public void test() {
Document oDocument = new Document();
String xmlStr = "<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>";
String schemaStr = "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" "
+ "targetNamespace=\"http://www.cordys.com\" "
+ "xmlns=\"http://www.cordys.com\">"
+ "<xs:element name=\"note\">"
+ "<xs:complexType>"
+ "<xs:sequence>"
+ "<xs:element name=\"to\" type=\"xs:string\"/>"
+ "<xs:element name=\"from\" type=\"xs:string\"/>"
+ "<xs:element name=\"heading\" type=\"xs:string\"/>"
+ "<xs:element name=\"body\" type=\"xs:string\"/>"
+ "</xs:sequence>"
+ "</xs:complexType>"
+ "</xs:element></xs:schema>";
try {
Schema oSchema = SchemaFactory.newSchema(schemaStr.getBytes());
int result = oDocument.load(xmlStr.getBytes(), oSchema);
assertTrue("Failed to load the xml with schema validation",result != 0);
} catch (XMLException e) {
e.printStackTrace();
}
}
protected long getNativeHandle()
public ResourceOwner getResourceOwner()