how to avoid this error while transform empty tag in DataWeave mapping - solution

This is my source XML in this I have transform without affecting error for empty tag with my format.
Source XML
<Invoices>
<Invoice>
<invoice_no>819785</invoice_no>
<inv_status_code>S</inv_status_code>
<invoiceDate>2017-03-20</invoiceDate>
<total>208.7100</total>
</Invoice>
<Invoice>
</Invoice>
</Invoices>

Related

ODK Dynamic select from database, how to handle empty list

I have an ODK form that is configured to get a list of data from the database and use that list of data for the select.
Problem is that I am not able to display an error for when the query from the database returns an empty string, instead, ODK form crashes while loading. I have tried this,
<instance id="books">
<list>
<g:if test="${Book.list()}">
<g:each in="${Book.list()}" var="book">
<book>
<id>${book.id}</id>
<name>${book.name?.encodeAsHTML()}</name>
</book>
</g:each>
</g:if>
<g:else>
<book>
<id></id>
<name></name>
</book>
</g:else>
</list>
</instance>
which creates an xml with an empty id and empty name. This makes sure that the ODK doesn't crash when it loads.
But since I don't want the user the select an empty book option, I added a constraint in the bind nodeset section,
<bind nodeset="/form/book" type="string" required="true()" constraint=". != ''" jr:constraintMsg="Book must be not be empty"/>
So now when the user tries to get past the book selection section the ODK form doesn't allow it, but instead of throwing the constraint message that I supplied it throws this error
don't know xml value! perhaps selection was stored as index only and has not yet been linked up to a formdef?

In Filemaker, is it possible to import into Container fields from XML?

The XML FMPXMLRESULT grammar documentation states:
XML export does not support exporting container field data.
which seems to imply that it's possible to import (it does also specify that you can denote a field as type "CONTAINER" in the XML). However, I have found zero documentation as to how this might be done.
Is it possible? I get that there are ways of getting e.g. an image file into Filemaker after the fact, but can I just specify it in the XML beforehand, negating the need to have additional scripts or post-processing the import (not to mention something that works in Filemaker 11 or below)?
You can import file references, but not binary data. (And you'll have to specify the field as TEXT type in the XML file.) For example:
<?xml version="1.0" encoding="UTF-8"?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="01-25-2011" NAME="FileMaker"
VERSION="ProAdvanced 11.0v3" />
<DATABASE DATEFORMAT="M/d/yyyy" TIMEFORMAT="h:mm:ss a"
LAYOUT="" NAME="" RECORDS="" />
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" TYPE="TEXT" NAME="Path" />
</METADATA>
<RESULTSET FOUND="">
<ROW>
<COL>
<DATA>image:test.jpg</DATA>
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>
The path must be in FileMaker format; here I used a relative path to test.jpg in the same directory as the file (will only work for local files), but it can also be an absolute path, e.g.:
imagewin:/C:/Some/Path/test.jpg
Your best option is probably to import Base64-encoded data, then use the Base64Decode function to decode it.
importing images, preferably from http
I am not sure what exactly that means. If your XML contains a link to an image, then the only thing you can do with it is import the link as text. If you are using version 12 or higher, you can follow this with the Insert From URL script step (for each imported record).

cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")

Attempting to hit the Customers end point and the API keeps rejecting my request with this extremely nondescript error:
<ErrorCode>-3002</ErrorCode>
<ErrorDesc>cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")</ErrorDesc>
<DBErrorCode>01400</DBErrorCode>
Here is the sample XML:
<?xml version='1.0' encoding='utf-8' ?>
<Add RequestId='47e1633341s4521a24e269ad12ab3f6' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.intuit.com/sb/cdm/v2'>
<ExternalRealmId>111111111</ExternalRealmId>
<Object xsi:type='Customer'>
<TypeOf>Organization</TypeOf>
<Name>SampleCustomer</Name>
<Address>
<Line1>123 E. Fake St</Line1>
<Line2>Suite 1</Line2>
<City>Somewhere</City>
<Country>USA</Country>
<CountrySubDivisionCode>FL</CountrySubDivisionCode>
<PostalCode>12345</PostalCode>
<Default>true</Default>
<Tag>Billing</Tag>
</Address>
<Phone>
<DeviceType>LandLine</DeviceType>
<FreeFormNumber>123-456-4563</FreeFormNumber>
<Default>true</Default>
<Tag>Main</Tag>
</Phone>
<DBAName>Sample Customer</DBAName>
<AcctNum>51f2ce86134c03000a000155</AcctNum>
</Object>
</Add>
Any suggestions? These exceptions are super confusion. I found the one related to "ESB"."PHONE_API"."LABEL_NAME_MAP" was related to an empty phone number field. That isn't the case with this request.
You edited your post to reflect a correct tag, so this answer may no longer be relevant
My first guess would be that, per the documentation, the Address/Tag node allowable values are defined by the PhysicalAddressLabelType enum.
Tag - String - Tag (or label) that identifies the use of the address. The
values allowed are defined in the PhysicalAddressLabelType.
If you look at the allowable values, you'll see the only allowable values are:
Billing
Shipping
But you specified:
Office
Can you try specifying a valid value?
Likewise, you're specifying an invalid Tag for the Phone node as well. The allowable values are here:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/062_enumerations/telephonenumberlabeltype
But you've specified:
Main
Can you try specifying a valid value?

how to extract xml tag values from email body?

I know the process to extract the body from the email using MIME::PARSER, but in my mail i have xml data. whats is the process to extract xml tag values from the email body?
Body:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<TEST>
<test>test</test>
<test1>test1</test1>
</TEST>
Assuming the body actually consists of XML, just feed it into your XML parser of choice (XML::Twig seems popular these days or you could look at Task::Kensho's recommended XML modules) and use it as normal.

XML based template engine in Java?

Can somebody suggest me a template engine (preferably written in Java) that could generate any text that I like from given XML input?
StringTemplate, FreeMarker
How about XSLt? You may use JAXP to do the processing.
You can use XSLT, it is not restricted to generating only XML output. It is restricted to XML input. Use the xsl:output tag do define the type of output you will be generating.
E.g. to generate text output
<xsl:output method="text" encoding="UTF-8"/>
To generate XML output with indentation
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>