XMLPort Attribute Names

NAVTechNAVTech Member Posts: 16
Another quick question:
I have created an XMLPort to export some data as an XML file. The schema that I am following repeats the names of the Attributes for a number of different tags. As a compensation for this, I have used some global variables as datasources (which all become populated correctly when I debug the process). However the file that results from this XMLPort has blank tags wherever these variables are used as the datasource

I suspect that it may not be possible to create an XMLPort using global variables and/or using the same attribute names across an XML file.

Has someone experienced this problem before? and if so, is there a workaround??

Many Thanx

Comments

  • DenSterDenSter Member Posts: 8,305
    You can put values in global variables all you want, but in the end they will have to be transferred to the actual elements and attributes. I don't know of course how your XMLPort is set up, but it should be possible to populate elements and attributes that way.

    You can have the same name for an attribute for more than one element. You can have an element called 'Customer', with an attribute 'Name', and another element called 'Vendor', also with an attribute called 'Name'. It is even technically possible to have the same name element when they are nested (it shouldn't be possible but some parsers don't cause exceptions when that happens), but that is not well formed XML.

    So you could have an attribute called Name under two elements, and as the source you will need to set the variables. Now it becomes your task to make sure that you populate those variables before the xml is exported.
  • NAVTechNAVTech Member Posts: 16
    I am new to XMLPorts and am a little lost. Denster, what do you mean by transferring to the elements and attributes?

    I am using the XML designer to fill out Tagnames, Element Types and Datasources (which works up until I enter an identical datasource name within the designer - then I get a variable is defined twice error).

    So I compensate and define global variables to hold the datasource value (assigning the value in the Export::OnBeforPassField trigger), thinking that this will work. But when I run the XMLPort all the tags which I defined with a datasource of a global variable, these show up as blank tags (tags with no values between them)

    I need to keep the tag names as they are (as they are that way in the schema that I need to follow). Has anyone had this issue before? Can anyone help?

    Thanks. :?
  • ara3nara3n Member Posts: 9,256
    NAVTech wrote:
    I am new to XMLPorts and am a little lost. Denster, what do you mean by transferring to the elements and attributes?

    I am using the XML designer to fill out Tagnames, Element Types and Datasources (which works up until I enter an identical datasource name within the designer - then I get a variable is defined twice error).

    So I compensate and define global variables to hold the datasource value (assigning the value in the Export::OnBeforPassField trigger), thinking that this will work. But when I run the XMLPort all the tags which I defined with a datasource of a global variable, these show up as blank tags (tags with no values between them)

    I need to keep the tag names as they are (as they are that way in the schema that I need to follow). Has anyone had this issue before? Can anyone help?

    Thanks. :?


    For variable defined twice error. Change the Datasource. So if you have two elements with same name NAV gives it the same name to the datasource. So remove <> and add a 1 or 2 at the end of the datasource.
    XMLPort are a little different in that you don't need global variable the datasource is created as variable if it sourcetype is Text
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.