Skip to main content
Solved

XMLTemplater: Adding XML attributes to Sub Templates "ports"

  • July 13, 2015
  • 2 replies
  • 33 views

Hi, 

 

 

I am successfully using the XMLTemplater/XMLFormater approach to write to a TEXTLINE writer.  My question is about adding attributes to the top level "port".  A configuration like this (PROJECT) reads in template files based on user parameters:

 

 

 

 

Using a template like this:

 

 

<Project name="{fme:get-attribute("fs_project_name")}" type="Asset">

 

    <AssignedTo>"{fme:get-attribute("fs_assigned_to")}</AssignedTo>

 

    <ScheduleDate>{fme:get-attribute("fs_schedule_date")}</ScheduleDate>

 

    <DueDate>{fme:get-attribute("fs_due_date")}</DueDate>

 

    <ComplianceDate>{fme:get-attribute("fs_compliance_date")}</ComplianceDate>

 

    <UploadStatus>InBasket</UploadStatus>

 

    <Location>

 

        <Geometry type="undefined"/>

 

        <OriginalGeometry type="undefined"/>

 

    </Location>

 

    <Attributes>

 

        <Attribute id = "InspectionType">Asset</Attribute>

 

    </Attributes>

 

</Project>

 

 

Results in this (You can see that the <Project> tag is repeated.

 

 

<Project>

 

<Project name="T00123456" type="Asset">

 

<AssignedTo>"204052230</AssignedTo>

 

<ScheduleDate>2015-07-08</ScheduleDate>

 

<DueDate>2015-07-08</DueDate>

 

<ComplianceDate>2015-07-08</ComplianceDate>

 

<UploadStatus>InBasket</UploadStatus>

 

<Location>

 

<Geometry type="undefined"></Geometry>

 

<OriginalGeometry type="undefined"></OriginalGeometry>

 

</Location>

 

<Attributes>

 

<Attribute id="InspectionType">Asset</Attribute>

 

</Attributes>

 

</Project>

 

</Project>

 

 

My work-around is to use a couple of StringReplacers to remove the superfluous tags but I was wondering if there is a more elegant way.

 

 

Thanks in advance.

Best answer by fmelizard

Hi,

 

I would check if the project tag exists in the root template. If that is the case try removing it.

 

Hope this helps.
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

fmelizard
Safer
Forum|alt.badge.img+21
  • Safer
  • Best Answer
  • July 14, 2015
Hi,

 

I would check if the project tag exists in the root template. If that is the case try removing it.

 

Hope this helps.

  • Author
  • July 14, 2015
I looked everywhere but the root template.  I was following an example from a tutorial and thought that the root XML needed to have references to the named sub-template ports using tags.  I know that these are refrences with {fme:process-features("")}.  The perils of cut-and-paste.

 

 

Thanks for pointing me the right direction.