Hi @dms2, a possible way is to extract the original values from the source XML document as feature attributes (e.g. _original_minx, _original_maxx etc.), merge them to the Update feature, then use them in the expressions. e.g.
if (fme:get-attribute('_minx') ne '') then fme:get-attribute('_minx') else fme:get-attribute('_original_minx')
Alternatively, the XMLXQueryUpdater can also be used more flexibly, if you merge the new values (_minx, _maxx etc.) to the feature which has the XML document. Assuming that the feature has an attribute called "response" which stores this XML document, the following setting is possible.
<?xml version="1.0"?>
<root>
<minx>0</minx>
<maxx>100</maxx>
</root>
XQuery Expression:
let $minx := xs:string(fme:get-attribute("_minx"))
let $maxx := xs:string(fme:get-attribute("_maxx"))
return {
if ($minx ne '') then replace value of node /root/minx with $minx else (),
if ($maxx ne '') then replace value of node /root/maxx with $maxx else ()
}
Hi @dms2, a possible way is to extract the original values from the source XML document as feature attributes (e.g. _original_minx, _original_maxx etc.), merge them to the Update feature, then use them in the expressions. e.g.
if (fme:get-attribute('_minx') ne '') then fme:get-attribute('_minx') else fme:get-attribute('_original_minx')
Alternatively, the XMLXQueryUpdater can also be used more flexibly, if you merge the new values (_minx, _maxx etc.) to the feature which has the XML document. Assuming that the feature has an attribute called "response" which stores this XML document, the following setting is possible.
<?xml version="1.0"?>
<root>
<minx>0</minx>
<maxx>100</maxx>
</root>
XQuery Expression:
let $minx := xs:string(fme:get-attribute("_minx"))
let $maxx := xs:string(fme:get-attribute("_maxx"))
return {
if ($minx ne '') then replace value of node /root/minx with $minx else (),
if ($maxx ne '') then replace value of node /root/maxx with $maxx else ()
}
Note that namespace declarations will be required in XQuery expressions if the source XML contains namespaces. See also this Q&A;:
Add zeros in real numbers
fAddition] This is an example if the XML elements belong to a namespace.
Source XML:
<?xml version="1.0"?>
<k:root xmlns:k="http://www.foobar.com/xml/k">
<k:minx>0</k:minx>
<k:maxx>100</k:maxx>
</k:root>
XQuery Expression:
declare namespace k="http://www.foobar.com/xml/k";
let $minx := xs:string(fme:get-attribute("_minx"))
let $maxx := xs:string(fme:get-attribute("_maxx"))
return {
if ($minx ne '') then replace value of node /k:root/k:minx with $minx else (),
if ($maxx ne '') then replace value of node /k:root/k:maxx with $maxx else ()
}
Hi @dms2, a possible way is to extract the original values from the source XML document as feature attributes (e.g. _original_minx, _original_maxx etc.), merge them to the Update feature, then use them in the expressions. e.g.
if (fme:get-attribute('_minx') ne '') then fme:get-attribute('_minx') else fme:get-attribute('_original_minx')
Alternatively, the XMLXQueryUpdater can also be used more flexibly, if you merge the new values (_minx, _maxx etc.) to the feature which has the XML document. Assuming that the feature has an attribute called "response" which stores this XML document, the following setting is possible.
<?xml version="1.0"?>
<root>
<minx>0</minx>
<maxx>100</maxx>
</root>
XQuery Expression:
let $minx := xs:string(fme:get-attribute("_minx"))
let $maxx := xs:string(fme:get-attribute("_maxx"))
return {
if ($minx ne '') then replace value of node /root/minx with $minx else (),
if ($maxx ne '') then replace value of node /root/maxx with $maxx else ()
}
The first option is perfect. Thank you.