How do I pick a sub-element in Yahoo Pipes? - select

Below is an example of the type of RSS structure I am trying to parse (it is not complete for ease of explanation):
<rss>
<item>
<span>
test
test 2
</span>
</item>
<item>
<span>
test 3
test 4
</span>
</item>
</rss>
I have used the XPath Fetch Page module to fetch the page and used "//body/item" to select all the different item's.
My question is how do I select the second tag in the structure?
I can select the first tag by using something like item.span.a.content in Yahoo Pipes which would return "test" and "test 3" for the above example.
I want "test 2" and "test 4" to be returned. I thought that I could use something like item.span.a[1].content or item.span.a{1}.content but this does not seem to work.
I hope this is understandable I found it hard to explain.

The answer was to use: item.span.1.a.content
where 1 was the element in the a list that I needed.

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.

one pattern multiple responses in aiml

I want to make a chatbot,so my doubt is how can i respond in multiple ways for a single pattern in aiml ?
for example if the user asks whats next the chat bot should respond step1
if again he asks whats next it should respond step2.
You can use "that" tags in the template, which remember the last bot statement and answer accordingly, although this gives you just one level of control. If you want more levels, a better way is to set topics using the "think" tags, and then defining topic specific templates which will be used first.
To have multiple responses for a single <pattern>, you can use the <random> and <li> tags:
<category>
<pattern>WHATS NEXT</pattern>
<template><random>
<li>Step 1</li>
<li>Step 2</li>
</random></template>
</category>
However, the responses will be generated randomly and not in a certain order.
For instance, if the user inputs "What's next?" for the first time, the response might be "Step 1" and the next time the user inputs the same keyword, the response might still be "Step 1".
First you need a category that knows the steps, and returns the answer in a defined format. In my example the format is
MAKE TOAST STEP * *
where the first star is the step number and the second star represents the remainder of the returned text. Here is the category:
<category>
<pattern>MAKING TOAST STEP *</pattern>
<template>
<set var="step"><star/></set>
<condition var="step">
<li value="1">Make toast step 1, get some bread</li>
<li value="2">Make toast step 2, put the bread in the toaster</li>
<li value="3">Make toast step 3, wait until it pops up</li>
<li>Make toast step 4, eat the toast</li>
</condition>
</template>
</category>
Then you need a category that calls the next step but only if the previous answer was a toast-making question. This category uses the that tag to ensure it is activated only during the toast making conversation. It uses thatstar to get the previous step number, then adds one to the step number:
<category>
<pattern>WHAT IS NEXT</pattern>
<that>MAKE TOAST STEP * *</that>
<template>
<set var="step"><calculate><thatstar/>+1</calculate></set>
<srai>MAKING TOAST STEP <get var="step"/></srai>
</template>
</category>
Then you need a category to kick off the whole sequence:
<category>
<pattern>HOW DO I MAKE TOAST</pattern>
<template>
<srai>MAKING TOAST STEP 1</srai>
</template>
</category>
The caveats with this approach are (1) it uses the calculate tag which is not standard AIML but should be coded quite easily. (2) It uses AIML v2 elements such as variables used with get and set. (3) I have not tested it, but I am confident the process should work.
<category>
<pattern>TEST SPLIT</pattern>
<template>
I don't want to talk about that now.
<split/>
I would rather talk about you.
</template>
</category>
Do <split/>
Output
Reference

Umbraco - Displaying a specific image within a macro for-each child of certain node

Umbraco newbie here. I've researched a tonne but can't seem to find what I' looking for.
I have a site with a slider on the homepage, the slider is sitting in a macro which is using a for-each (of a nodes children) with a final goal to display the 'heroImage' image from that doctype. I cant post images as a newbie to this site, but heres my content structure:
HOME
PORTFOLIO
- First Item
- Another Item
ABOUT
CONTACT US
Home, Portfolio, ABOUT and CONTACT US are "Landing Pages" document types, and the children under Portfolio (First Item and Another Item) are "Portfolio Entries" document types. Below is the code on "Landing Page" calling the Slideshow macro.
Portfolio Entry has fields:
heroImage
images
body
Slideshow macro obviously being the highlight there. Easy enough. Heres my macro code where you'll see I'm trying to display the heroImage of the node in question for each 'for-each'.
<xsl:template match="/">
<!-- slider -->
<div id="slideshow">
<div id="slider" class="nivoSlider">
<xsl:for-each select="umbraco.library:GetXmlNodeById(1081)/*[#isDoc and position() < 4]">
<xsl:variable name="mediaId" select="umbraco.library:GetMedia(#id, 'false')/data [#alias = 'umbracoFile']" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="count($mediaNode/data) > 0 and string($mediaNode/data[#alias='umbracoFile']) != ''">
<img src="{$mediaNode/data[#alias='umbracoFile']}" alt="[image]" />
</xsl:if>
</xsl:if>
</xsl:for-each>
</div>
</div>
<!-- data-transition="slideInLeft" -->
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
</xsl:template>
I feel like im so close, and ran out of search queries as most of the solutions I found were dependant on the imageId being passed onto the macro from the other side of the macro which wouldn't work.
Hope Ive explained this enough and thanks in advance for your help!
First of all, it looks like you're hardcoding the parent node id. In the code you just provided, it seems to only be getting the children of the node with id 1081. From reading what you just posted, it would seem that on all landing pages, you want to display their individual portfolio entries.
Either way, I would stay away from hardcoding IDs. If the node id changes in any way(user deletes the node, it gets exported as a package to the live environment, etc), your code will stop working. I'd just use $currentPage instead.
Judging by your filter, I imagine you only want the first 3 items to show in the slider. The code seems correct, but you seem to be using the old schema and its associated xpath. If you're using a newer version of Umbraco, the way you reference node data in xslt would have changed. I would guess that you've found many code examples and tried merging them together, without realising they wouldn't call the same schema.
This wiki link will provide more information, and hopefully fix your problem if you're using the wrong xpath.

Displaying entries per category in ExpressionEngine

So, I've searched, and found a few posts that kinda get me what I want, but it still doesn't quite work. This post especially seemed closest to what I was trying to achieve, and I built my code off of it: http://expressionengine.com/forums/viewthread/168142/
To explain; I have a series of entries, each entry is assigned to only one category. I'd like to list out these categories and, beneath each category, list out the entries with one of their custom fields. Like so:
Category 1
Item 1
Item 2
Category 2
Item 1
Item 2
So, here's my code as it stands now, which lists out the categories, but doesn't spit out any of the entries at all:
{exp:channel:categories channel="faq-question" style="linear"}
<section class="faq-category-container closed">
<h1 class="faq-category-header">{category_name}</h1>
<dl>
{exp:query sql="
SELECT title, url_title AS urlt, cat_id
FROM exp_channel_titles
NATURAL JOIN exp_category_posts
WHERE channel_id = '7' AND cat_id = '{category_id}'
ORDER BY title ASC"
}
{embed="jazz-camp/faq-cat-list" faqlink="{urlt}"}
{/exp:query}
</dl>
</section><!-- end .faq-category -->
{/exp:channel:categories}
And the embedded template it references:
{exp:channel:entries channel="faq-question" url_title="{embed:faqlink}"}<!-- entry -->
<dt>{title}</dt>
<dd>
{faq_content}
</dd>
{/exp:channel:entries}
Any help would be most appreciated!
This may be a very basic example of what you're after:
{exp:channel:categories style="linear"}
<h1>{category_name}:</h1>
{exp:channel:entries category="{category_id}" dynamic="no"}
<p>{my_custom_field}</p>
{/exp:channel:entries}
{/exp:channel:categories}
So, here's what I ended up with at the end (courtesy of some help over at the EE boards):
{exp:channel:categories channel="faq-camp" style="linear" show_empty="no"}
<section class="faq-category-container closed">
<h1 class="faq-category-header">{category_name}</h1>
<div class="faq-questions-container">
<dl>
{embed="jazz-camp/faq-cat-list" faqlink="{category_id}" faqparent="faq-camp"}
</dl>
</div><!-- end .faq-questions-container -->
</section><!-- end .faq-category -->
{/exp:channel:categories}
And as for the embed, it looks like this:
{exp:channel:entries channel="{embed:faqparent}" category="{embed:faqlink}" dynamic="no"}<!-- entries -->
<dt>{title}</dt>
<dd>
{faq_answer}
</dd>
{/exp:channel:entries}
The reason for the embed has to do with how things are pulled in with regards to getting the correct channel entries; simply having the {exp:channel:entries} inline in the page didn't quite work.
The Category Archive tag might be helpful to you:
http://ellislab.com/expressionengine/user-guide/modules/channel/category_archive.html

Merging two XMLDOMDocuments

Is there any easy way in msxml to merge two xml documents (IXMLDomDocuments)?
I want to make one of the trees embedded as a child of the second one.
I saw that IXMLDomDocument3 offers importNode, but couldn't get it to work correctly. Is this the way to go or is there another solution?
Thanks,
Dan
What programming language are you using?
Here's a working example in Javascript:
Given A.xml:
<base>
<A>
<one>
<two/>
</one>
</A>
</base>
B.xml:
<something>
<B/>
<BBBBBB/>
</something>
merge.js:
var doc1 = new ActiveXObject("MSXML2.DOMDocument");
doc1.load("A.xml");
var doc2 = new ActiveXObject("MSXML2.DOMDocument");
doc2.load("B.xml");
doc1.documentElement.appendChild(doc2.documentElement);
WScript.echo (doc1.xml);
The output is:
<base>
<A>
<one>
<two/>
</one>
</A>
<something>
<B/>
<BBBBBB/>
</something>
</base>