CSS Attribute Selcetor - Which one is faster? - css

Which one is preferred in terms of performance?
a[href*="op.ExtSite.com/p"]
a[href*="shop.ExtSite.com/page"]
a[href^="http://shop.ExtSite.com/page"]
a[href^="http://shop.ExtSite.com/page"][href$=".html"]
Update
The last selector should have been written as follow:
a[href^="http://shop.E"][href$=".html"]
Also, regarding this multiple selector, I would like to know which condition is checked first, the left one or the right one?

My guess is either this one
a[href^="http://shop.ExtSite.com/page"]
or
a[href^="http://shop.ExtSite.com/page"][href$=".html"]
as it starts looking from the first of the string so all links that does not have h in the beginning will be avoided.
UPDATE
if you need to check on the full pattern then go with the one I mentioned below :
a[href^="http://shop.ExtSite.com/page.html"]

Related

capturing a child value in Firebase rules

Using Firebase, it's possible to create rule expressions tp protect data but I've found it can quickly become complex.
One case I'm looking at has a rule using the children of the current node, e.g.:
data.child('value').val() === true
It's also possible to create a rule based on the contents of another node:
root.hasChild($node_variable)
What I'd like to do is to combine these two, e.g.:
root.child(data.child('value')).hasChild($node_variable)
but this hybrid approach throws an error when I publish the combined rule. Is there a way around this?
As suggested by David in the comments, the solution was
root.child(data.child('value').val()).hasChild($node_variabl‌​e)

Is there any way to add multiple "Auto Number Prefix" in oracle ucm?

See, I have a requirement in which I am supposed to change the "Auto Number Prefix" for only one profile, I am wondering if there is any way to achieve that?
You should be able to set AutoNumberPrefix in a rule side effect and have it apply only to that rule/profile.
<$AutoNumberPrefix="profile1_"$>
For those who wants the answer for this, I found the method to provide the different prefix for different profile type. Go in Admin Server-> Configuration -> Paste this code;
AutoNumberPrefix=<$if dDocType like 'Profile_name'$>Prefix Name<$else$>another prefix name<$endif$>
Adding the code shown as "correct" is actually the more inflexible way to do this. Any changes require a restart of the Content Server.
Jonathan's answer was really close, but the syntax used ensures that the variable "AutoNumberPrefix" remains in the profile context. It needs to be placed into local data to be used. This is accomplished using the function "dpPromote".
<$dpPromote("AutoNumberPrefix","profile1_")$>

How to dynamically search/replace text with update in XQuery (exist-db)

My intention is to somehow clean source files automatically. How to do that in XQuery? (I am not interested in reconstructing the document in memory and storing it as a new one.) It is quite easy to do something similar in case of short and simple elements addressed directly, however, I can’t figure out how to do that dynamically for all the text nodes, if possible.
I would expect something like this could work:
update replace $div[contains(., 'chapter')] with replace(., 'chapter', 'Chapter')
This throws err:XPDY0002 Undefined context sequence for 'self::node()' [source: String]
Apparently, there is a problem in addressing the context with . in the replacing function. But maybe I don’t understand the update thing in general. I am only inspired by the bottom of this article.
Expression to the right of with is independent from expression to the left. So an explicit node/context is needed on both part :
update replace $div[contains(., 'chapter')] with replace($div, 'chapter', 'Chapter')

Ambiguous match, found 2 elements matching css, how to get to the second one?

I am having problems in Capybara with the Ambiguous match problem. And the page provides no 'ids" to identify which one is which.
I am using within function.
within('.tile.tile-animation.animation-left.animation-visible.animated') do
#some code in here
end
I've used the :match option which solved my first problem.
within('.tile.tile-animation.animation-left.animation-visible.animated', :match => :first) do
#some code in here
end
The question is how to get to the SECOND css '.tile.tile-animation.animation-left.animation-visible.animated' ?
It depends on the html -- a simple solutions is
within(all('.tile.tile-animated.animation-left.animation-visible.animated')[1]) do
# some code in here
end
which will scope to the second matching element on the page, but won't be able to auto-reload if the page changes, and won't wait for the elements to appear. If you need it to wait for at least two elements to appear you can do
within(all('.tile.tile-animated.animation-left.animation-visible.animated', minimum: 2)[1]) do
....
which will wait some time for at least the 2 elements to appear on the page, but still won't be able to auto-reload if the page changes. If you need the ability to auto-reload on a dynamically changing page it will need to be possible to write a unique selector for the element (rather than indexing into the results of #all.

How to add variable and do loop in CSS

Is it possible to add variable and do loop in css like php:
for($a=6; $a<9; $a++) { "#divShow"+$a }
So, the result will be:
#divShow6 #divShow7 #divShow8
Any idea? Thanks in advance.
No. There are no 'variables' or 'loops' in CSS. It is not a Turing-complete language. This is what CSS classes are for, so you don't have to generate IDs.
You don't have loops in CSS, but if you want to match all the tags with an id that starts with divShow you can use (example http://jsfiddle.net/diegof79/mUGsj/):
div[id^="divShow"]
But I'll recommend to use a class instead.
Also your question shows a match of childrens: divShow8 inside a divShow7. You don't need that kind of selector, because probably the problem can be resolved in another way (by using classes or different id).
Take a look to http://www.w3schools.com/cssref/sel_nth-child.asp maybe it gives you other ideas.

Resources