I have this line:
let $name := data($item//*[#class='title'])
Instead of title - I want to reference all of the classes that start with sku.
A sample class name looks like this:
sku-RjItMEJEUy1VNUlY
How would I do this?
this should do the trick I think
$item//*[starts-with(#class, 'sku')]
Related
I need to use node.xpath to access a JSON node, but the property name contains space, like "First Name":
empDesc = cts.doc('/employee/employee1.json').xpath('//First Name');
How can I make this work?
Something like this:
empDesc = cts.doc('/employee/employee1.json').xpath('//*[name(.)="First Name"]')
But you are probably better off converting this to a JSON object and using normal access methods.
You can use node() with an argument inside MarkLogic XPath:
empDesc = cts.doc('/employee/employee1.json').xpath('//node("First Name")');
If you need to grab multiple properties, you could also convert to a JSON object first, and access that the regular way, like Mary suggested. Something like this:
let doc = cts.doc('/employee/employee1.json').toObject();
let empDesc = doc.employee['First Name'] + ' ' + doc.employee['Last Name'];
HTH!
I got problem such as :
id="tabscontent:tabView:BWconent_0:j_idt670"
After exceute
id changed = "tabscontent:tabView:BWconent_0:j_idt682"
670 change 682
Everyone know how to make : contains() or starts-with() or ends-with()
Please to help me
Thank you so much
P/s : I mean using xpath id for Katalon Testcase
Assuming that the beginning part of the id is static you can use starts-with() like this:
//*[starts-with(#id, 'tabscontent:tabView:BWconent_0:treeLeft_0:1:j_idt')]
The above XPath will return elements with id attribute value starts with "tabscontent:tabView:BWconent_0:treeLeft_0:1:j_idt"
Use this
TestObject myObject = new TestObject().addProperty('css', ConditionType.EQUALS, 'a[id^="tabscontent:tabView:BWconent_0"]')
The ^="some text" denotes "starts-with" for css selectors.
You will need to import TestObject and ConditionType classes. You can just press Ctrl+Shift+O in script mode and Katalon will do the rest.
Is it possible to set points in initials?
For example to change MAW into M.A.W.
I tried keep_before, but it doesn't work.
?keep_before(" ")+". "}
Result: MAW.
Please help.
You could do it like:
${'MAW'?replace('','.')[1..]}
'MAW'?replace('','.') will result in .M.A.W., which you can "substring" by using the range [1..].
See
https://freemarker.apache.org/docs/ref_builtins_string.html#ref_builtin_replace
https://freemarker.apache.org/docs/dgui_template_exp.html#dgui_template_exp_stringop_slice
It's easiest to do with regular expressions: ${initials?replace('.', '$0.', 'r')}. It's maybe nicer if you wrap this into a #function though (<#function dotify(s)><#return s?replace('.', '$0.', 'r')></#function>, and then ${dotify(initals)}), especially if you need to do this on multiple places.
If your letters are in name try:
<#list 0..(name?length-1) as idx>${name[idx]}.</#list>
One simple thing:
I want to combine the {s name="*"} and {link file="*"} blocks.
src="{link file='{s name='sFooterPaymentsIcon'}{/s}'}"
The problems should be the
'
signs.
How can I do that?
You can try assign a new variable and pass that on file parameter, like:
{assign var="my_file" value="{s name='sFooterPaymentsIcon'}{/s}"}
and then
src="{link file="$my_file"}"
You can do it this way:
//Assign snippet value to variable $snippetLink, in case variable is empty - assign LinkInCaseSnippetEmpty
{assign var='snippetLink' value='LinkInCaseSnippetEmpty'|snippet:'TheNameOfSnippet':"Namespace/If/Need"}
//assign source from variable $snippetLink
src="{link file=$my_file}"
In one line:
src="{link file='LinkInCaseSnippetEmpty'|snippet:'TheNameOfSnippet':'Namespace/If/Need'}"
{s} is for for text-snippets and should not be used for configuration-variables. If you need to make an include configurable, you should create a plugin for that.
The plugin should have a frontend-subscriber and make the file-include configurable via backend configuration-form. In the subscriber you can pass the configuration-value for the file-include to the frontend-view.
When I use Sphinx automethod to document a specific method like so:
.. automethod:: my_module.MyClass.my_method
The resulting docs append the class name to the method name like this:
MyClass.my_method(kwarg1=None, kwarg2=None)
This is the docstring for my_method...
Is there any way to tell automethod to not prefix the method name with the class name, such that the resulting docs look like this:
my_method(kwarg1=None, kwarg2=None)
This is the docstring for my_method...
?
Add this line in your conf.py file
add_module_names = False
In addition to
add_module_names = False
use
.. autofunction:: my_module.MyClass.my_method
instead of automodule and the class name is omitted in the generated doc.