On Fri, 09 Oct 2009 02:27:36 -0700, Ashwini <[email protected]>
wrote:
But i removed some of the required elements from xml and i did
schema validation on the new xml.
the validate function did not throw any exceptions. as per schema the
xml file is wrong, but i failed to get exception by using marklogic
function.
Which version of MarkLogic Server are you using? Prior to 4.1
the schema validation support was essentially limited to simple
type checking and a small amount of attribute checking. If you
are using 4.1, try validate strict. It could be that you are not actually
finding the schema, and in lax mode that's OK and no exceptions
will be thrown. If you aren't getting the errors in strict mode, and
you are running 4.1, I would be very interested in seeing your
schema/document. There are some bugs in our schema support
surrounding inheritance of content models through groups and
substitution groups, in some cases, but it may be you have found a
new case.
how to use validate lax {$node} , i want to chk a xml file with schema
before inserting .
Please help me out. What I need to do so that when I load a new xml file
into the database then MarkLogic should validate it before loading
and also will it possible to check on collection level, with out
providing
schema location in xml file.
Schemas are located via namespace. If there is only one schema in your
schemas database for that namespace, the server will use that one.
Where there is more than one schema for a namespace, disambiguation
depends on the schema location obtained in the following order:
(1) the schema location on the document
(2) schemas imported into the query through the XQuery
import schema declaration
(3) schemas configured via the Schemas item in the group in the admin UI
(4) a schema selected from the schemas database (if there is more than
one, this is an effectively random selection)
(5) a standard schema loaded on startup (from the Config directory)
If you want to validate a document before inserting it into the database
you need to write your load script to do that, using the validate
expression.
If you want to automatically do that for every document loaded into the
database by whatever means you could use the validation pipeline in
CPF: install CPF and attach the validation pipeline to your domain. This
pipeline will validate all (XML) documents inserted into the domain.
It will not delete the document: it just puts the document into an
error state and notes the specific validation error in its properties.
You could put in your own custom error handling pipeline to make of
that information what you wish. Note that CPF is running this
asynchronously, so you won't see the error directly on loading the
document: you need some kind of process to look for erroneous
documents after the fact.
If you really want all XML documents to be rejected and prevented from
being loaded at all into the server, however they get inserted, then
you need to make a custom pre-commit trigger. (Pre-commit so that
when it throws an error the entire transaction is aborted and the
document is not inserted. This means any documents loaded
together in the same query will also fail.)
//Mary
[email protected]
Principal Engineer
Mark Logic Corporation
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general