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

Badge

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

Badge +16

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.

Userlevel 2
Badge +17

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 /*

Reply