|
|
xdmp:email(
|
|
$message as node()
|
| ) as empty-sequence() |
|
 |
Summary:
Send an email in an XQuery program. A valid SMTP Relay must be
configured in the Groups page of the Admin Interface for the email to be
sent. The format of the email message must be an XML file that
complies with the schema files listed below.
|
Parameters:
$message
:
An XML representation of an email message to send. The message must
comply with the XML schemas defined in the following schema files:
install_dir/Config/email-xml.xsd
install_dir/Config/rfc822.xsd
where install_dir is the directory in which
MarkLogic Server is installed.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-email
|
Example:
This example demonstrates sending a message with
HTML content.
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>Sample HTML Email</rf:subject>
<rf:from>
<em:Address>
<em:name>MarkLogic</em:name>
<em:adrs>marklogic@yourdomain</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>System Administrator</em:name>
<em:adrs>admin@yourdomain</em:adrs>
</em:Address>
</rf:to>
<em:content>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test HTML message</title>
</head>
<body>
<h1>Test HTML message</h1>
<p>Here is a simple paragraph</p>
</body>
</html>
</em:content>
</em:Message>)
|
Example:
This example demonstrate sending a message with
plain text content.
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>Sample Plain Text Email</rf:subject>
<rf:from>
<em:Address>
<em:name>MarkLogic</em:name>
<em:adrs>marklogic@yourdomain</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>System Administrator</em:name>
<em:adrs>admin@yourdomain</em:adrs>
</em:Address>
</rf:to>
<em:content xml:space="preserve">
This is a sample email with a plain text body.
</em:content>
</em:Message>)
|
Example:
This example demonstrates sending a message with
attachments.
let $newline := " "
let $boundary := concat("blah", xdmp:random())
let $content-type := concat("multipart/mixed; boundary=",$boundary)
let $attachment1 := xs:base64Binary(doc("/space/binaries/testdata1/Bon-Jovi.jpeg"))
let $attachment2 := xs:base64Binary(doc("/space/binaries/testdata1/logo.gif"))
let $content := concat(
"--",$boundary,$newline,
$newline,
"This is a test email with two images attached.", $newline,
"--",$boundary,$newline,
"Content-Type: image/jpeg", $newline,
"Content-Disposition: attachment; filename=Bon-Jovi.jpeg", $newline,
"Content-Transfer-Encoding: base64", $newline,
$newline,
$attachment1, $newline,
"--",$boundary,$newline,
"Content-Type: image/gif", $newline,
"Content-Disposition: attachment; filename=logo.gif", $newline,
"Content-Transfer-Encoding: base64", $newline,
$newline,
$attachment2, $newline,
"--",$boundary,"--", $newline)
return
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>Sample Email</rf:subject>
<rf:from>
<em:Address>
<em:name>MarkLogic</em:name>
<em:adrs>marklogic@yourdomain</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>System Administrator</em:name>
<em:adrs>admin@yourdomain</em:adrs>
</em:Address>
</rf:to>
<rf:content-type>{$content-type}</rf:content-type>
<em:content xml:space="preserve">
{$content}
</em:content>
</em:Message>)
|
|
|
|
xdmp:multipart-decode(
|
|
$separator as xs:string,
|
|
$data as binary(),
|
|
$options as element()?
|
| ) as node()* |
|
 |
Summary:
Extract the parts from a multipart encoding. The first item in the
sequence is a manifest, and the remaining items are the decoded parts.
An attempt will be made to determine the type of content based on
headers such as the part's content-type. If possible, an element will be
returned, falling back to an xs:string, and finally binary().
The options control how the parts are unpacked, and are similar to
xdmp:zip-get - default-namespace, repair,
format, default-language,
and encoding. The options apply to all parts, so specifying a format of
binary will cause all parts to be returned as binary, and specifying text
will cause all parts to be returned as xs:string if possible, falling back
to binary() if necessary. This is useful if different parts need different
options, in which case the resulting strings can each be passed to
xdmp:unquote() with appropriate options.
|
Parameters:
$separator
:
The string that is to be used as a separator.
|
$data
:
The data to be decoded.
|
$options
:
Decode options.
|
|
Example:
xquery version "1.0-ml";
let $html:= document{ <html><p>Some stuff in an .html document</p></html> }
let $xml:= document{ <root><a>Some other stuff in a .xml document</a></root> }
let $text :=text{xdmp:to-json(("a",fn:false()))}
let $boundary-string:="gc0p4Jq0M2Yt08jU534c0p"
let $mpe := xdmp:multipart-encode(
$boundary-string,
<manifest>
<part>
<headers>
<Content-Type>xml</Content-Type>
<boundary>gc0p4Jq0M2Yt08jU534c0p</boundary>
</headers>
</part>
<part>
<headers>
<Content-Type>html</Content-Type>
</headers>
</part>
<part/>
</manifest>,
($xml,$html,$text) )
return xdmp:multipart-decode($boundary-string, $mpe)
=>
<manifest>
<part>
<headers>
<Content-Type>xml</Content-Type>
<boundary>gc0p4Jq0M2Yt08jU534c0p</boundary>
<Content-Length>94</Content-Length>
</headers>
</part>
<part>
<headers>
<Content-Type>html</Content-Type>
<Content-Length>90</Content-Length>
</headers>
</part>
<part>
<headers>
<Content-Type>text/plain</Content-Type>
<Content-Length>12</Content-Length>
</headers>
</part>
<part/>
</manifest>
<?xml version="1.0" encoding="UTF-8"?>
<root><a>Some other stuff in a .xml document</a></root>
<?xml version="1.0" encoding="UTF-8"?>
<html><p>Some stuff in an .html document</p></html>
["a", false]
|
|
|
|
xdmp:multipart-encode(
|
|
$separator as xs:string,
|
|
$manifest as element(),
|
|
$content as node*
|
| ) as binary() |
|
 |
Summary:
Create a multipart encoding of the specified node. The returned binary
node can be passed to xdmp:http-post.
The manifest is modeled after the
manifest that is passed to xdmp:zip-create,
with the headers element being
the same as is described for xdmp:http-get
allowing users to add arbitrary
headers to each part. If a content-type header is not specified for a part,
it will be determined if possible from the content.
There should be one part element for each node in the content sequence.
Each part also has an optional options node to control how xml or text
will be serialized. The two options are the same as for
xdmp:save.
<parts>
<part>
<headers>
<Content-Type>image/jpeg</Content-Type>
<headers>
<options>
<output-encoding>...</output-encoding>
<output-sgml-character-entities>...</output-sgml-character-entities>
</options>
</part>
</parts>
|
Parameters:
$separator
:
The string that is to be used as a separator.
|
$manifest
:
The manifest.
|
$content
:
The nodes that are to be encoded.
|
|
Example:
xquery version "1.0-ml";
let $html:= document{ <html><p>Some stuff in an .html document</p></html> }
let $xml:= document{ <root><a>Some other stuff in a .xml document</a></root> }
let $text :=text{xdmp:to-json(("a",fn:false()))}
let $boundary-string:="gc0p4Jq0M2Yt08jU534c0p"
return
xdmp:multipart-encode(
$boundary-string,
<manifest>
<part>
<headers>
<Content-Type>xml</Content-Type>
<boundary>gc0p4Jq0M2Yt08jU534c0p</boundary>
</headers>
</part>
<part>
<headers>
<Content-Type>html</Content-Type>
</headers>
</part>
<part/>
</manifest>,
($xml,$html,$text) )
=>
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: xml
boundary: gc0p4Jq0M2Yt08jU534c0p
Content-Length: 94
<?xml version="1.0" encoding="UTF-8"?>
<root><a>Some other stuff in a .xml document</a></root>
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: html
Content-Length: 90
<?xml version="1.0" encoding="UTF-8"?>
<html><p>Some stuff in an .html document</p></html>
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: text/plain
Content-Length: 12
["a", false]
--gc0p4Jq0M2Yt08jU534c0p--
|
|
|
|
xdmp:parse-dateTime(
|
|
$picture as xs:string,
|
|
$value as xs:string,
|
|
[$language as xs:string?],
|
|
[$calendar as xs:string?],
|
|
[$country as xs:string]
|
| ) as xs:dateTime |
|
 |
Summary:
Parses a string containing date, time or dateTime using the supplied
picture argument and returns a dateTime value. While this function
is closely related to other XSLT functions, it is available in XSLT
as well as in all XQuery dialects.
|
Parameters:
$picture
:
The desired string representation of the given $value.
The picture string is a sequence of characters, in which the
characters represent variables such as, decimal-separator-sign,
grouping-sign, zero-digit-sign, digit-sign, pattern-separator,
percent sign and per-mille-sign. For details on the picture string, see
http://www.w3.org/TR/xslt20/#date-picture-string.
This follows the specification of
picture string in the W3C XSLT 2.0
specification for the fn:format-dateTime function.
Symbol Description
-----------------------------------
'Y' year(absolute value)
'M' month in year
'D' day in month
'd' day in year
'F' day of week
'W' week in year
'w' week in month
'H' hour in day
'h' hour in half-day
'P' am/pm marker
'm' minute in hour
's' second in minute
'f' fractional seconds
'Z' timezone as a time offset from UTC
for example PST
'z' timezone as an offset using GMT,
for example GMT+1
|
$value
:
The given string $value representing the dateTime value
that needs to be formatted.
|
$language
(optional):
The language used in string representation of the date, time or
dateTime value.
|
$calendar
(optional):
This argument is reserved for future use. The only calendar supported
at this point is "Gregorian" or "AD".
|
$country
(optional):
$country is used to take into account if there any country specific
interpretation of the string while converting it into dateTime value.
|
|
Usage Notes:
Dates before October 15, 1582 (the start of the Gregorian calendar) will
not return the correct dateTime value.
The xdmp:parse-dateTime function will not parse all dates;
if it does not parse a date, it can throw the
XDMP-PATTERNVALUEMISMATCH exception. To help normalize
the dates so they can be parsed, you can try using the XSLT functions
defined in the following stylesheet:
<marklogic-dir>/Modules/MarkLogic/appservices/utils/normalize-dates.xsl
In particular xdmp:parse-dateTime does not support parsing names of days or months.
|
Example:
xdmp:parse-dateTime("[Y0001]-[M01]-[D01]T[h01]:[m01]:[s01].[f1][Z]","2010-01-06T17:13:50.873594-08:00")
|
|
|
|
xdmp:parse-yymmdd(
|
|
$picture as xs:string,
|
|
$value as xs:string,
|
|
[$language as xs:string?],
|
|
[$calendar as xs:string?],
|
|
[$country as xs:string?]
|
| ) as xs:dateTime |
|
 |
Summary:
Parses a string containing date, time or dateTime using the supplied
picture argument and returns a dateTime value. While this function
is closely related to other XSLT functions, it is available in XSLT
as well as in all XQuery dialects.
|
Parameters:
$picture
:
The desired string representation of the given $value.
This follows the specification of picture string which is
compatible to the format specification in icu. See
http://icu-project.org/apiref/icu4j/com/ibm/icu/text/SimpleDateFormat.html
for more details.
The following is the summary of the formatting symbols:
Symbol Description
----------------------------
"y" year(absolute value)
"M" month in year
"d" day in month
"D" day in year
"E" day of week
"w" week in year
"W" week in month
"H" hour in day
"K" hour in half-day
"a" am/pm marker
"s" second in minute
"S" fractional seconds
"Z" timezone as a time offset from UTC
for example PST
"ZZZZ" timezone as an offset using GMT,
for example GMT+1
|
$value
:
The given string $value that needs to be formatted.
|
$language
(optional):
The language used in string representation of the date, time or
dateTime value.
|
$calendar
(optional):
This argument is reserved for future use. The only calendar supported
at this point is "Gregorian" or "AD".
|
$country
(optional):
$country is used to take into account if there any country specific
interpretation of the string while converting it into dateTime value.
|
|
Usage Notes:
Dates before October 15, 1582 (the start of the Gregorian calendar) will
not return the correct dateTime value.
|
Example:
xdmp:parse-yymmdd("yyyy-MM-ddThh:mm:ss.Sz","2010-01-06T17:13:50.873594-8.00")
|
|
|
|
xdmp:QName-from-key(
|
|
$key as xs:string
|
| ) as xs:QName |
|
 |
Summary:
Construct a QName from a string of the form "{namespaceURI}localname".
This function is useful for constructing Clark notation
parameters for the xdmp:xslt-eval
and xdmp:xslt-invoke
functions.
|
Parameters:
$key
:
The string from which to construct a QName.
|
|
Example:
xquery version "1.0-ml";
(: returns the Clark notation form of the QName :)
xdmp:key-from-QName(xs:QName("fn:foo"))
=>
{http://www.w3.org/2005/xpath-functions}foo
|
|
|
|
xdmp:resolve-uri(
|
|
$relative as xs:string?,
|
|
[$base as xs:string]
|
| ) as xs:anyURI? |
|
 |
Summary:
Resolves a relative URI against an absolute URI. If $base is specified,
the URI is resolved relative to that base. If $base is not specified, the
base is set to the base-uri property from the static context, if the
property exists; if it does not exist, an error is thrown.
|
Parameters:
$relative
:
A URI reference to resolve against the base.
|
$base
(optional):
An absolute URI to use as the base of the resolution.
|
|
Usage Notes:
This function is the same as fn:resolve-uri(), but always accepts a relative
base URI. The fn:resolve-uri() function raises an error in this case in
standards compatible dialects.
If $base is specified, it is assumed to be an absolute URI and
$relative is assumed to be an absolute or a relative URI reference.
If $relative is a relative URI reference, it is resolved against $base,
using an algorithm such as the ones described in
[RFC 2396] or
[RFC 3986], and
the resulting absolute URI reference is returned.
If $relative is the zero-length string, fn:resolve-uri returns
the value of $base, or the base-uri property from the static context
if there is no $base value specified (if the base-uri property is
not initialized in the static context, an error is raised).
Resolving a URI does not dereference it. This is merely a syntactic operation
on two character strings.
|
Example:
xdmp:resolve-uri("hello/goodbye.xml",
"/mycompany/default.xqy")
=> /mycompany/hello/goodbye.xml
|
|
|