Question

write all attributes gml

  • 20 June 2017
  • 8 replies
  • 11 views

Badge +1

Hi,

I'm new to gml so probably this is simple question.

If I'm writing to gml and all features have <missing> (or null or empty) attribute called "my_attribute" then "something" wont be written to output GML. How to write it regardles?


8 replies

Userlevel 2
Badge +16

You will need to give the attribute a value using the NullAttributeMapper.

I would for example add a space to all null attributes to force them to the output.

Badge +1

You will need to give the attribute a value using the NullAttributeMapper.

I would for example add a space to all null attributes to force them to the output.

Hi @erik_jan

 

 

No, I don't want space sign, zero sign, empty quotation marks... I'd like to have null value in according attribute in gml.

 

 

Thank you for your reply

 

Userlevel 2
Badge +16
Hi @erik_jan

 

 

No, I don't want space sign, zero sign, empty quotation marks... I'd like to have null value in according attribute in gml.

 

 

Thank you for your reply

 

Then the only option I see is using the XMLTemplater transformer to create the GML and write using the Text writer.

 

 

Userlevel 2
Badge +17

Hi @zzupljanin, if you mean that "null value" for the destination GML is an empty XML element like <my_attribute />, I think you can still use the NullAttributeValueMapper to assign Empty String to the <missing> attribute, so that an empty XML element will be written.

Userlevel 2
Badge +17

Hi @zzupljanin, if you mean that "null value" for the destination GML is an empty XML element like <my_attribute />, I think you can still use the NullAttributeValueMapper to assign Empty String to the <missing> attribute, so that an empty XML element will be written.

Or, even if you need to write a text value "null" (i.e. <my_attribute>null</my_attribute>) when the attribute is <missing>, <empty>, or <null>, the NullAttributeValueMapper is still helpful. I'm unclear the actual requirement anyway...

 

Userlevel 4
Badge +25

I'm guessing you want something like <item xsi:nil="true"/> or <item xsi:nil="true"></item>

FME should do that if:

  • The FME attribute is set to Null (using the NullAttributeMapper if necessary)
  • You're using a schema that allows nils, i.e. <xsd:element name="item" nillable="true"/>
  • minOccurs="1"

I'll freely admit I don't really know what minOccurs is supposed to represent, but I do know this won't work if it is set to 0 (zero).

I hope this helps. Let me know if not and I can ask one of our XML experts to give their opinion.

Userlevel 4
Badge +25

I'm guessing you want something like <item xsi:nil="true"/> or <item xsi:nil="true"></item>

FME should do that if:

  • The FME attribute is set to Null (using the NullAttributeMapper if necessary)
  • You're using a schema that allows nils, i.e. <xsd:element name="item" nillable="true"/>
  • minOccurs="1"

I'll freely admit I don't really know what minOccurs is supposed to represent, but I do know this won't work if it is set to 0 (zero).

I hope this helps. Let me know if not and I can ask one of our XML experts to give their opinion.

For my reference (and for the Safe support team if you contact them) this is related to PR#50274

 

Userlevel 4
Badge +25

I'm guessing you want something like <item xsi:nil="true"/> or <item xsi:nil="true"></item>

FME should do that if:

  • The FME attribute is set to Null (using the NullAttributeMapper if necessary)
  • You're using a schema that allows nils, i.e. <xsd:element name="item" nillable="true"/>
  • minOccurs="1"

I'll freely admit I don't really know what minOccurs is supposed to represent, but I do know this won't work if it is set to 0 (zero).

I hope this helps. Let me know if not and I can ask one of our XML experts to give their opinion.

Right, just to confirm/clarify - you can't write nulls to GML with FME if FME is generating the schema, because there's no way (yet) to define an attribute as nillable. If you use an external schema then it can have a nillable attribute, and FME can write a null value to it.

 

 

minOccurs is a bit of a red herring. It seems to be a flag for optional. 1 or more means that the element has to appear. FME generated schemas are always zero meaning optional (nill isn't disallowed, but it isn't defined either).

 

 

If using an existing schema, and the schema says that the element is both required (minOccurs="1") and nillable, then the GML writer will generate the element with the xsi:nil="true", because it the schema says it must be present in the output.

 

 

Reply