with vimgrep - or other vim possibility - how can i get groups of data out of a file? - vim

I'm trying to do a vimgrep on a file in order to get only two attributs with their values out of the xml file.
so far i can get the complete lines and i'd like with the help of groups to have a better display.
:vimgrep key= % | copen
^ I'd like to add to this command the grouping possibility with "( )" ....but without success for the moment.
i'd appreciate your help in order to have a result as explained in the "result expected"
part of the file that I'm working with :
<policy name="Menu_Controls" class="User" displayName="$(string.Menu_Controls)" explainText="$(string.IE_ExplainMenu_Controls)" presentation="$(presentation.Menu_Controls)" key="Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\AllowedControls">
<parentCategory ref="AdminApproved" />
<supportedOn ref="SUPPORTED_IE5" />
<elements>
<boolean id="MCSiMenu" valueName="{275E2FE0-7486-11D0-89D6-00A0C90C9B67}">
<trueValue>
<decimal value="0" />
</trueValue>
<falseValue>
<decimal value="1" />
</falseValue>
</boolean>
<boolean id="PopupMenu_Object" valueName="{7823A620-9DD9-11CF-A662-00AA00C066D2}">
<trueValue>
<decimal value="0" />
</trueValue>
<falseValue>
<decimal value="1" />
</falseValue>
</boolean>
<boolean id="Ikonic_Control" valueName="{F5131C24-E56D-11CF-B78A-444553540000}">
<trueValue>
<decimal value="0" />
</trueValue>
<falseValue>
<decimal value="1" />
</falseValue>
</boolean>
</elements>
</policy>
<policy name="Microsoft_Agent" class="User" displayName="$(string.Microsoft_Agent)" explainText="$(string.IE_Explain_Microsoft_Agent)" presentation="$(presentation.Microsoft_Agent)" key="Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\AllowedControls">
<parentCategory ref="AdminApproved" />
<supportedOn ref="SUPPORTED_IE5" />
<elements>
<boolean id="Microsoft_Agent_Control" valueName="{D45FD31B-5C6E-11D1-9EC1-00C04FD7081F}">
<trueValue>
<decimal value="0" />
</trueValue>
<falseValue>
<decimal value="1" />
</falseValue>
</boolean>
</elements>
</policy>
my expected result :
name="Menu_Controls" key="Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\AllowedControls"
name="Microsoft_Agent" key="Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\AllowedControls"
thanks in advance for your help.
toshi

two cmds could do it:
v/<policy /d
then
%s/.* \(name="[^"]*"\).*\(key="[^"]*"\).*/\1 \2/g

My ExtractMatches plugin provides a :YankMatches command, with which you can extract the matches and put them into a scratch buffer. As a one-liner:
:execute 'YankMatches \<\%(name\|key\)="[^"]*"' | new | put!
Result:
name="Menu_Controls"
key="Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\AllowedControls"
name="Microsoft_Agent"
key="Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\AllowedControls"

If you find :vimgrep and the quickfix list really helpful, you can use the editqf.vim plugin to make the quickfix list of your grep results editable, and then use e.g. a variation of the :%s command given in #Kent's answer to strip off the extraneous stuff.

Related

find xml-nodes by tag with wildcard

I am trying to find any nodes in a xml whos tags start with a certain pattern.
<data>
<general>
<va value="400" /> <!--looking for this "v-tag"-->
<vb value="42" /> <!-- and this one-->
<y value="43" />
</general>
<special>
<va value="100" />
</special>
</data>
I cannot put together the xpath expression. Something like this
xyz = lxml.etree.parse( ... )
vees = xyz.xpath("general/[tag='v*']")
I would like to have vees beeing
vees
Out[64]: [<Element va at 0x....>, <Element vb at 0x...>]
Try changing:
vees = xyz.xpath("general/[tag='v*']")
to
doc.xpath('//general//*[starts-with(name(),"v")]')
and see if it works.

SCXML notation of a target set

How can I define a "legal state configuration" according to https://www.w3.org/TR/scxml/#LegalStateConfigurations. I want to specify a target set (!), not a single target. Target sets can be defined inside the initial attribute of the <scxml> and <state> elements, as well as a target attribute of <transition> elements. But I can't seem to find any example of the notation of more than one state inside the above-mentioned attributes. Do they have to be space-separated? Or array notation according to JavaScript? Or object notation? Or comma-separated?
Thanks for any hints.
But anyway I'd like to know, what I have missed in the standard, to be sure to be interpreter-independent.
Here's a little testcode:
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
<initial>
<transition target="State_3_2 State_4_2" />
</initial>
<parallel id="Parallel_1">
<history id="hist" type="deep">
<transition target="State_1_2 State_2_2" />
</history>
<state id="State_1">
<state id="State_1_1" />
<state id="State_1_2" />
</state>
<state id="State_2">
<state id="State_2_1" />
<state id="State_2_2" />
</state>
</parallel>
<parallel id="Parallel_2">
<transition target="hist" event="switch_hist" />
<state id="State_3">
<state id="State_3_1" />
<state id="State_3_2" />
</state>
<state id="State_4">
<state id="State_4_1" />
<state id="State_4_2" />
</state>
</parallel>
</scxml>
To test: on entry, the states State_3_2 and State_4_2 must be active (initial element executed correctly), after event switch_hist, states State_1_2 and State_2_2 must be active (transitionattribute executed correctly).
If somebody has an interpreter all set other than SCION, could You test this there?
Also the alternative syntax with the first 4 lines replaced by
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="State_3_2 State_4_2">
Thank You.
It is space-separated. You can see an example of this in the SCXML test test suite. For example line 9 of test364.
Hope this helps. Thanks.

spring integration xpath namespace issue

I am trying to use an an xpath expression, in order to read requestId field in the xml file given below. however, this expression results in no matches. When I try to enclose the field names with single quotes, it results in a compilation error. I even tried using local-name, instead of name, in the xpath expression. I need to be able to get the value of requestId field as shown.
<int-file:outbound-channel-adapter
id="file" mode="APPEND" charset="UTF-8"
directory="C:\\Users\\dvenkat1\\Desktop\\test"
auto-create-directory="true" filename-generator-expression="#xpath(payload, '/*[name()=Envelope]/*[name()=Body]/*[name()=processArchiveRequest]/*[name()=fulfillmentRequest]/*[name()=requestHeader]/*[name()=requestID]/text()')" />
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sch="http://...schema">
<soap:Header/>
<soap:Body>
<sch:processArchiveRequest>
<sch:fulfillmentRequest>
<sch:requestHeader>
<sch:requestID>Samplereq</sch:requestID>
............
Another option would be, is to use something like this:
<int-file:outbound-channel-adapter
id="file" mode="APPEND" charset="UTF-8"
directory="C:\\Users\\dvenkat1\\Desktop\\test"
auto-create-directory="true" filename-generator-expression="#xpath(payload, 'reference exp1 here']) " />
<int-xml:xpath-expression id = "exp1"
expression="name(/soapNs:Envelope/soapNs:Body/schNs:processArchiveRequest/schNs: fulfillmentRequest/schNs:requestDetail/*[1])"
namespace-map="archiveNamespaceMap" />
<util:map id="archiveNamespaceMap">
<entry key="soapNs" value="http://www.w3.org/2003/05/soap-envelope" />
<entry key="schNs" value="http://blah../schema" />
</util:map>
It works for me like this:
filename-generator-expression="#xpath(payload, '//*[local-name()="requestID"]')"
Pay attention to the escaped " symbol.
Regarding <int-xml:xpath-expression>.
You can use it from the the filename-generator-expression as well, but you should follow with the XPathExpression and therefore use XmlPayloadConverter manually. And do that everything somewhere from the custom bean.

In ext.net, how do I align a tabpanel button to the right?

I would like to align the button of the right, but keep the content tabs on the left. This is my code:
<ext:TabPanel ID="TabPanel1" runat="server" Height="295" Plain="true" DeferredRender="false" meta:resourcekey="TabPanel1Resource1">
<TabBar>
<ext:Button runat="server" Icon="ArrowOut" meta:resourcekey="fullscreenResource1">
<DirectEvents>
<Click OnEvent="edit_fullOpenAdd" />
</DirectEvents>
</ext:Button>
</TabBar>
<Defaults>
<ext:Parameter Name="autoScroll" Value="true" Mode="Raw" />
</Defaults>
<Items>
......the content ......
</Items>
</ext:TabPanel>
Any Ideas?
Thank you!
Edit: I was told to try tabCls: 'right-tab', but I do not know how to implement this.
Use TabStrip control.
Please see this example: http://examples.ext.net/#/TabPanel/TabStrip/Overview/

Ribbon button should be hidden based on lead status - CRM 2011

I have custom button in lead ribbon. The custom button should be hidden when lead is qualified. How can I do that? Can any one please explain. I appreciate.
You can actually accomplish this entirely with built-in DisplayRule functionality. When a Lead is qualified, the StatusCode property is set to "Qualified", which translates into an OptionSet value of "3". You can check for the value of this property in a ValueRule and display/hide the control appropriately. I can think of two ways to achieve this:
Erik Pool's Visual Ribbon Editor
RibbonXml
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="CompanyName.Form.lead.MainTab.Actions.Sample.CustomAction" Location="Mscrm.Form.lead.MainTab.Actions.Controls._children" Sequence="41">
<CommandUIDefinition>
<Button Id="CompanyName.Form.lead.MainTab.Actions.Sample" Command="CompanyName.Form.lead.MainTab.Actions.Sample.Command" Sequence="29" ToolTipTitle="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.LabelText" LabelText="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.LabelText" ToolTipDescription="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.Description" TemplateAlias="isv" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command">
<EnableRules />
<DisplayRules>
<DisplayRule Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command.DisplayRule.ValueRule" />
</DisplayRules>
<Actions>
<Url Address="http://www.bing.com" />
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command.DisplayRule.ValueRule">
<ValueRule Field="statuscode" Value="3" />
</DisplayRule>
</DisplayRules>
<EnableRules />
</RuleDefinitions>
<LocLabels>
<LocLabel Id="CompanyName.Form.lead.MainTab.Actions.Sample.LabelText">
<Titles>
<Title languagecode="1033" description="Sample" />
</Titles>
</LocLabel>
<LocLabel Id="CompanyName.Form.lead.MainTab.Actions.Sample.Description">
<Titles>
<Title languagecode="1033" description="Sample Description" />
</Titles>
</LocLabel>
</LocLabels>
</RibbonDiffXml>

Resources