Tibco BW XML parsing mapping Accumulation - tibco

Being new to Tibco BW development I have a scenario which may be easy for you experts to solve/suggest.
I have an XML
<FILES>
<FILEINFO>
<NAME>F1<NAME>
<DESC>D1<DESC>
</FILEINFO>
<FILEINFO>
<NAME>F2<NAME>
<DESC>D2<DESC>
</FILEINFO>
</FILES>
I want to convert/map/accumulate it into following format.
<ALLDATA>
<NAMES>
<NAME>F1</NAME>
<NAME>F2</NAME>
</NAMES>
<DESCRIPTIONS>
<DESCR>D1</DESCR>
<DESCR>D2</DESCR>
</DESCRIPTIONS>
</ALLDATA>
I tried to do what I could but to no avail. Could you please let me know how to do it . Best if you can send me a working BW process for the same so that I can understand it better.
Thanks for your help in Advance.
DMEHA

You can try this:
I hope this helps.

Related

Apache Nifi - move a top-level element into children (JSON/XML)

New to Apache Nifi and trying to process an XML that looks a bit like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<productCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<version>CHANNELS-VERSION-100</version>
<channels>
<channel>
<id>1</id>
<name>Super Channel 1</name>
</channel>
<channel>
<id>2</id>
<name>Super Channel 2</name>
</channel>
</channels>
</productCatalog>
What I want, is to read the "version" element, then include it in the "channel" children when I process them further down the pipeline e.g. to produce something like this (in XML or JSON):
<processedChannel>
<catalogVersion>CHANNELS-VERSION-100</catalogVersion>
<id>2</id>
<name>Super Channel 2</name>
</processedChannel>
I've tried various permutations of XQuery, XMLSplit, UpdateAttribute to put the version in a flow attribute (not content),etc, but I cannot seem to make the "version" available for all the "channels" downstream. I can either get a flow that only contains the version, or I can get the channels, but I cannot find a way to combine them.
This seems like it should be easy, but I cannot find an obvious solution.
My real use case has a really big XML file, so I am trying to avoid loading it all in one go - I split it as early as possible so I can stream the children more easily. That's why I want to put the version onto the children if possible.
Any help gratefully received!
ForkRecord should do what you want. From your desired output I think you'll want "extract" as the mode, but you could try both and see what you get for output. ForkRecord and the XML Reader/Writer are available as of NiFi 1.7.0.
#mattyb: Thanks for your suggestions. ForkRecord looks really interesting, but doesn't fit with my current use case because it needs a schema. But the EvaluateXPath and EvaluateXQuery options both seem to work now, even though I spent hours playing around with these previously.
Here's my flow now:
ListFile --> FetchFile --> Evaluate XPath (to get version as flow-file attribute) --> SplitXml --> etc - and now I have the version in my flow-file attributes for the downstream processing, which was what was wanted.
Not sure why it didn't work before, but thanks for prompting me to look at it again.

parsing a XML document in ruby

I am new to ruby and XML. I have been given an XML file and asked to do some data manipulation in that.
For ex. consider the below XML file.
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to> Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
They are asking me to extract the the string which are inside the tags for ex "Tove", "Jani" and do some manipulation(for ex replacing "tove" with "john") on it and rewrite the data to same xml document.
I know ruby has a lot of gems and utilities and there must be a good utility to do it. If someone has any idea about any utility to do this work easily then just let me know.
And if there is no utility then if someone could give me some idea on how to proceed with it then it would be good.
One way is to use REXML that comes as part of the standard library.
Another way is to use Nokogiri (I would recommend using this).
Here are some good tutorials that will definitely help you:
http://ruby.bastardsbook.com/chapters/html-parsing/
https://blog.engineyard.com/2010/getting-started-with-nokogiri/

How can i implement LDA using apache mahout?

have a data set like as bellow in CSV format.
FileName,Topic,Tag,Frequency
File-1,Topic -1,Tag-1,10
File-2,Topic -2,Tag-2,10
File-3,Topic -3,Tag-2,10
File-4,Topic -4,Tag-4,10
File-5,Topic -1,Tag-5,10
File-6,Topic -3,Tag-1,10
File-7,Topic -1,Tag-1,10
I need to find a correlation between the tags using mahout LDA(Latent Dirichlet allocation) algorithm. Can anybody please help me to find how to do that using Apache Mahout.
I am also confused that in exactly what input format mahout wants ?
It will be helpful if somebody please share some good stuff for mahout beginner
I might be late in answering. But, Mahout no longer supports LDA for versions above 0.6 . One has to use Cvb instead of lda to accomplish the task of running topic models.
The following links can help You:
https://mahout.apache.org/users/clustering/lda-commandline.html
https://mahout.apache.org/users/clustering/latent-dirichlet-allocation.html

How do I add a image to a Freebase Topic ?

I am trying to add a image to my freebase topic, How can i do this ? I have heard that it is no longer possible.
Thanks
You're correct; this is no longer possible. See this post by Brendan Neutra, one of the Freebase team at Google.

Need Information on XslCompiledTransform in Plain English

Does anybody have any links that explain proper implementation of the XSLCompiledTransform? Thanks
http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx

Resources