How to Skip duplicated field values in Datamapper Mule ESB - mule

I have a requirement like this, Under the root tag 'Features' multiple feature elements are present.I need to remove duplicates. I have loaded its corresponding xsd in both source and target. But was not sure how to remove duplicates. My xml is a complex one, but to understand, I made here as simple.
Source ( input xml)
<features>
......(other fields)...
<Datas>
<feature> 1</feature>
<feature> 2 </feature>
<feature> 1 </feature>
<feature> 3 </feature>
<feature> 3 </feature>
</Datas>
</features>
Target ( output xml)
<features>
....(other fields)....
<ItemDetails>
<feature> 1</feature>
<feature> 2 </feature>
<feature> 3 </feature>
</ItemDetails>
I was thinking, something need to do in For each element in DataMapper. But not sure how can be done or may be it is wrong
Please let me know if any short cut, crispy way to remove the duplicates. It will reduce my time in large.
Mule version: 3.5.1
Thanks in advance.

This cannot be accomplished with DataMapper, you need an ulterior XSLT transformer to remove duplicates, see the following stackoverflow question.

I have resolved the problem in this way.
First I used Datamapper. It will gives as response but with duplicates. Finally I used Simple XSLT as described in this link Removing duplicate elements with XSLT( It removes duplicates alone) and make copy of remaining transformed field as such ( I used XSLT v1 in the link)
Hope It might helps for those facing the problem like me.

Related

WiX: Feature/Condition behaving unexpectedly

I'm a novice WiX user, converting over several existing installations from a no longer maintained (.MSI-producing) commercial product.
As part of that I'm restructuring the original feature/component arrangements to take advantage of some of the new options WiX has opened up. One of these is adding Conditions at Feature rather than Component level, and as part of that I've tried specifying a conditional Feature like this (demo/test items throughout):
<Feature Id="Feature1" Title="Test Only" Level="0">
<Component Id="C1" Guid="*" Directory="SomeDir">
<File Id="File1" KeyPath="yes" Checksum="yes" Name="Test file.txt" Source="D:\xxx.dat" />
</Component>
<Condition Level="1"><![CDATA[INSTALLTYPE <> 1]]></Condition>
</Feature>
Where INSTALLTYPE is a Property defined at <Product> level and subsequently set to 0, 1 or 2 by the user via a RadioButtonGroup in the UI sequence.
Summarising what I've found after a day or so of trying different options and head-scratching:
With an initial Level=0, set to 1 by the condition (as in the sample above), the Feature is never installed.
With an initial Level=1, set to 0 by the condition, the Feature is installed when the condition is satisfied as long as an = test is used in the condition. If a INSTALLTYPE <> 1 is used, or Not (INSTALLTYPE = 1), the feature is never installed.
If a pre-defined Property (such as INSTALLLEVEL) is used in the test rather than my INSTALLTYPE, everything works correctly/as expected.
If equivalent tests are applied at Component, rather than Feature, level, everything works as expected for all Propertys and test operators.
Something seems to be going wrong with INSTALLTYPE but I can't for the life of me work out what. I've tried firing a VBScript custom action (MsgBox("INSTALLTYPE=" & Session.Property("INSTALLTYPE"))) in the Execute sequence to check the value of the Property, and as far as I can see this does display the value I'd expect it to have from the UI setting.
In principle I could get Features installing the way I want using the subset of settings I've found to work (e.g. INSTALLTYPE = 0 OR INSTALLTYPE = 2 rather than INSTALLTYPE <> 1), but my bafflement over apparently simple things not behaving as expected suggests I'm missing something fundamental...so I'm wary of just shrugging and applying workarounds.
If anyone has any thoughts on what I might be doing wrong with the items above, I'd be very happy to hear them!

Set File Name to Property

I have a Merge Module which installs a file. I would like to use a property passed to the Merge Module during MSI creation. Something like:
<Configuration Name='FileNameProperty'
Format='Text'
DefaultValue='[FileNameProperty]' />
<Substitution Table='CustomAction'
Row='SetFileName'
Column='Target'
Value='[=FileNameProperty]' />
<CustomAction Id='SetFileName'
Property='MYFILENAME'
Value='[MYFILENAME]' />
<InstallExecuteSequence>
<Custom Action='SetFileName'
Before='LaunchConditions'>1</Custom>
</InstallExecuteSequence>
...
<File Name="[MYFILENAME]"
Source="my-file.exe" />
Currently I am using a Custom Action, namely Type 51, which works when substituting property values for other element attributes, such as ServiceInstall DisplayName. However, in this instance the file is deployed as [MYFILENAME].
I've looked through the other Custom Actions provided by MSDN, but can't find anything that fits this situation. Any suggestions or idea if this is even possible?
My last ditch option is to include File elements for each variation of file name and select the desired file based off condition, but I would like to avoid that.
File names aren't formatted so properties can't be used. If you use multiple files, WiX's smart cabbing ensures the copies don't take up extra space in your cabinet.

Wix::heat, Is it possible to add child element under component element while harvesting?

Basically i want to add <Condition>0</Condition> element under the <Component>..</Component> element when i harvest a directory using heat.exe
I should look like below
<Component Id='JapaneseFlag' Guid='{4CB0C1EE-8370-4880-B172-CF1E9F7308F7}'>
<File Id='JaFlag' Source='.\ja.png'></File>
<Condition>INSTALLEDSWVERSION = "XYZ"</Condition>
</Component>
and i also want the conditional feature for the above component under the feature element, like
<Feature Id='JA_Flag' Title='Japanese Flag' Level='1'>
<Condition Level='0'>NOT (INSTALLEDSWVERSION = "XYZ")</Condition>
<ComponentRef Id='JapaneseFlag'/>
</Feature>
Is this possible using heat?
if not, So Is there any way to do this dynamically?
Any clue would help me to google further.
Yes, you can use xslt to transform the generated wxs file.
Check this for example.

WiX XmlConfig change values on multiple lines?

Related: WiX XmlFile setValue on multiple lines
I'd like to update attributes on multiple xml nodes with one statement using XmlConfig. Is there an equivalent to XmlFile - bulkSetValue ?
This will update the first instance.
<util:XmlConfig Id="ServerWCFCertClientSettings" File="[#APP_CONFIG]" On="install" PreserveModifiedDate="yes"
Action="create"
Node="value"
ElementPath="//configuration/system.serviceModel/client/endpoint/identity/certificateReference"
Name="findValue"
Value="[SELECTED_WCF_CERTIFICATE]"
Sequence="200" />
I could use XmlFile for this, but we're trying to standardize on XmlConfig for all operations.
#Doug Though it's a more than a year old post but just in case this helps someone: Setting a value XmlConfig

WiX: Define made in included file not avaible from wxs-fragment-file

I have a defines.wxi-file which contains some good definitions used in all my wxs-files.
When I attempt to reference the defined value from one of the <Fragment>-files I get Undefined preprocessor variable '$(var.IMAGE_FOLDER)' back in my face.
I guess there is something trivial I am missing here...
Any ideas?
Edit 19:th April.
Found that issue only occurs if reference from a Fragment-file.
Re-wrote sample to match that.
defines.wxi
<Include>
<?define IMAGE_FOLDER="Images" ?>
</Include>
some-Fragment.wxs
<Fragment>
<?Include defines.wxi ?>
<Component Id='c.Images' Guid=".." Directory='INSTALLDIR.Images' >
<File Id='f.sample.jpg' Source='$(var.IMAGE_FOLDER)sample.jpg' Name='sample.jpg' />
</Component>
Solved it.
Where it in the sample says:
<?Include defines.wxi ?>
it should be lower case...
<?include defines.wxi ?>
then it works like a charm!
/L
Ok, another try.
Do you reference anything in that <Fragment/> from the main <Product/> ? The contents of the fragment are visible to the rest of the code in case you reference anything from it. For instance, you can reference a component (<ComponentRef/>) or component group (<ComponentGroupRef/>). Once anything is referenced, the entire fragment is included.
Hope this helps.
In the text of the error message you provided it says "Undefined preprocessor variable '$(var.MAGE_FOLDER)'", not $(var.IMAGE_FOLDER) - the leading 'I' is missing. This made me think that you reference the same variable somewhere in the rest of your code, but misspelling it.
In this case, the candle.exe is absolutely right - it can find IMAGE_FOLDER, but can't find MAGE_FOLDER.
Hope this is the case and you'll fix it quickly. ;-)