In order to find all attributes with name myAttr in the document I can do this //#myAttr but what if I want to specify the root and still find all attributes with that name in the document? Something like /root/{whatever_or_nothing}/#myAttribute
How about this way :
/root//#myAttribute
Related
we want to automate an web application with Robot framework/SeleniumLibrary. The app contains some tables, which do not have simple unique identifiers like id/name/class... They only can be uniquely identified via a nested property. Here a sample excerpt of the properties window (DevTools)
grid: window.<computed>
> FormSubmitOnlyChanged : true
> ...
> _dataprocessor: dataProcessor
> autoUpdate: false
> ...
> serverProcessor: "/TEST/GridNew/multi?group=getMetaData&name=Sources&editing=true"
> ...
> ...
...
The Element looks as following:
* The id parameter contains an dynamic id and can therefore not be used for object identification.
We tried some approaches, e.g.
//div[contains(#grid._dataprocessor.serverProcessor, 'group=getMetaData&name=Sources')]
or
//div[contains(#serverProcessor, 'group=getMetaData&name=Sources')]
but none of them did work. Does anybody have an idea how to get an XPath that makes it possible to contain the nested property? Thank you in advance.
Please try this XPath:
"//div[contains(., 'group=getMetaData&name=Sources')]"
The dot . means here any attribute containing group=getMetaData&name=Sources value.
Also, I see the parent element in the shared picture is hidden. Maybe this causes your problems?
Please try this below xpath:
//div[starts-with(#id,'cgrid2_')]
The developers now managed it to set an id manually to overwrite the generated dynamic ID. Furthermore, after more research, it seems to be not possible to use this property for XPath.
I'm working on creating a custom report report page in CQ5. I've got my reportbase and columnbase components set up correctly, by following the steps listed here. I am able to, for instance, pick up all the templates that are available, by setting the property nodeTypes to cq:Template
I want to add a constraint to it, say for example pick up templates whose jcr:title is foo. I created a node under querybuilder called propertyConstraints and added my constraints in the form of nodes below it, as describedhere. However, this does not work for me at all.
What is the correct way to add constraints to the querybuildernode? Has anyone tried this?
Also, once I get this working correctly, can I extend this example to return pages of a specific template?
Have you looked into the QueryBuilder API? Adobe's documentation discusses how to match 1 or more property values.
Create a node propertyConstraints under queryBuilder of type nt:unstructured
create another node under propertyConstraints with any name.
Add properties to this node :
name String jcr:title
value String foo
I'm generating XML file dynamiquely from database using Ruby Builder (http://builder.rubyforge.org/).
To add a Tag which name is in a variable, I found this:
xml.tag!(#myTagName)
How to dynamiquelly insert à list of attributes in this Tag ?
I dont know the names of the attributes which are loaded dynamically from database
I need to create a loop because I dont know how many attributes will be inserted.
Thanks.
I think it shouldn't be hard to do what you need. Whenever you add a tag you can pass along an optional hash which will be the tag's attributes. So for example if you do:
builder = Builder::XmlMarkup.new
xml = builder.person(name: "foo", age: 0 )
Then you will get <person name='foo' age='0'/>
So in a similar way if you build your dynamic attributes as a hash you can use the #tag! method like the following:
xml = builder.tag!(tag_name, attributes_hash)
I have my tag ${file.name} in a jsp file to display a name of file to download
name containt a full file name,include file extension. for example
testfile.png
a-file.zip
testfile-test505454654.png
a-filenum5468.docx
other_file_with_a_name_very_very_very_larrrrrrrrrrrrrrrrrrrrrge.pdf
Files with very long names, crash my layout.
I think the way to format the file name to shorten it but include the extention. Maybe
testfile.png
a-file.zip
testfile-test505454....png *
a-filenum5468.docx
other_file_with_a_na....pdf *
How I can do?
in href no problem because it is done by id ${file.id}
If file is a POJO, you may add a getter-method to the POJO (something like String getShortName(){}) that returns a short version of the file name. And then use the method in your EL expression: ${file.shortName}.
I would write and register a custom tag that would take care of shortening the output to a maximum length
<custom:short value="${file.name}" var="shortFileName" />
The tag would take care of shortening based on defaults or values you specify in the element and putting it the result in a request attribute you can use anywhere after that declaration.
Since the requirements can be used many times so You should go with CUSTOM Tag solution like #Sotirios Delimanolis suggested.
JSTL function ( Like c:fn ) is another solution. Using jstl function get better performance than Custom tag ( simple / classic model )
Link: http://www.noppanit.com/how-to-create-a-custom-function-for-jstl/
I have a Nokogiri xml node:
node = <word n='ab' v='cd'>something</word>
I want to add an attribute:
node['p']='ef'
but in such a way that it 'shows' the first in the list of attributes, like
node = <word p='ef' n='ab' v='cd'>something</word>
Is there a simple way to do this?
I don't know of any XML serializer that allows you to control the order of attributes (except by accident, relying on undocumented features of a product). It shouldn't matter; the order is only cosmetic.
When you say "the order denotes the certitude" this is very worrying, because you are attaching meaning to the order of attributes when XML is very clear that the order will in general not be maintained. You need to redesign your XML to find a different way to capture this information.