This content has been marked as final. Show 5 replies
It may be that I'm going blind but I can find no way to validate a document against a schema without first registering the schema in xml db.If you want to use the validation features of XML DB (via XMLType's corresponding methods), the schema has to be registered first, there's no way around that.
Without registering, the alternative is to use an external validation tool you can interface with the database via a PL/SQL API.
The usual example is the Java schema processor :
For my purposes xml db introduces an unnecessary layer of complexity and managementSorry, what "complexity" are you talking about?
Where's the difficulty in calling DBMS_XMLSCHEMA.REGISTERSCHEMA?
You just have to do it once, with genTypes and genTables parameters set to false, and there you go, you can use the functionalities.
If the schema evolves, then just delete the existing one and re-register the new version. It only takes a couple of procedure calls.
Regarding your "complex" observation. At a general level I suppose the term is subjective.
The reason for my comment however is that we work a lot with schemas and the example code I have provided is simple and flexible for many purposes including just testing xml related stuff on the fly - and in my personal opinion PL/SQL really should support the capability.
In working on this example I have thought of a few more reasons to call it complex
1. once the schema has been registered, if the transaction subsequently fails the schema persists
2. because the schema is stored in the xmldb it means that this area then needs to be backed up also
3. if the xml schemas exist in xml db and I remove my personal schema , the xml db schemas need to be explicitly purged otherwise they persist
I absolutely know there is value in the XML DB but I do think that adding this conceptually simple XML validation method to the XMLtype would open up a developer's options significantly ito the use of schemas in the db, as suddenly:
1. in-proc stored schema document validations become possible
2. in-table stored schema document validations become possible
3. xml db schema validations obviously remain possible
hope this explains my thoughts a bit more comprehensively
1. once the schema has been registered, if the transaction subsequently fails the schema persistsEasily managed with a conditional statement, or a proper exception handler.
2. because the schema is stored in the xmldb it means that this area then needs to be backed up alsoXML DB is not a separate part of the database, it's getting backed up like any other data - but depends on what you mean by "backed up".
3. if the xml schemas exist in xml db and I remove my personal schema , the xml db schemas need to be explicitly purged otherwise they persistXML DB has versioning capabilities, and you can also register the same schemas multiple times using different URLs.
hope this explains my thoughts a bit more comprehensivelySure :)
I understand you're more looking for some kind of one-shot validation functionality, where schemas can change ad libitum.
That's typically the purpose of an external tool then.
:) thanks - while I agree with all your comments as options I have available, the single validation method
isValidBoo := myXMLdoc.validateAgainstSchema(myXMLschemaDoc);
would be way the quickest, cleanest and most appropriate solution for what I am trying to achieve, and I believe it opens up nice options for XML validation to developers
So come on Oracle - as schema validation functionality exists in oracle already via XML DB adding a new "validate using schema( schemaDoc XMLtype)" method to XMLtype surely shouldn't be too difficult???