use of "if" in XML Write task
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
3 posts
Page 1 of 1
I'm using the XML Write task to generate an xml document from a rowset retrieved from a database query. There are elements that I want to appear in my output only if certain conditions are met. I would like to use an "if" inside the xml write prior to generating the element, but it seems to operate differently when inside the xml write than under normal project flow. Namely, it has a "test" attribute as opposed to the usual "condition" attribute and for the life of me I can't figure out what it wants in that test attribute. For example, my code goes something like this:
[8003 - xmlWrite] Invalid value '${ResultSet[Direct_Flag] == 'true'}' for attribute 'test' in element 'if'
here's the code:
Thanks!
Sean
Code: Select all
I would like to have the element "directFlag" only appear in the output if its value is "true". When I try adding that I get an error: <xmlWrite outputFile="${system.job.workspace}/output.xml" defaultTrim="right" outputFileVariable="OutputFile" version="1.0">
<header><?xml version="1.0" encoding="UTF-8" ?></header>
<element name="vendors">
<attribute name="xmlns" value="http://www.stryker.com/party" />
<forEach inputRowSetVariable="${ResultSet}">
<element name="vendor">
<element name="name" value="${ResultSet[Supplier_Name]}" />
<element name="directFlag" value="${ResultSet[Direct_Flag]}" />
<element name="activeStatus" value="${ResultSet[Active_Status_MW]}" />
</element>
</forEach>
</element>
</xmlWrite>
[8003 - xmlWrite] Invalid value '${ResultSet[Direct_Flag] == 'true'}' for attribute 'test' in element 'if'
here's the code:
Code: Select all
I've tried lots of different values for the test clause but nothing seems to work, including simply entering "${true}". Can someone explain how this is used? <xmlWrite outputFile="${system.job.workspace}/output.xml" defaultTrim="right" outputFileVariable="OutputFile" version="1.0">
<header><?xml version="1.0" encoding="UTF-8" ?></header>
<element name="vendors">
<attribute name="xmlns" value="http://www.stryker.com/party" />
<forEach inputRowSetVariable="${ResultSet}">
<element name="vendor">
<element name="name" value="${ResultSet[Supplier_Name]}" />
<if test="${ResultSet[Direct_Flag] == 'true'}">
<element name="directFlag" value="${ResultSet[Direct_Flag]}" />
</if>
<element name="activeStatus" value="${ResultSet[Active_Status_MW]}" />
</element>
</forEach>
</element>
</xmlWrite>
Thanks!
Sean
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
Sean,
The XML If Condition was originally designed for Header/Detail relationships. Like the following:
The XML If Condition was originally designed for Header/Detail relationships. Like the following:
Code: Select all
Conditional Element statements are being considered for a future release.<forEach inputRowSetVariable="${details}">
<if test="${details["TDPON"]} eq ${headers["THPON"]}">
<element name="DocShpLineItem">
<attribute name="ContainerQuantity" value="${details["TDCONQTY"]}" />
<attribute name="CommodityCode" value="${details["TDCOMCDE"]}" />
<attribute name="SKUNumber" value="${details["TDITM"]}" />
<attribute name="Description" value="${details["TDDES"]}" />
</element>
</if>
</forEach>
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
3 posts
Page 1 of 1