The queryxmlstring() function
Smartsite 7.9 - ...
The queryxmlstring() extension function queries the specified xml string using the specified xpath statement.
| XML |
|
|---|---|
string exf:queryxmlstring(string xml, string xpath) string exf:queryxmlstring(string xml, string xpath, string prefix, string namespace) |
|
Parameters:
- string xml: the xml (escaped) string to query.
- string xpath: the xpath statement.
- string prefix (optional): the namespace prefix.
- string namespace (optional): the namespace.
Example
| XML |
|
|---|---|
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:a="uri:localization"
xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0">
<head>
<title>Example</title>
<xf:model>
<xf:instance>
<data xmlns="">
<moddate xsi:type="xf:dateTime">2018-01-30T10:34:00.000</moddate>
<resources><![CDATA[
<data xmlns="uri:localization">
<strings lang="nl-NL">
<string code="TITLE">Titel</string>
<string code="MODDATE">Wijzigingsdatum</string>
</strings>
<strings lang="en-US">
<string code="TITLE">Title</string>
<string code="MODDATE">Modification date</string>
</strings>
</data>
]]></resources>
</data>
</xf:instance>
</xf:model>
</head>
<body>
<xf:group ref="/data" appearance="full" xml:lang="nl-nl">
<xf:label/>
<xf:output value="exf:queryxmlstring(resources, concat('b:strings[@lang="', exf:lang(), '"]/b:string[@code="TITLE"]'),'b','uri:localization') " />
<xf:output value="exf:queryxmlstring(resources, concat('b:strings[@lang="', exf:lang(), '"]/b:string[@code="MODDATE"]'),'b','uri:localization') " />
</xf:group>
<xf:group ref="/data" appearance="full" xml:lang="en-US">
<xf:label/>
<xf:output value="exf:queryxmlstring(resources, concat('b:strings[@lang="', exf:lang(), '"]/b:string[@code="TITLE"]'),'b','uri:localization') " />
<xf:output value="exf:queryxmlstring(resources, concat('b:strings[@lang="', exf:lang(), '"]/b:string[@code="MODDATE"]'),'b','uri:localization') " />
</xf:group>
</body>
</html>
|
|
The result will be:
Titel
Wijzigingsdatum
Title
Modification date
Wijzigingsdatum
Title
Modification date
Namespace
This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).