Skip to main content
Question

Dealing with nullable attributes in XmlTemplater

  • July 31, 2014
  • 3 replies
  • 34 views

Hi,

 

 

I use XmlTemplater to create gml document. In my needed xsd schema which I use to produce xml sample for XmlTemplater, there is too many nullable attributes. Thing is, validation cann;t pass against schema because attrubutes like <attribute></attribute>. It needs to be <attribute xsi:nill="true"> (I thing). Is there any way to tell XmlTemplater or FME to write <attribute xsi:nill="true"> for all null attributes and empty strings, without writting if/else in XmlTemplater (if null write <attribute xsi:nill="true"> else <attribute>value</attribute>)?

 

Is there some other way I can do this? I have about 300-400 attributes like this.
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

Forum|alt.badge.img

I would also like to know how to combat this! Anyone able to help?


itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • November 14, 2016

Hi @aleksandar, I would turn off the validation in the XMLTemplater and replace the tags via a StringReplacer, once that is done pass the XML via the XMLValidator to check against the xsd schema.

Hope this helps.


takashi
Celebrity
  • November 15, 2016

Hi @aleksandar and @robertdbuckley, I think it's hard to automatically set the 'xsi:nil' attributes with the XMLTemplater.  After creating XML document containing empty elements, the XMLXQueryUpdater with this XQuery expression can also be used to add the 'xsi:nil' attribute to every empty element.

(: add 'xsi:nil' attribute with value of true to every empty element :)
for $x in //*[fn:empty(text())]
  return insert node attribute {"xsi:nil"} {true} into $x ,
return /*