Skip to main content
Question

Dealing with nullable attributes in XmlTemplater


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.

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+17
  • 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
Evangelist
  • 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"} {trueinto $x ,
return /*

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings