Description
The functx:has-simple-content function returns true if the element has no child elements but does have some textual (character data) content, even if it is all whitespace.
Arguments and Return Type| Name | Type | Description |
$element |
element() |
the XML element to test |
| return value |
xs:boolean |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:has-simple-content
( $element as element() ) as xs:boolean {
$element/text() and not($element/*)
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function has-simple-content
( $element as element() ) as xs:boolean {
$element/text() and fn:not($element/*)
} |
Exampleslet $in-xml := | <in-xml>
<a></a>
<b/>
<c> </c>
<d>xml</d>
<e><x>xml</x></e>
<f>mixed <x>xml</x></f>
</in-xml> | return |
| XQuery Example | Results |
|---|
functx:has-simple-content($in-xml/a)
|
false
|
functx:has-simple-content($in-xml/b)
|
false
|
functx:has-simple-content($in-xml/c)
|
true
|
functx:has-simple-content($in-xml/d)
|
true
|
functx:has-simple-content($in-xml/e)
|
false
|
functx:has-simple-content($in-xml/f)
|
false
|
See AlsoHistory |
|