|
|
fn:document(
|
|
$uris as item()*,
|
|
[$base-node as node()]
|
| ) as document-node()* |
|
 |
Summary:
Returns the document(s) stored in the database at the specified URI(s).
The URI(s) are resolved according to the base-uri of the calling
stylesheet or XQuery main module.
This is an XSLT function, and it is available in both XSLT and in
XQuery 1.0-ml.
|
Parameters:
$uris
:
The $uris is a sequence of the URI(s) of the document(s) to be retrieved.
This parameter is mandatory. However you may pass a singleton sequence
with an empty string in it. In that case it will return the stylesheet
that contains this function call when called from XSLT stylesheet and
all the documents in the database when called from XQuery- this is allowed
only when you are not using version 1.0 strict. If any URI in this sequence
is an absolute URI, then it is used as is. If it is a relative
URI, it is resolved against a base URI specified in the second argument.
|
$base-node
(optional):
If $base-node is supplied, its base URI is used to resolve relative
URIs in uri-sequence. If it is not supplied, the base URI of the node
that contained the fn:document() call is used.
|
|
Usage Notes:
If no second argument is specified, the URI resolves using the base-uri
of the calling module. This can cause surprising results if the URI you are
resolving is not rooted but the module from which you call it has a base-uri.
When calling fn:document from an xdmp:eval,
the calling module is defined to have no base-uri. When calling from an
XQuery module or an XSLT stylesheet, the base-uri is the URI of the
module or stylesheet. For an example to demonstrate this , see the
second example below.
For the URI to be exactly what you enter, use
fn:doc instead.
|
Example:
fn:document(("/product.xml", "/price.xml"),
< a xml:base="http://www.marklogic.com" />)
|
Example:
xquery version "1.0-ml";
(:
This module should be at the App Server root with a name test.xqy,
so it resolves to /test.xqy from the App Server's root.
:)
xdmp:set-response-content-type("text/plain"),
xdmp:document-insert("testing.xml", <foo/>);
xdmp:document-insert("/testing.xml", <bar/>);
declare option xdmp:output "indent-untyped=yes";
<root>
<document-from-module>
<document>{fn:document("testing.xml")}</document>
</document-from-module>
<document-from-eval>
<document>{xdmp:eval('fn:document("testing.xml")')}</document>
</document-from-eval>
</root>
(:
From the module, the document cannot find the URI "testing.xml"
because the base-uri of the module is its URI relative to the
App Server root. It therefore finds /testing.xml because that is what
the URI testing.xml resolves to (testing.xml resolves to /testing.xml when
the base-uri is /test.xqy). From an eval, there is no base-uri, so
it can find an unrooted URI (testing.xml resolves to testing.xml when the
base-uri is empty).
:)
=>
<root>
<document-from-module>
<document>
<bar/>
</document>
</document-from-module>
<document-from-eval>
<document>
<foo/>
</document>
</document-from-eval>
</root>
|
|
|
|
fn:element-available(
|
|
$element-name as xs:string
|
| ) as xs:boolean |
|
 |
Summary:
Returns true if and only if the name of an XSLT instruction is passed
in.
This function is only available in XSLT; it is not available
in XQuery.
|
Parameters:
$element-name
:
The name of the element to test.
|
|
Example:
xquery version "1.0-ml";
xdmp:xslt-eval(
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="foo">
<xsl:value-of
select="element-available('xsl:apply-templates')"/>
</xsl:template>
</xsl:stylesheet>,
document{<foo>hello there</foo>})
=> true
|
|
|
|
fn:format-number(
|
|
$value as numeric,
|
|
$picture as xs:string,
|
|
[$decimal-format-name as xs:string]
|
| ) as xs:string |
|
 |
Summary:
Returns a formatted string representation of value argument based
on the supplied picture. An optional decimal format name may also
be supplied for interpretation of the picture string. This
is an XSLT function, and it is available in both XSLT and in XQuery 1.0-ml.
|
Parameters:
$value
:
The given numeric $value that needs to be formatted. The
type of this argument must be a numeric type (for example, xs:integer,
xs:float, xs:double, or xs:decimal).
|
$picture
:
The desired string representation of the given number $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.
|
$decimal-format-name
(optional):
Represents a named <xsl:decimal-format> instruction.
It is used to assign values to the variables mentioned above
based on the picture string.
|
|
Example:
xquery version "1.0-ml";
fn:format-number(xs:integer("1000000"),"#,##0.00")
=>
1,000,000.00
|
Example:
xquery version "1.0-ml";
let $stylesheet :=
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:decimal-format name="testformat" decimal-separator="."/>
<xsl:template match="foo">
<xsl:sequence select="format-number(xs:float('1234.5'), '#,##0.00',
'testformat')"/>
</xsl:template>
</xsl:stylesheet>
return
xdmp:xslt-eval($s, document{<foo/>})
=>
1,234.50
|
|
|