XMLport Export: Skip Empty Tags

stefan.karnelstefan.karnel Member Posts: 11
Hi there!

Does anyone know how to skip empty tags when exporting with a XMLport?

Thanks,
Stefan

Comments

  • DenSterDenSter Member Posts: 8,305
    I think you do that by setting the MinOccurs property of the element to zero.
  • stefan.karnelstefan.karnel Member Posts: 11
    I thought it too, but it doesn't work.
  • AcidReignAcidReign Member Posts: 5
    Have you solved the Problem yet? I have the same thing here at the moment!
  • maris2000maris2000 Member Posts: 71
    Can anybody help with this Empty tag issue?
    I have one custom table called Customer Info, and I guess that this empty space in the table name is giving me a trouble.
    Is there a way to work around this issue?
  • jlandeenjlandeen Member Posts: 524
    I'm not quite sure that you've described the problem well enough to obtain a solution?

    The MinOccurrs and MaxOccurs properties of an element control how NAV parses an XML document. If it's MinOccurs = Zero and MaxOccurs = Once then a valid XML document can contain the element 0 or 1 times only in the correct structure of the document. That should work for imports as well as exports.

    Are you having problems importing data or exporting data? Is it an error that occurs due to invalid XML or during another event (say field level OnValidate trigger)?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • jordi79jordi79 Member Posts: 274
    hi all,
    i am having the same problem here. for example... if i am exporting values in xml. if the field has no value, instead of skipping the xml tag, nav will export </field1>. If it has value it will export <field1>value</field1>.

    Is it possible in xmlports to get nav to skip exporting the tags if there is no value? I have tried setting the minoccurs to 0, but it does not help. nav still exports an empty xml tag.

    i am thinking the best way would be to remove all empty tag manually via a batch job after the xml file is created by nav. but i am trying to avoid doing this. if this is at all possible to be configured in NAV xmlports.
  • wizard_of_clausewizard_of_clause Member Posts: 6
    jordi79 wrote:
    hi all,
    i am having the same problem here. for example... if i am exporting values in xml. if the field has no value, instead of skipping the xml tag, nav will export </field1>. If it has value it will export <field1>value</field1>.

    Is it possible in xmlports to get nav to skip exporting the tags if there is no value? I have tried setting the minoccurs to 0, but it does not help. nav still exports an empty xml tag.

    i am thinking the best way would be to remove all empty tag manually via a batch job after the xml file is created by nav. but i am trying to avoid doing this. if this is at all possible to be configured in NAV xmlports.

    The schema, generated by NAV, defines all complex types as sequences.

    When importing a sequence, you can omit trailing emtpy tags, but you cannot do the same with the leading tags, even when they are empty and even when the minOccurs would allow it. You will also discover that you cannot shuffle the elements within the complex type. If you try to import such an xml, you will get an error claiming missing elements, even if the xml does contain the data. Your xml must contain all elements, in the defined order. Those that do not contain any value, not even empty, can be nilled, but must not be omitted.

    When exporting an xmlport, I am not aware of any regular way to trigger the nil attribute. NAV does not "know" NULL values, which would be the equivalent of nil or "missing". Maybe you can add it manually within the xmlport design... That should be tricky, since xmlport does not support arbitrary namespaces.
    The difference between theory and practice is smaller in theory than it is in practice.
  • jordi79jordi79 Member Posts: 274
    I have to pass the created xml into a codeunit to remove all the xmltags with null value Nd perform other types of text formatting stuff that xmlport does not support
Sign In or Register to comment.