In furtherance of Mary's post here is a function that I put together a while
back to do the same thing.
declare function validate-schema-inline(
$document as node(),
$schema-uris as xs:string*,
$mode as xs:string
) {
let $xsl :=
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdmp="http://marklogic.com/xdmp"
xmlns:map="http://marklogic.com/map"
xmlns:error="http://marklogic.com/xdmp/error"
extension-element-prefixes="xdmp map" version="2.0">
<xsl:output method="xml" indent="yes" />
{
for $uri in $schema-uris
return
<xsl:import-schema>{fn:doc($uri)}</xsl:import-schema>
}
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ns1:*">
<xsl:copy-of select="." validation="{$mode}"/>
</xsl:template>
</xsl:stylesheet>
return
xdmp:xslt-eval(document {$xsl},
if($document instance of document-node())
then $document
else document {$document}
)
};
Gary Vidal
Principal Consultant
MarkLogic Corporation
[email protected]
Phone: +1 917 576-5794
Skype: ml-garyvidal
www.marklogic.com
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Tuesday, February 04, 2014 1:23 PM
To: [email protected]
Subject: General Digest, Vol 116, Issue 2
Send General mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://developer.marklogic.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific than "Re:
Contents of General digest..."
Today's Topics:
1. Post-read trigger? (Geert J.)
2. schema validation (Whitby, Rob)
3. Re: schema validation (Geert J.)
4. Re: schema validation (Anthony Coates)
5. Re: schema validation (Mary Holstege)
----------------------------------------------------------------------
Message: 1
Date: Tue, 4 Feb 2014 08:29:02 +0100
From: "Geert J." <[email protected]>
Subject: [MarkLogic Dev General] Post-read trigger?
To: MarkLogic Developer Discussion <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Would a post-read trigger (only at accessing a document explicitly using
doc()) make sense? For instance to update a view-count in the document
properties. Saves one from spawning a task oneself..
Cheers
M.Sc. G.P.H. (Geert) Josten
Senior Developer
Dayon B.V.
Delftechpark 37b
2628 XJ Delft
The Netherlands
T +31 (0)88 26 82 570
[email protected]
www.dayon.nl
De informatie - verzonden in of met dit e-mailbericht - is afkomstig van Dayon
BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht
kunnen geen rechten worden ontleend.
------------------------------
Message: 2
Date: Tue, 4 Feb 2014 12:55:24 +0000
From: "Whitby, Rob" <[email protected]>
Subject: [MarkLogic Dev General] schema validation
To: MarkLogic Developer Discussion <[email protected]>
Message-ID: <cf1693ba.11920%[email protected]>
Content-Type: text/plain; charset="windows-1252"
Hi,
I can?t seem to figure out how to use a schema without loading it into the
schemas db. Is something like this possible?
let $xml := <foo>?
let $schema := <xs:schema>?
let $validate := ???
Thanks
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://developer.marklogic.com/pipermail/general/attachments/20140204/7d3e1f73/attachment-0001.html
------------------------------
Message: 3
Date: Tue, 4 Feb 2014 15:10:12 +0100
From: "Geert J." <[email protected]>
Subject: Re: [MarkLogic Dev General] schema validation
To: MarkLogic Developer Discussion <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi Rob,
As far as I know, no. But you can specify a different database as Schemas
database. It should in principle be possible to select a docs database itself
as Schemas database..
Kind regards,
Geert
*Van:* [email protected] [mailto:
[email protected]] *Namens *Whitby, Rob
*Verzonden:* dinsdag 4 februari 2014 13:55
*Aan:* MarkLogic Developer Discussion
*Onderwerp:* [MarkLogic Dev General] schema validation
Hi,
I can't seem to figure out how to use a schema without loading it into the
schemas db. Is something like this possible?
let $xml := <foo>...
let $schema := <xs:schema>...
let $validate := ???
Thanks
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://developer.marklogic.com/pipermail/general/attachments/20140204/1dbfcb2f/attachment-0001.html
------------------------------
Message: 4
Date: Tue, 4 Feb 2014 16:14:21 +0000
From: Anthony Coates <[email protected]>
Subject: Re: [MarkLogic Dev General] schema validation
To: MarkLogic Developer Discussion <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
Classification: Public
The problem, as least for me sometimes, is that MarkLogic assumes you can
select the Schema(s) based on the namespace URI, and so you are stuck if you
need to select a specific Schema or set of Schemas where there isn't a
1-to-1 mapping between Schemas and namespace URIs (as often there isn't, e.g.
for FpML).
Cheers, Tony.
____________________________________________________
Anthony B. Coates (Tony)
VP | Solution/Data Architect
Deutsche Bank AG, Filiale London
Global Technology and Operations (GTO)
1 Appold Street, EC2A 2UU London, United Kingdom Tel. +44(20)754-77217 Mobile
+44(79)0543-9026 Email [email protected]
From:
"Geert J." <[email protected]>
To:
MarkLogic Developer Discussion <[email protected]>,
Date:
04/02/2014 14:10
Subject:
Re: [MarkLogic Dev General] schema validation
Hi Rob,
As far as I know, no. But you can specify a different database as Schemas
database. It should in principle be possible to select a docs database
itself as Schemas database..
Kind regards,
Geert
Van: [email protected] [mailto:
[email protected]] Namens Whitby, Rob
Verzonden: dinsdag 4 februari 2014 13:55
Aan: MarkLogic Developer Discussion
Onderwerp: [MarkLogic Dev General] schema validation
Hi,
I can?t seem to figure out how to use a schema without loading it into the
schemas db. Is something like this possible?
let $xml := <foo>?
let $schema := <xs:schema>?
let $validate := ???
Thanks
Rob
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
---
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient (or have received this e-mail in error) please
notify the sender immediately and delete this e-mail. Any unauthorized copying,
disclosure or distribution of the material in this e-mail is strictly forbidden.
Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional
EU corporate and regulatory disclosures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://developer.marklogic.com/pipermail/general/attachments/20140204/9c56ae10/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 374 bytes
Desc: not available
Url :
http://developer.marklogic.com/pipermail/general/attachments/20140204/9c56ae10/attachment-0002.gif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1124 bytes
Desc: not available
Url :
http://developer.marklogic.com/pipermail/general/attachments/20140204/9c56ae10/attachment-0003.gif
------------------------------
Message: 5
Date: Tue, 04 Feb 2014 08:25:34 -0800
From: "Mary Holstege" <[email protected]>
Subject: Re: [MarkLogic Dev General] schema validation
To: "MarkLogic Developer Discussion"
<[email protected]>, "Whitby, Rob"
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
On Tue, 04 Feb 2014 04:55:24 -0800, Whitby, Rob <[email protected]>
wrote:
> Hi,
>
> I can?t seem to figure out how to use a schema without loading it into
> the schemas db. Is something like this possible?
>
> let $xml := <foo>?
> let $schema := <xs:schema>?
> let $validate := ???
>
> Thanks
> Rob
>
>
There's a hacky way to do this via XSLT, which does support
embedded schema files.
Something like
let $xml = <foo>...
return
xdmp:xslt-eval(
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:my="http://exaple.com/xsd1/"
exclude-result-prefixes="xsi">
<xsl:import-schema namespace="http://example.com/xsd1/">
<xs:schema targetNamespace="http://example.com/xsd1/">
<!-- your schema stuff here -->
</xs:schema>
</xsl:import-schema>
<xsl:template match="/">
<xsl:copy-of select="." validation="strict"/>
</xsl:template>
</xsl:stylesheet>, document {$xml} )
//Mary
------------------------------
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
End of General Digest, Vol 116, Issue 2
***************************************
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general