how can i put in label a value from the xml - xslt

i want a label in my xsl which it's value be one from the xml,
how can i do that?

From your comment I think what you want is this:
<label text="{#theAdv}">
The {} allows you to evaluate XPATH expressions inside attribute values.
EDIT:
if the text is inside an element and not an attribute you can use the following:
<label text="{text()}">
text() get's the inner text of the current element.

Related

//*[#id="gwt-uid-2423"] is getting changed every rime in selenium python2.7 chrome

HTML Code is ..
<div class="N1LCMI-ib-e" role="option" id="gwt-uid-2423" style="user-select: none;">Hotel ID</div>
There is one button when i click on it there are some categories to select Only one category can be selected in one time. So Id in xpath is getting changed every time when i am using Xpath of that category. below is code which i am using to select that category.
driver.find_element_by_xpath('//*[#id="gwt-uid-2423"]').click() #select Hotel ID
so only 2423 part is getting changed every time.
is there any other way to go for it. pls help....
As you mentioned that the 2423 part is getting changed every time for the id attribute, so we can create a unique css_selector or xpath as follows:
css_selector :
driver.find_element_by_css_selector("div[class='N1LCMI-ib-e'][id^='gwt-uid-']").click()
xpath :
driver.find_element_by_xpath("//div[#class='N1LCMI-ib-e'][starts-with(#id, 'gwt-uid-')]").click()
You can find the element by contained text using an XPath.
//div[.='Hotel ID']

Make expression match optional value if possible

Consider the following text that might be part of an HTTP response from jMeter:
<menu id="Alpha" name="alpha">
<option value="a">A</option>
<option value="b">B</option>
<option value="c" selected="selected">C</option>
</menu>
<menu id="Bravo" name="bravo">
<option value="d">D</option>
<option value="e">E</option>
</menu>
I'm trying to extract the ID of each menu, as well as the selected option's value if there is an option selected. If there is no option selected, then by default, the first option's value should be matched. For example, in this example, I want the following to be matched:
"Alpha" "c"
"Bravo" "d"
So far, I have written the following:
<select id="Form:parameterList:([^"]+?)".*?>.*?(?:<option value="([^"]*?)".*?(?:selected="selected")?>)?.*?</select>
The problem with this is that only the first option's value is ever matched, and the selected option is never matched. That is, I want to prioritize matching the optional pattern.
Thanks,
Victor
Consider how maintainable your script will be using that complex regex.
You can achieve the result you desire using xpath extractors, conditional/loop controllers and or post-processors...
First get a list of all ids:
//menu/#id
You can get a list of ids containing an option with attribute selected = 'selected' with something similar to:
//menu/#id[/option[#selected='selected']]
Iterate through the first list (in a beanshell processor or loop controller, for instance). Where an id appears in the second list, extract the selected value with:
//menu[#id='xxxx']/option[#selected='selected']/#value /*substitue xxxx with appropriate id*/
Where the id does not have a 'selected' value, extract the default value:
//menu/[#id='xxxx']/option[1]/#value /*substitue xxxx with appropriate id*/
(sorry if my xpath aren't completely accurate, I have written this from memory alone, but hopefully the breadcrumbs are there to follow)

Cannot get List Lookup XSL param to use in HTML tag using SharePoint 2010 Designer

So I am adding a span tag to a few column fields in a couple of view all forms in SP 2010 Designer that have a Hexadec string in them, i'm using an inline style to display a block with a coloured background rather than the hexadec itself, so pretty simple.
I successfully achieved this in the first view but in the second view I cannot seem to return the value to use in the inline style, below is the original xsl and the row param is thisNode. The only difference in the views is one is the view all for a custom list(this one is working) and the other is the view all for another custom list with the previous lists value as a Lookup column, the columns xsl value is below.
<xsl:value-of select="$thisNode/#*[name()=current()/#Name]" disable-output-escaping="yes" />
I have tried adding the {$thisNode/#*[name()=current()/#Name]} to the inline css but get nothing returned when I should see a block of colour when viewing the form. I have also tried other ways to get the value from the thisNode row but have had no luck, can anyone tell me what I should be doing or what I am doing wrong?
Worked it out!
So the first step was to remove the hyperlink around the Loopup column:
<xsl:value-of select="substring-before(substring-after($thisNode/#*[name()=current()/#Name],'>'), '<')" disable-output-escaping="yes"/>
This then shows the Lookup column value as text; so we can use this method to create another param or variable and add the value to our css parameter like so:
<xsl:param name="thisNode" select="."/>
<xsl:param name="thisColour" select="substring-before(substring-after($thisNode/#*[name()=current()/#Name],'>'), '<')"/>
<span style="display:block;background:{$thisColour};width:20px;height:20px;" title=""></span>
This then shows my Hexadec colour as a 20px block rather than the Hexadec code as text, so hope this helps anyone else with the same problem, enjoy!

XSLT: Get the closest item with a specified value defined? (Sitecore)

I have the current structure;
Item 1
- Subitem 1
- Subitem 2
- Subitem 3
- - Sub subitem 1
- - Sub subitem 2
- - Sub subitem 3
- - etc
I have a field that is only defined on "Item 1". Let's call it 'Header'.
When i am on "Item 1" its easy enough to extract this value, but what about when i am on the other items? Is there a way i can go through the tree (up) until i find a field called 'Header' and it has a value, and then stop and use this as a reference point in my sub items?
If you want to look up the tree and find the closest element that contains a Header attribute with a value, something like this should work.
<xsl:value-of select="(ancestor::*/#Header[.!=''])[last()]" />
This uses the ancestor axis to look up the tree and the xpath expression looks for any element with a Header attribute who's value is not empty.
A second filter is used to evaluate the last one. If there is more than one ancestor that has a #Header with a value, the last one would be the closest to the context node, because the result is in document order.
EDIT: An alternative way to find the same results, leveraging the fact that ancestor axis returns in reverse document order would be to put the filter criteria in the predicate for the ancestor axis step, select the first one(closest match to the context node), and then step into the #Header:
<xsl:value-of select="ancestor::*[#Header!=''][1]/#Header" />
If your current context isn't Item 1 but rather one of its children, you can use the ancestor axis to get its data.
So, assuming your Item 1 element has an attribute called Header, you can do something like this:
<xsl:value-of select="ancestor::Item1/#Header"/>
This assumes your XML structure (which you really should have supplied in your question) looks like this:
<Item1 Header="a header">
<Subitem1/>
<Subitem2/>
<!-- etc -->
</Item1>
And that the name "Item1" is unique in this structure.

How can I disable href link in cfgrid cells for blank rows?

I have the following cfgrid:
<cfgrid format="html" name="grid" pagesize="10" selectmode="row" striperows="yes"
bind="cfc:data.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="link" header="Link" href="link.cfm" hrefkey="link_id">
</cfgrid>
Since pagesize is 10, I'll have some blank rows if I have less than 10 rows in the grid. For those blank row I'd have a '-' sign in place of the usual data, and the hrefkey will be null instead of the usual link_id. Is there a way to disable the href for blank rows? Or if there's a way to capture the null value with javascript?
You can loop through the a hrefs within the table and find all the hrefs that contain the '-' and change this to something else or remove the href completely. This can be done in JS but ideally I would try and do this before hand (i.e in CF) as there will be an overhead using JS to do this.