Forum How do I...?

CSS selector with class and not

JohnClarke
I want to add bookmarks for certain a.reflink elements that do not have the word "reader" in the href.

The following works fine:
a:not([href*=reader]) {
	prince-bookmark-level: 2;	
	bookmark-target: attr(href)
}


If I want to scope further by adding a class:
a.reflink:not([href*=reader]) {
	prince-bookmark-level: 2;	
	bookmark-target: attr(href)
}


I get a lot of empty bookmarks. Some of them seem to have valid targets.

Is there something that is syntactically incorrect in the second sample?
-John

BTW, I really like this CSS3 feature in Prince! :wink:

John Clarke
Cornerstone Systems Northwest Inc.

JohnClarke
Actually, neither of those work as expected. Moreover, I want to be able to limit the bookmarks by strings in their href AND avoid duplicates under a same node. So for instance,

<div id="section_01">
<a class="reflink" id="linkA" href="targetA">
<a class="reflink" id="linkC" href="targetC">
<a class="reflink" id="linkC" href="targetC">
<a class="reflink" id="LinkZ" href="LinkZ">
<a class="reflink" id="linkA" href="targetA">
<a class="reflink" id="linkB" href="targetB">
<a class="notareflink" id="linkB" href="targetB">
</div>

<div id="section_02">
<a class="reflink" id="linkA" href="targetA">
<a class="reflink" id="linkC" href="targetC">
<a class="reflink" id="linkC" href="targetC">
<a class="reflink" id="LinkZ" href="LinkZ">
<a class="reflink" id="linkA" href="targetA">
<a class="reflink" id="linkB" href="targetB">
<a class="notareflink" id="linkB" href="targetB">
</div>


would produce the following PDF bookmark tree:

Section01
--TargetA
--TargetC
--TargetB
Section02
--TargetA
--TargetC
--TargetB


Notice that there are no duplicate children on a given node, but duplicate "cousins" are allowed (between section01 and section02). Also there are no nodes with "Z" in the href.

Any suggetions would be appreciated. -John

John Clarke
Cornerstone Systems Northwest Inc.

JohnClarke
I think solved most of my own problems in this thread. It happens sometimes! :)

This works:
a.topiclink:not([href*="reader"]):not([href*="references"]):not([href*="Category"])


However I still can't figure out how to get rid of duplicate bookmarks. This does not work because it removes ALL sibling nodes (or quite possibly the last expression is just plain wrong):
a.topiclink:not([href*="reader"]):not([href*="references"]):not([href*="Category"]):not([href=attr(href)]~[href=:attr(href)]){


Is this possible? Perhaps I'm asking CSS to do something that it just wasn't made to do. Ideas?

John Clarke
Cornerstone Systems Northwest Inc.

mikeday
With regards to the last expression, the attr() function cannot be used within selectors.

You are definitely pushing the boundaries of what is possible with CSS3 Selectors, but that's part of the fun! :)
JohnClarke
Perhaps we could use counters? For example, we'd have a counter started for each new <a element. Its name would be taken from the ID or content. Then we simple check to see if the counter is >0 before adding it as a bookmark. But if we can't use attr() in a selector... I assume that means we can't use it in a counter either. :? -John

John Clarke
Cornerstone Systems Northwest Inc.

mikeday
No, I think this will require a more programmatic solution, such as a script or XSLT transform. CSS selectors are really aimed at styling, and cannot perform arbitrary computation.