216 DBMS_XMLSCHEMA_UTIL
The DBMS_XMLSCHEMA_UTIL package provides an interface for XML schema validation.
This chapter contains the following topics:
See Also:
216.1 DBMS_XMLSCHEMA_UTIL Security Model
Applications must have the EXECUTE privilege on the DBMS_XMLSCHEMA_UTIL package
216.2 Summary of DBMS_XMLSCHEMA_UTIL Subprograms
This topic lists the DBMS_XMLSCHEMA_UTIL subprograms in alphabetical order and briefly describes them.
Table 216-1 DBMS_XMLSCHEMA_UTIL Package Subprograms
| Subprogram | Description |
|---|---|
|
Validates an XML document against a schema |
|
|
Validates an XML document against a schema |
216.2.1 CONFORMING Function
This function is used to validate an XML document against a schema.
Syntax
DBMS_XMLSCHEMA_UTIL.CONFORMING ( doc IN NUMBER, sch IN NUMBER) RETURN NUMBER;
Parameters
Table 216-2 CONFORMING Function Parameters
| Parameter | Description |
|---|---|
|
|
The XML instance |
|
|
The XML schema |
Function Exceptions
The exceptions of DBMS_XMLSCHEMA_UTIL.CONFORMING function are as follows:
- The function returns zero if the schema is legal and the document conforms to the schema; otherwise it returns an LSX error code from the schema validation.
Note:
The function takes an xml data instance and xml schema instance. The user does not have to register the schema.
Example: The document conforms to the schema
SELECT DBMS_XMLSCHEMA_UTIL.CONFORMING(
XMLType('<A/>'),
XMLType(
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="A" type="xs:string"/>
</xs:schema>')) "LSX CODE"
FROM DUAL;
216.2.2 VALIDATE Procedure
This procedure is used to validate an XML document against a schema.
Syntax
DBMS_XMLSCHEMA_UTIL.VALIDATE ( doc IN XMLTYPE, sch IN XMLTYPE);
Parameters
Table 216-3 VALIDATE Procedure Parameters
| Parameter | Description |
|---|---|
|
|
The XML instance |
|
|
The XML schema |
Procedure Exceptions
The exceptions of DBMS_XMLSCHEMA_UTIL.VALIDATE procedure are as follows:
- The procedure raises ORA-31154 if either the schema is not legal, or the document does not conform to the schema.
Note:
The procedure takes an xml data instance and xml schema instance. The user does not have to register the schema.
Example: The document conforms to the schema
BEGIN
DBMS_XMLSCHEMA_UTIL.VALIDATE(
XMLType('<A/>'),
XMLType(
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="A" type="xs:string"/>
</xs:schema>'));
END;
/