Hello everybody, i have mapped my sql server table to an xml schema and final output we are getting metadata of tables. To input related Foreignkey information inside metadata we have a field and we mapped it, problem is for many rows we dont have values, we have NULL. From current mapping values are coming and NULL values are creating empty elements in final xml file. Please see the screenshort. We want to delete the total bnr:foreignkey element for NULL values. Please correct my code if someone can help me. Thanks a lot. Looking forward.
Hello @mjoarder_pln
If the features are associated with incoming FME-feature fields/attributes, you could check for NULL attributes using the Tester transformer.
There is another method, I want to verify whether or not it is still the recommended way. I will update this post when I talk to the other XML experts.
You can use an if-clause around the whole block, something like
{
if (not($fkey eq "")) then
<bnr:foreignKey>
...
</bnr:foreignKey>
else
""
}
The syntax is explained in the help under the heading "Root template":
If there were many elements to be removed when empty, it could be easier to add an XMLFormatter and set "Yes" to its "Remove Empty Elements" parameter.
If there were many elements to be removed when empty, it could be easier to add an XMLFormatter and set "Yes" to its "Remove Empty Elements" parameter.
You can use an if-clause around the whole block, something like
{
if (not($fkey eq "")) then
<bnr:foreignKey>
...
</bnr:foreignKey>
else
""
}
The syntax is explained in the help under the heading "Root template":
For me this is not working, may be i wrote wrong.
{
if (not($fkey eq "NULL")) then
<bnr:foreignKey>
<bnr:MD_ForeignKey>
<bnr:identifier>
<gmd:MD_Identifier>
<gmd:code>
<gco:CharacterString>{fme:get-attribute($fkey)}</gco:CharacterString>
</gmd:code>
</gmd:MD_Identifier>
</bnr:identifier>
<bnr:table>
<gco:CharacterString/>
</bnr:table>
<bnr:column>
<gco:CharacterString/>
</bnr:column>
</bnr:MD_ForeignKey>
</bnr:foreignKey>
else
""
}
If there were many elements to be removed when empty, it could be easier to add an XMLFormatter and set "Yes" to its "Remove Empty Elements" parameter.
Hello @mjoarder_pln
If the features are associated with incoming FME-feature fields/attributes, you could check for NULL attributes using the Tester transformer.
There is another method, I want to verify whether or not it is still the recommended way. I will update this post when I talk to the other XML experts.
You can use an if-clause around the whole block, something like
{
if (not($fkey eq "")) then
<bnr:foreignKey>
...
</bnr:foreignKey>
else
""
}
The syntax is explained in the help under the heading "Root template":