Skip to main content

I have an XML Formatter transformer translating a query out of a MSSQL Database.  My XLD does not allow empty values, thus I always need to go through with a text editor and find XML Tags which look like this:

<KONTAKT2_EMAIL></KONTAKT2_EMAIL>

and change them to this:

<KONTAKT2_EMAIL xsi:nil="true" />

This is rather time consuming and I would like to perform this validity check in fme. I would therefore need to build in the following logic into the xml formatter transformer:

if Value = Null then XML Tag ends with xsi:nil="true" />

Any idea how to achieve this?

Hi @robertdbuckley, the XMLXQueryUpdater with this XQuery expression replaces value of every existing xsi:nil attribute with true and adds xsi:nil attribute with value of true to every empty element missing xsi:nil attribute.

for $x in //*tfn:empty(child::*) and fn:empty(text())]
return if (fn:exists($x/@xsi:nil))
    then replace value of node $x/@xsi:nil with true
    else insert node attribute xsi:nil {true} into $x

0684Q00000ArLCYQA3.png


Hi @robertdbuckley, the XMLXQueryUpdater with this XQuery expression replaces value of every existing xsi:nil attribute with true and adds xsi:nil attribute with value of true to every empty element missing xsi:nil attribute.

for $x in //*tfn:empty(child::*) and fn:empty(text())]
return if (fn:exists($x/@xsi:nil))
    then replace value of node $x/@xsi:nil with true
    else insert node attribute xsi:nil {true} into $x

0684Q00000ArLCYQA3.png

Thank you!

 

 


Reply