How to Skip a field/component/sub-component without xmltag in Smooks - smooks

I want to process a baplie edi and however i don't need all the values coming in the EDI file. in such a case is there a way to skip a field/component/sub-component without the xmltag being displayed in the output unnecessarily.
Example,
I just need the sender identification and receipient indentification alone.
Thanks in advance.

I'm not totally familiar with that message format, but you can tell the Smooks EDI reader (via the EDI mapping model) to "truncate" fields, segments etc. (see the docs). So, what you ask should be possible if the data is at the end (I think).

Related

Is there a way to do string replacement/substitution in sql?

I have some records in a CMS that include HTML fragments with custom tags for a widget tool. The maker of the CMS has apparently updated their CMS without providing proper data conversion. Their widgets use keys for layout based on screen width such as block_lg, block_md, block_sm. The problem kicks in with the fact they used to have a block_xs and they have now shifted them all -- dropping the block_xs and instead placing a block_xl on the other end.
We don't really use these things, but their widget configurations do. What this means for us is the values for each key are identical. The problem occurs when the updated CMS code is looking for the 'block_xl' in any widget definition tags, it can't find it and errors out.
What I'm thinking then is that the new code will appear to 'ignore' the block_xs due to how it reads the tags. (and similarly, the old code will ignore block_xl) Since the values for each are identical, I need to basically read any widget definition and add a block_xl value to it matching the value of [any one of] the other width parameters.
Since the best place order-wise would be 'before' the block_lg value, it's probably easiest to do it as follows:
Replace any thing matching posix style regex matching /block_lg(="\d+,\d+")/ with: block_xl="$1" block_lg="$1"
Or whatever the equivalent of that would be.
Example of an existing CMS block with multiple widget definitions:
<div>{{widget type="CleverSoft\CleverBlock\Block\Widget"
widget_title="The Album" classes="highlight-bottom modish greenfont font52 fontlight"
enable_fullwidth="0" block_ids="127" lazyload="0"
block_lg="127,12," block_md="127,12," block_sm="127,12," block_xs="127,12,"
template="widget/block.phtml" scroll="0" background_overlay_o="0"}}</div>
<!-- Image Block -->
<div>{{widget type="CleverSoft\CleverBlock\Block\Widget"
widget_title="What’s Your Favorite Cover Style?"
classes="zoo-widget-style2 modish grey font26 fontlight"
enable_fullwidth="0" block_ids="126" lazyload="0"
block_lg="126,12," block_md="126,12," block_sm="126,12," block_xs="126,12,"
template="widget/block.phtml" scroll="0" background_overlay_o="0"}}</div>
What I would prefer to end up with from the above (adding block_xl):
<div>{{widget type="CleverSoft\CleverBlock\Block\Widget"
widget_title="The Album" classes="highlight-bottom modish greenfont font52 fontlight"
enable_fullwidth="0" block_ids="127" lazyload="0"
block_xl="127,12," block_lg="127,12," block_md="127,12," block_sm="127,12," block_xs="127,12,"
template="widget/block.phtml" scroll="0" background_overlay_o="0"}}</div>
<!-- Image Block -->
<div>{{widget type="CleverSoft\CleverBlock\Block\Widget"
widget_title="What’s Your Favorite Cover Style?"
classes="zoo-widget-style2 modish grey font26 fontlight"
enable_fullwidth="0" block_ids="126" lazyload="0"
block_xl="126,12," block_lg="126,12," block_md="126,12," block_sm="126,12," block_xs="126,12,"
template="widget/block.phtml" scroll="0" background_overlay_o="0"}}</div>
I know how to do it in php and if necessary, I will just replace it on my local DB and write an sql script to update the modified records, but the html blocks can be kind of big in some cases. It would be preferable, if it is possible, to make the substitutions right in the SQL but I'm not sure how to do it or if it's even possible to do.
And yes, there can be more than one instance of a widget in any given cms page or block. (i.e. there may be a need for more than one such substitutions with different local 'values' assigned to the block_lg)
If anyone can help me do it in SQL, it would be greatly appreciated.
for reference, the tables effected are called cms_page and cms_block, the name of the row in both cases is content
SW

Call a data from a database in a .ini file

I have a little problem about my .ini file. I am using LabVIEW to pilot a Power Supply GPD-2303. And I have to configure the Voltage and the Current searched for each cards. These datas are in a Database but I have only a read access on it.
Voltage, Name, AlphaNumCode... Are not a problem because it will probably never change so my code is looking like:
[AlphaNumCode]
VSET_1=VALUE
VSET_2=VALUE
CSET_1=VALUE
CSET_2=VALUE
Assembly_PN=VALUE
That's to set Voltage, Current at the start of the execution on LabVIEW and give an Assembly PN "IF KQG then AssemblyPN= 1633".
That's the situation. The problem is there:
[Assembly PN]
CURRENT1_PROG_SEARCHED=VALUE
CURRENT2_PROG_SEARCHED=VALUE
CURRENT1_BLANK_SEARCHED=VALUE
CURRENT2_BLANK_SEARCHED=VALUE
I want to transform it, because if this value is not a fix value. I am looking for Something like:
[Assembly PN]
CURRENT1_PROG_SEARCHED="VALUE IN COLON W, LINE X"
CURRENT1_PROG_SEARCHED="VALUE IN COLON W, LINE X"
CURRENT2_PROG_SEARCHED="VALUE IN COLON X, LINE X"
CURRENT1_BLANK_SEARCHED="VALUE IN COLON Y, LINE X"
CURRENT2_BLANK_SEARCHED="VALUE IN COLON Z, LINE X"
I have found: https://support.microsoft.com/en-us/kb/149090
But it show how to interact with the colon but not with a specific case. Is there a command?
That's the last thing I have to do in my Internship to end this project and I do not like let things unfinished.
Hope someone can help me or give me documents to learn how to do it, it will be great :)
Edit:
Yes, this article show how to access data by a text file, and the text file is linked to the data in the database, I was thinking that could work.
I am clearly new about database so I am sorry about the lack of knowledge I will try to do my best, but using SQL server and System DSN to Access it in LabVIEW.
The ini File is read in a LabVIEW Program
By"COLON" I mean "COLUMN
Edit:
I send you my Sub VI and a picture of my code, that's what I want. still having 2 days to end it so I hope you can read me guys!
[1630]LINE=WHERE (OC=1630);
[1631]LINE=WHERE (OC=1631);
[1632]LINE=WHERE (OC=1632);
[1633]LINE=WHERE (OC=1633);
[1635]LINE=WHERE (OC=1635);
LabVIEW Picture of the Sub VI 25/07/16 using DB Select Tool Kit
Best regards,
Robin.
I have found a solution, in fact I am using a .ini file to send a condition:
Just to know: (OC = Assembly Number)
In my .ini I have:
[1633]
OC=WHERE(OC=1633);
Then I send it to the condition in DB Select Tool Kit and I enter the column / table where is the data I am looking for.
Then if a new card need to be test they just need to make a new line in the .ini file:
[XXXX]
OC=WHERE(OC=XXXX);
Thanks for your help that problem is resolve, I hope it can help someone that want to make communication between LabVIEW / .ini / Database
Best regards,
Robin

Avoid duplicates in the destination schema

I have a little problem. I want to map every detail line to one OrderInfo. The destination schema can not have any duplicate OrderInfo. All the detail lines should be in the destination orderInfo, but the SuppliersOrderNo and BuyersOrderNo should not be twice.
Any ideas how to do this, is it possible to use XSL or inline script?
<inv:OrderInfo>
<inv:SuppliersOrderNo>123456</inv:SuppliersOrderNo>
<inv:BuyersOrderNo>6789</inv:BuyersOrderNo>
<inv:DetailLines>
<inv:DetailLine>
<inv:InvoiceDetailLineNo>1</inv:InvoiceDetailLineNo>
<inv:Item>
<inv:SuppliersArticleNo>article2</inv:SuppliersArticleNo>
<inv:SuppliersDescription>BestArticle</inv:SuppliersDescription>
</inv:Item>
</inv:DetailLine>
<inv:DetailLine>
<inv:InvoiceDetailLineNo>2</inv:InvoiceDetailLineNo>
<inv:Item>
<inv:SuppliersArticleNo>article3</inv:SuppliersArticleNo>
<inv:SuppliersDescription>AlmostBestArticle</inv:SuppliersDescription>
</inv:Item>
</inv:DetailLine>
</inv:DetailLines>
</inv:OrderInfo>
<inv:OrderInfo>
<inv:SuppliersOrderNo>123456</inv:SuppliersOrderNo>
<inv:BuyersOrderNo>6789</inv:BuyersOrderNo>
<inv:DetailLines>
<inv:DetailLine>
<inv:InvoiceDetailLineNo>1</inv:InvoiceDetailLineNo>
<inv:Item>
<inv:SuppliersArticleNo>article1337</inv:SuppliersArticleNo>
<inv:SuppliersDescription>WOW</inv:SuppliersDescription>
</inv:Item>
</inv:DetailLine>
</inv:DetailLines>
</inv:OrderInfo>
If you want to do this purely in XSLT, you'll have to use Muenchian gruoping. I wrote a blog that links to some other blogs on how to do this in BizTalk a little while back: https://blog.tallan.com/2014/12/09/muenchian-grouping-in-biztalk-while-keeping-mapper-functionality/
To summarize the blog: if you pursue this, you'll need a map that's completely custom XSLT somewhere, but you could put it into a custom pipeline component if you still want to be able to use "regular" maps functionality without any other caveats (in my blog I describe a method of doing that in a pipeline component so that a "regular" BizTalk map can still be used on the preprocessed output). There are lots of resources on Muenchian grouping out there (including on StackOverflow), so I'm not rehashing all of that in this answer.
You could also try to serialize the message in a C# component and use some LINQ methods to group/sort/order/etc, or if you're inserting the content into SQL at some point you could do it in SQL (which would be able to handle this kind of task more naturally).

How to stop QSettings altering the order of key=value pairs in setting file?

In my program I have a Microsoft's INI style settings/configuration file that is created, edited and stored using the convenient QSettings class but the user may manually edit this file using the program itself, or any text editor she desires like gedit or vim. The order in which key=value pairs appear is important. The problem is whenever I try to store the changes at shutdown time, the order of key=value pairs change to a random order and it seems impossible to stop QSettings from changing it. For clarification here's a sample of a configuration file:
[AlarmGroup1]
DateTimeNotInitialized=1
DateTimeStampError=2
ParametersMissingOrInconsistent=3
NotInitialized=4
FlashMemoryFatalError=5
NotIdentified=6
which changes to:
[AlarmGroup1]
ParametersMissingOrInconsistent=3
DateTimeNotInitialized=1
DateTimeStampError=2
NotInitialized=4
FlashMemoryFatalError=5
NotIdentified=6
Is it possible to avoid the change of order? Why is Qsettings behaving like this?
QSettings behaves like this because the problem it was designed to solve was saving/retrieving single key/value pairs, not ordered lists of pairs.
To solve this you will need to either :
Remove the requirement for a specific order from you program
Write your own equivalent of QSettings
Write a "custom storage format provider" to pass into QSettings http://doc.qt.io/qt-5/qsettings.html#registerFormat

Chameleon: Why is a repeating comment truncated?

I'm having trouble with the transformation of an HL7 message. Its got an NTE segment with repeating fields of type string.
ex:
MSH|^~\&|HOST||TD-SYN||201207031000||ORU^R01|0017|P|2.3
PID|1||0001|
NTE|||Comment 1~Comment 2~Comment3
What happens after a graphical transformation is, NTE just takes Comment 1 and the rest of the repeating comments are ignored.
MSH|^~\&|HOST||TD-SYN||201207031000||ORU^R01|0017|P|2.3
PID|1||0001|
NTE|||Comment 1|
I tried setting the "Repeats" field of NTE segment's grammar to 10 but doesn't make a difference. Also, no script is manipulating that field of NTE, so I have no idea why it truncates it that way. Can someone tell me what's going on?
Glad you found it. Just as a general help, use sometimes the HAPI TestPanel to convert into XML, then you see very well how to loop over your HL7 elements. You then also know if you're using a correct HL7 structure.
In your example on the 3rd element in NTE <NTE.3>:
<?xml version="1.0" encoding="UTF-8"?>
<ORU_R01 xmlns="urn:hl7-org:v2xml">
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>HOST</HD.1>
</MSH.3>
<MSH.5>
<HD.1>TD-SYN</HD.1>
</MSH.5>
<MSH.7>
<TS.1>201207031000</TS.1>
</MSH.7>
<MSH.9>
<CM_MSG.1>ORU</CM_MSG.1>
<CM_MSG.2>R01</CM_MSG.2>
</MSH.9>
<MSH.10>0017</MSH.10>
<MSH.11>
<PT.1>P</PT.1>
</MSH.11>
<MSH.12>2.3</MSH.12>
</MSH>
<ORU_R01.RESPONSE>
<ORU_R01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.3>
<CX.1>0001</CX.1>
</PID.3>
</PID>
<NTE>
<NTE.3>Comment 1</NTE.3>
<NTE.3>Comment 2</NTE.3>
<NTE.3>Comment3</NTE.3>
</NTE>
</ORU_R01.PATIENT>
</ORU_R01.RESPONSE>
</ORU_R01>
I just found the answer from its documentation. It isn't actually truncated.
The default value of "value" is the first element in the repeatable field. Thus,
all I had to do is to access the repeating fields via field.repeat_field(index).value. :)