Description
The functx:has-mixed-content function returns true if the element has mixed content, i.e. both child elements and textual (character data) content other than whitespace.
Technically, when a schema is not in use, the spaces and line breaks used to pretty-print XML documents do count as text nodes. However, for convenience, this function ignores them.
Arguments and Return TypeName | Type | Description |
$element |
element() |
the XML element to test |
return value |
xs:boolean |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:has-mixed-content" as="xs:boolean"
xmlns:functx="http://www.functx.com">
<xsl:param name="element" as="element()"/>
<xsl:sequence select="
$element/text()[normalize-space(.) != ''] and $element/*
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <in-xml>
<a></a>
<b/>
<c> </c>
<d>xml</d>
<e><x>xml</x></e>
<f>mixed <x>xml</x></f>
<g> <x>xml</x> </g>
</in-xml> |
| </xsl:variable> |
XPath Example | Results |
---|
functx:has-mixed-content($in-xml/a) |
false |
functx:has-mixed-content($in-xml/b) |
false |
functx:has-mixed-content($in-xml/c) |
false |
functx:has-mixed-content($in-xml/d) |
false |
functx:has-mixed-content($in-xml/e) |
false |
functx:has-mixed-content($in-xml/f) |
true |
functx:has-mixed-content($in-xml/g) |
false |
See AlsoHistory |
Recommended Reading:
|