Stay organized with collections
Save and categorize content based on your preferences.
Schema
public
abstract
class
Schema
extends Object
Immutable in-memory representation of grammar.
This object represents a set of constraints that can be checked/
enforced against an XML document.
A Schema
object is thread safe and applications are
encouraged to share it across many parsers in many threads.
A Schema
object is immutable in the sense that it shouldn't
change the set of constraints once it is created. In other words,
if an application validates the same document twice against the same
Schema
, it must always produce the same result.
A Schema
object is usually created from SchemaFactory
.
Two kinds of validators can be created from a Schema
object.
One is Validator
, which provides highly-level validation
operations that cover typical use cases. The other is
ValidatorHandler
, which works on top of SAX for better
modularity.
This specification does not refine
the Object.equals(java.lang.Object)
method.
In other words, if you parse the same schema twice, you may
still get !schemaA.equals(schemaB)
.
Summary
Protected constructors |
Schema()
Constructor for the derived class.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Protected constructors
Schema
protected Schema ()
Constructor for the derived class.
The constructor does nothing.
Public methods
newValidator
public abstract Validator newValidator ()
Creates a new Validator
for this Schema
.
A validator enforces/checks the set of constraints this object
represents.
Returns |
Validator |
Always return a non-null valid object. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Schema\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Protected Ctors](#proctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nSchema\n======\n\n\n`\npublic\n\n\nabstract\nclass\nSchema\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\n`\n\n|---|-----------------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | javax.xml.validation.Schema |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nImmutable in-memory representation of grammar.\n\n\nThis object represents a set of constraints that can be checked/\nenforced against an XML document.\n\n\nA [Schema](/reference/javax/xml/validation/Schema) object is thread safe and applications are\nencouraged to share it across many parsers in many threads.\n\n\nA [Schema](/reference/javax/xml/validation/Schema) object is immutable in the sense that it shouldn't\nchange the set of constraints once it is created. In other words,\nif an application validates the same document twice against the same\n[Schema](/reference/javax/xml/validation/Schema), it must always produce the same result.\n\n\nA [Schema](/reference/javax/xml/validation/Schema) object is usually created from [SchemaFactory](/reference/javax/xml/validation/SchemaFactory).\n\n\nTwo kinds of validators can be created from a [Schema](/reference/javax/xml/validation/Schema) object.\nOne is [Validator](/reference/javax/xml/validation/Validator), which provides highly-level validation\noperations that cover typical use cases. The other is\n[ValidatorHandler](/reference/javax/xml/validation/ValidatorHandler), which works on top of SAX for better\nmodularity.\n\n\nThis specification does not refine\nthe [Object.equals(java.lang.Object)](/reference/java/lang/Object#equals(java.lang.Object)) method.\nIn other words, if you parse the same schema twice, you may\nstill get `!schemaA.equals(schemaB)`. \n**See also:**\n\n- [XML Schema Part 1: Structures](http://www.w3.org/TR/xmlschema-1/)\n- [Extensible Markup Language (XML) 1.1](http://www.w3.org/TR/xml11/)\n- [Extensible Markup Language (XML) 1.0 (Second Edition)](http://www.w3.org/TR/REC-xml)\n\nSummary\n-------\n\n| ### Protected constructors ||\n|------------------------------------------------------------------------------------------------------|---|\n| ` `[Schema](/reference/javax/xml/validation/Schema#Schema())`() ` Constructor for the derived class. |\n\n| ### Public methods ||\n|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[Validator](/reference/javax/xml/validation/Validator) | ` `[newValidator](/reference/javax/xml/validation/Schema#newValidator())`() ` Creates a new [Validator](/reference/javax/xml/validation/Validator) for this [Schema](/reference/javax/xml/validation/Schema). |\n| ` abstract `[ValidatorHandler](/reference/javax/xml/validation/ValidatorHandler) | ` `[newValidatorHandler](/reference/javax/xml/validation/Schema#newValidatorHandler())`() ` Creates a new [ValidatorHandler](/reference/javax/xml/validation/ValidatorHandler) for this [Schema](/reference/javax/xml/validation/Schema). |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n\nProtected constructors\n----------------------\n\n### Schema\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\nprotected Schema ()\n```\n\nConstructor for the derived class.\n\n\nThe constructor does nothing.\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### newValidator\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Validator newValidator ()\n```\n\nCreates a new [Validator](/reference/javax/xml/validation/Validator) for this [Schema](/reference/javax/xml/validation/Schema).\n\n\nA validator enforces/checks the set of constraints this object\nrepresents.\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------------------------------------------------------|-----------------------------------------------|\n| [Validator](/reference/javax/xml/validation/Validator) | Always return a non-null valid object. \u003cbr /\u003e |\n\n### newValidatorHandler\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract ValidatorHandler newValidatorHandler ()\n```\n\nCreates a new [ValidatorHandler](/reference/javax/xml/validation/ValidatorHandler) for this [Schema](/reference/javax/xml/validation/Schema).\n\n\u003cbr /\u003e\n\n| Returns ||\n|----------------------------------------------------------------------|-----------------------------------------------|\n| [ValidatorHandler](/reference/javax/xml/validation/ValidatorHandler) | Always return a non-null valid object. \u003cbr /\u003e |"]]