Conditionally, Converting of JSON to XML using MuleSoft - mule

I have a simple conversion of JSON to XML using MuleSoft. In "Transform Message" component, I provided JSON Schema as Input and XML Schema as Output. When I run the app, the conversion happens if the file matches with both schema but it generates an empty XML file if it doesn't match.
I want below conditions:
1) If the file matches with schema, the converted output file should be sent to converted folder and the original file should move to Success folder.
2) If the file doesn't match with schema, the original file should move to the Failure folder instead of conversion.
Hope, I explained it comprehensively as I am new to MuleSoft. Here is a sample diagram which may simplify my requirement. Provide me with a new one if I badly designed the process.

First thing you need to create a flowVar that will hold your original payload.
When your doing your evaluation, if its XML then use a simple XPath expression like //elementName[not(node())]
Lastly, on your success use scatter-gather for multi-threading write. Pull your original payload from flowVar and write to Success and Write your regular payload to your Converted folder

Related

No output is generated when using reference data in Azure Stream Analytics

I have written a simple query and join it with a json reference data. I can see correct results when testing the query in "Test results" tab. However, no output is generated when starting the job.
I have confirmed that the output blob is created when no join with reference data is used in the query.
Any help is appreciated. The sample reference json follows:
[
{
"DeviceId":"DEV-021",
"Brand":"brand01",
"Model":"model01"
}
]
Use flat json structure instead of array. It should give you the output
Check the path you specified in the reference data, maybe it is not correct or you did not specify the file name. Does it contain something like {date}/{time}/filename.json?
If you forget to specify the file name, it does not work as well.
And if you are testing the job, usually you specify the file manually and that is why your query works.

How do you differentiate between QVD source files and target files when reading a QVW's XML MetaData?

I am currently trying to find an alternative to the Governance Dashboard that Rob Wunderlich (Qlik founder) created, since I am currently encountering errors when using it.
How do you differentiate between a data source (QVD, aka source) that is used by a QVW or a data file (QVD, aka target) that is generated by that QVW?
QVW:
LOAD
Lower(Discriminator) AS DataFile.Filepath
FROM C:\Sample_Transform_file.qvw (xmlSimple, Table is[DocumentSummary/LineageInfo])
Below is an example of what I found when parsing through the XML Metadata
(discriminator subtag within the lineageinfo tag) for one specific Transform QVW.
Sample Table Output
Are targets just identified by this?
STORE - [qvdName.qvd](qvd)
From what I have found, That appears to be the case, to a degree.
All of our QVW files that output a QVD utilize DIRECTORY statements rather than either hard-coded file location paths or variablized paths. Hence why all of the Targets are getting displayed as "STORE - qvdname.qvd", instead of displaying the filepath. In a sense, that is a flaw on QlikView's part, regarding its Governance Dashboard (or at the very least, they don't seem to recommend variablizing those paths as a standard in order to avoid breaking the lineage).

How to Read specific column value from .text file in wso2 esb

I am starting to work with wso2 esb from few days back.
I need to read particular column value and set into property in wso2 esb.
My .txt file contains following values:
**SNO|FIRSTNAME|LASTNAME|EMAIL|PHONE|ADDRESS|SELLING_DEALER**
**51|christopher|chris|cpko78#gmail.com|0406-755909|US|MacGgor**
I need to read email and phone column value from this .txt file and set into property which can be used for further operations like EmailValidation or PhoneValidation.
Can anyone help me out to fine solution?
If you use ESB one option would be to do a smooks transformation into xml and then read the values from the generated xml. Just keep in mind that if you need the original csv content later in your proxy/api, you need to store the original content and restore it after you've read the needed values (using enrich mediator).
https://docs.wso2.com/display/ESB481/Smooks+Mediator
Another option would be to do a xslt transformation into xml (similar to smooks).
https://docs.wso2.com/display/ESB481/XSLT+Mediator
The last option I could think of is using the script mediator and extract the values using JavaScript, Groovy, or Ruby.
https://docs.wso2.com/display/ESB481/Script+Mediator
If you use EI then you also might expose your csv as a data service.
https://docs.wso2.com/display/DSS351/Exposing+CSV+Data+as+a+Data+Service
Hope that helps.

No data output when extracting part of filename in U-SQL

When I do an extract from multiple files and include part of the filename in the fields list and in the FROM clause (e.g. FROM "/input/filename-{filedate:*}.nc"), the resulting output file only contains a header row. If I remove "filedate" from the fields list and the FROM clause, I get the correct output.
I noticed in the job graph that when including "filedate", an "Empty Input" and an "Extract Cross" step is added before the "PodAggregate" step, and in the "Extract Cross" no data is written. What is this step?
Also, if I run the original extract including "filedate" locally, I get the correct output, so it's only in ADLA this error occurs.
I use a custom extractor and I don't know if this has anything to do with it. I haven't tested with a built-in extractor.
We released the new "fast file set" option by default. Unfortunately, it introduced a regression for some plans. Until we fix it, please add the following statement to your script:
SET ##InternalDebug = "FileSetV2:off";
Our apologies for any inconvenience this may have caused.

mapping a string containing xml in BizTalk

I have an xml document with a node that may optionally contain a string of escaped xml. I'd like to be able to transform that content using xsl in a BizTalk map. Any suggestion how?
I've tried:
msxsl:node-set(string). This creates a nameless single node with no content.
The document() function using a url prefix of 'data:text/xml' as suggested by helderdarocha here.
for-each selecting the text() of the node containing the string
using xpath() in an orchestration to extract the string then make a multipart message. It won't let me use an xmlDocument message as one of the messages in a multipart message transform.
Do I have to use a C# helper assembly to accomplish this?
I have tackled a similar issue in a project, where I have a series of 2 mappings (both native xslt).
The first map will map your input document to an intermediate format. This format has one "any" node (instead of the escaped XML node), where eventually, I put in the unescaped XML. I unescape using a C# extension object.
The C# code could just be a wrapper for System.Web.HttpUtility.HtmlDecode()
In the second mapping, you can map using plain XPath.
Example Input message:
<root>
<someNode>blabla</someNode>
<any><root2><myValue>escapedXml</myValue></root2></any>
</root>
Intermediate format:
<root>
<someNode>blabla</someNode>
<any>
<root2>
<myValue>escapedXml</myValue>
</root2>
</any>
</root>
In your second mapping, you could use XPaths like /root/any/root2/myValue/text() without any issue.
Important Note:
If you need to do XSD validation against this intermediate format, this is a good way to do this as well. You would just need to create the appropriate intermediate XSD according to your needs. In my case this was needed, so I had to validate this unescaped format using a receive pipeline execution in an orchestration.