Add code to the AML (Notepad) using Powershell - powershell

I've got the following code in Notepad:
<AML>
<Item type="Class" action="add">
<name>Pepsi</name>
<name>Fanta</name>
<name>Sprite</name>
</Item>
</AML>
and using the Powershell code is it possible to add some new rows like Coca-Cola and 7-up to the file? But it's needed to add it to the .
Like the result should be:
<AML>
<Item type="Class" action="add">
<name>Pepsi</name>
<name>Fanta</name>
<name>Sprite</name>
<name>Coca-Cola</name>
<name>7-up</name>
</Item>
</AML>
These new values will be taken from some array and dynamically added to this file time by time.
Doesn't matter it will be Notepad or Notepad++ it's just for test. The result will be in xml I believe.

Related

Orbeon/XForms: Change dropdown values based on other input control

I have a text control my-text and a dropdown my-dropdown. Depending on the content of my-text, the itemset of my-dropdown should change. Unfortunately, there is no visibility property for individual dropdown items, so I thought of a different solution. Inside the <resource xml:lang="en"> tag of my Orbeon form i defined several itemsets:
<first-itemset>
<item>
<label>AAA</label>
<value>a</value>
</item>
<item>
<label>BBB</label>
<value>b</value>
</item>
</first-itemset>
<second-itemset>
<item>
<label>XXX</label>
<value>x</value>
</item>
<item>
<label>YYY</label>
<value>y</value>
</item>
</second-itemset>
Now if content of my-text equals "first-itemset" then the first itemset should be used, otherwise the second. How can I do that?
Inside <fr:dropdown-select1 ...> I need something like
<xf:itemset ref="$form-resources/CONTENT_OF_MY-TEXT_HERE/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
</xf:itemset>
What do I need to write instead of CONTENT_OF_MY-TEXT_HERE to get the actual content so orbeon uses the correct itemset?
The direct answer to your question is: *[local-name() = xxf:value('choice-control')]. So you would have:
<xf:itemset
ref="
$form-resources/
*[local-name() = xxf:value('choice-control')]/
item
">
With this, you'd get a different itemset depending the value typed in the choice control:
However, keep in mind that if you're doin this in Form Builder, your change to the source can be lost quite easily. For instance, next time you change the control name, that ref expression will be reset. So, it would be better to find another way to achieve this. For instance, you could have 2 dropdowns, of which only one is visible at any point in time, based on the value enterer in the other field.

Magento 2 - Copy price block to another location in product layout

I am trying to find a way to duplicate the price block so that it appears in two locations of the product page for specific products, by using the Layout Update XML field inside the design tab of the product edit page (Magento Admin).
I have successfully copied the price block by creating a modified layout XML file for specific products, for example:
theme_folder\Magento_Catalog\layout\catalog_product_view_id_178.xml
Inside this file I added the following in the required location:
<block class="Magento\Catalog\Pricing\Render" name="product.price.final.second.location" after="product.info.options.wrapper">
<arguments>
<argument name="price_render" xsi:type="string">product.price.render.default</argument>
<argument name="price_type_code" xsi:type="string">final_price</argument>
<argument name="zone" xsi:type="string">item_view</argument>
</arguments>
</block>
However there are too many products that use this modified layout and it would be easier to manage the product catalog if I could achieve the same thing just using the Layout Update XML field and entering a simple instruction like:
<copy element="product.price.final" destination="second.price.container">
Except there is no copy instruction, only a move instruction which is not what I want.
A different solution would be to have a way to select which layout XML to use from the product edit page, for example a yes/no attribute.
Is there a way to achieve this result?
I found the solution. The following XML inserted into the Layout Update XML field will copy the price block to a referenceBlock (or referenceContainer):
<referenceBlock name="my.reference.block">
<block class="Magento\Catalog\Pricing\Render" name="product.price.final.lower">
<arguments>
<argument name="price_render" xsi:type="string">product.price.render.default</argument>
<argument name="price_type_code" xsi:type="string">final_price</argument>
<argument name="zone" xsi:type="string">item_view</argument>
</arguments>
</block>
</referenceBlock>

Create conditions in Eclipse plugin.xml

Is there a way to create conditions (similar to if/else blocks) in the Eclipse plugin.xml's files.
I'm creating a Eclipse plugins in which I need to set a different value depending on the project facet, I'm getting the project facet using:
<with variable="projectFacet">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="projectFacet" forcePluginActivation="true"/>
</with>
And then I have this code:
<item
label="test"
visible="false"
id="test.test1"
category="category1"
description="test description">
</item>
At this momment I'm hardcoding "category1", what I need is to select the correct category depending on the variable I got before, for example:
facet1 should be on the category1
facet2 should be on the category2
Someone knows how to do that? Thanks.

How to add a colorized HTML code snippet in Sandcastle documentation?

I am using the Sandcastle Help File Builder and would like to include colorized HTML code snippets in the "Conceptual Content". Is this possible and if so, how?
I have tried <code>, <codeExample>, and <sampleCode language="HTML" />.
The best result so far is to HTML-encode the sample HTML and place it in a .snippets file like so.
<?xml version="1.0" encoding="utf-8" ?>
<examples>
<item id="htmlSnippet">
<sampleCode language="HTML">
<span>My Html</span>
</sampleCode>
</item>
</examples>
Then reference it in the .aml file.
<codeReference>htmlSnippet</codeReference>
I would prefer to have it colorized, but I can't figure out a way to add the formatting.
According to the MAML Guide, the proper way of doing this is to use a <code> tag with a CDATA section:
<code language="xml" title="Example Configuration">
<![CDATA[
<span>My Html</span>]]>
</code>
The contents of the CDATA section will be treated as a literal string, and indentation will be preserved.
I know this is old, but Sandcastle supports html as xml. I figured I should comment in case anyone else comes across this post as I did.
This should work:
<?xml version="1.0" encoding="utf-8" ?>
<examples>
<item id="htmlSnippet">
<sampleCode language="xml"><!CDATA[[
<span>My Html</span>
]]>
</sampleCode>
</item>
</examples>
If you're using Sandcastle Help File Builder, you may create your own syntax parser as described here and here, although xml is available by default... using the XAML filter's generator, which is defined here if you want to look at the config:
<generator type="Microsoft.Ddue.Tools.XamlUsageSyntaxGenerator"
assembly="{#SandcastlePath}ProductionTools\SyntaxComponents.dll">
<filter files="{#SandcastlePath}Presentation\Shared\configuration\xamlSyntax.config" />
</generator>
According to the SHFB documentation for the Code Block Component, you should be able to just use the <code>.
I got it to work without a problem; here's what I did:
test.html
<html>
<head>Something!</head>
<body>
<h1>Heading</h1>
<!-- #region myhtml -->
<p>Paragraph</p>
<div>Div for <strong>Good</strong> <em>measure</em>.</div>
<!-- #endregion -->
</body>
</html>
SomethingorOther.aml
<code language="html" source="../Examples/test.html" region="myhtml" />
Result:
Please note that in the preview, your sample will appear as unhighlighted XML, but when you build the documentation, everything should like just fine.

What's the most efficient process for parsing XML and building a Core Data database?

Let's say I'm getting I'm receiving XML files from some web service, like these two examples..
<news>
<item id="123" created="10/09/10" expires="07/07/10" modified="10/09/10">
<title>Xiabo receives Nobel></title>
<content>Lorem ipsum lorem ipsum</content>
</item>
</news>
.
<products>
<item id="1" category="shoes">
<name>Nike Air</name>
<logo><![CDATA[http://example.com/images/logos/nikeair.png]></logo>
<content>Lorem ipsum lorem ipsum</content>
</item>
<item id="2" category="jeans">
<name>Wrangler</name>
<logo><![CDATA[http://example.com/images/logos/wrangler.png]></logo>
<content>Lorem ipsum lorem ipsum</content>
</item>
</products>
How would I parse these XML files and then add them to Core Data, so that next time I load the app the data will be there without reloading the XML.
Sorry my question is so vague, I'm just trying to get my head around it.
If you have any control over the web service, you should change XML format to JSON. Obj-C can digest JSON very efficiently. XML parsing(be it with xmllib or NSXMLParser) is not very efficient. My empirical analyses shows that NSXMLParser is faster at the expense of flexibility.