Nav XSD Paser patch for XMLPort generation

If you plan to work arround an huge xml file import/export and help yourself with the standard XML schema viewer, you should know about the useful “Generate XMLport” function :

XML Schema Viewer

Two problem I’ve been hurted with this :

– With repeating node name a number is added surrounded with < >, the variable can’t be in xmlport code
– MinOccurs columns is not propagate in the  MinOccur proprerty in xmlport nodes and cause error when importing file

To patch this go to codeunit 9610 called “XSD Parser” and search for “CreateXMLPortFile” function.

Scroll down a little until seeing something like : File.WRITE(‘{ [%1];%2;%3;%4;Text }’);

Remove the < > in text “VariableName=<%1%2>”

Copy paste this code just before the line “IF TempsXMLSchemaElement.COUNT = 0” :


IF MinOccurs = 0 THEN BEGIN //>> MinOccurs Patch
  IF TempXMLSchemaElement.COUNT = 0 THEN BEGIN
    File.WRITE(STRSUBSTNO(' { [%1];%2;%3;%4;Text ;',CREATEGUID,IndentationText,NodeNameText,ElementTypeText, (MinOccurs=0) ));
    File.WRITE(' MinOccurs=Zero }');
    File.WRITE(STRSUBSTNO(' { [%1];%2;%3;%4;Text ;',CREATEGUID,IndentationText,NodeNameText,ElementTypeText));
    File.WRITE(' MinOccurs=Zero;');
    File.WRITE(STRSUBSTNO(' VariableName=%1%2 }',
    "Node Name",TempXMLSchemaElement.COUNT));
END ELSE BEGIN//<< MinOccurs Patch

// Standard Code here



Leave a Reply

Your email address will not be published. Required fields are marked *