Download Altova MobileTogether Designer
Transcript
862
Appendices
XSLT and XPath/XQuery Functions
as item()? XP3 XQ3
This function takes two arguments. The first argument is a sequence of one or more items of
any datatype. The second argument, Condition, is a reference to an XPath function that
takes one argument (has an arity of 1) and returns a boolean. Each item of Sequence is
submitted, in turn, to the function referenced in Condition. (Remember: This function takes
a single argument.) The first Sequence item that causes the function in Condition to
evaluate to true() is returned as the result of find-first, and the iteration stops.
Examples
find-first(5 to 10, function($a) {$a mod 2 = 0}) returns xs:integer 6
The Condition argument references the XPath 3.0 inline function, function(), which
declares an inline function named $a and then defines it. Each item in the Sequence
argument of find-first is passed, in turn, to $a as its input value. The input value is
tested on the condition in the function definition ($a mod 2 = 0). The first input value to
satisfy this condition is returned as the result of find-first (in this case 6).
find-first((1 to 10), (function($a) {$a+3=7})) returns xs:integer 4
Further examples
If the file C:\Temp\Customers.xml exists:
find-first( ("C:\Temp\Customers.xml", "http://www.altova.com/
index.html"), (doc-available#1) ) returns xs:string C:\Temp
\Customers.xml
If the file C:\Temp\Customers.xml does not exist, and http://www.altova.com/
index.html exists:
find-first( ("C:\Temp\Customers.xml", "http://www.altova.com/
index.html"), (doc-available#1) ) returns xs:string http://
www.altova.com/index.html
If the file C:\Temp\Customers.xml does not exist, and http://www.altova.com/
index.html also does not exist:
find-first( ("C:\Temp\Customers.xml", "http://www.altova.com/
index.html"), (doc-available#1) ) returns no result
Notes about the examples given above
The XPath 3.0 function, doc-available, takes a single string argument, which is
used as a URI, and returns true if a document node is found at the submitted URI.
(The document at the submitted URI must therefore be an XML document.)
The doc-available function can be used for Condition, the second argument of
find-first, because it takes only one argument (arity=1), because it takes an
item() as input (a string which is used as a URI), and returns a boolean value.
Notice that the doc-available function is only referenced, not called. The #1 suffix
that is attached to it indicates a function with an arity of 1. In its entirety docavailable#1 simply means: Use the doc-availabe() function that has arity=1,
passing to it as its single argument, in turn, each of the items in the first sequence.
As a result, each of the two strings will be passed to doc-available(), which
uses the string as a URI and tests whether a document node exists at the URI. If
one does, the doc-available() evaluates to true() and that string is returned as
Altova MobileTogether Designer
© 2015 Altova Gmb H
Related documents
Altova MobileTogether Designer
ThinRDP Workstation User's Guide
Appli* MobileTogether Windows Phone
Altova StyleVision 2016 Basic Edition
Datalogic Hand-held devices II User`s manual
Skorpio™ X3
Aplicación MobileTogether para Windows Phone
Datalogic Falcon X3+
Altova MapForce 2016
Altova MobileTogether Server
Aplicación móvil MobileTogether para WebClient
1 Altova SemanticWorks 2012