CSS Cross Referencing

Hi All

I have the following code in my CSS:

cross_reference[ID*="ALDF_"] {
	-xpp-xref-refer: attr(ID) foot this none;
}

cross_reference[ID*="ALDF_"]::before {
	content: -xpp-macro(ri, '%refpg4');
}

footnote {
	display: block;
	-xpp-xref-mark: attr(id);
}

footnote::before {
	content: -xpp-macro(i1, '16pt') -xpp-macro(sup) -xpp-macro(ri, '%refnum') -xpp-macro(reset) "\2009";
}

And this works fine - however if I change %refpg4 to %refnum each cross reference reports the "current" footnote %refnum rather than the one the the id reference is pointing to.

Just to reassure you the footnote has an attribute id= but the cross ref has ID=.

Any suggestions very welcome!

Chris

  • Supplementary question: In other places I have <cross_reference ID="unique number">Text Goes Here</cross_reference> which is then referenced elsewhere and the text needs outputting - how is this done in the CSS?

  • Hi Chris,

    I may not be understanding everything you're trying to do, especially without any "context" of how these elements are being used in the XML document.

    Is the footnote element being used inside the XML for an XPP footnote, or is it being used in main text? I'm assuming that the footnote element is being used inside a footnote.

    If it's being used inside an XPP footnote, do you realize that the composing of the footnote will essentially do the "xref mark" of the footnote type for you and that your doing "-xpp-xref-mark: attr(id)" in the footnote element is actually creating a cross reference for a "spot" type using the same ID as is probably being used for the footnote? Is that what you want? You may be able to just delete this -xpp-xref-mark from your CSS.

    In any case, my thought on your actual question is that the things you are doing in cross_reference[] and cross_reference[]::before are out-of-order.

    I would think that the ::before with the <ri> of %refpg4 or %refnum is being executed by composition before the main element and so you would need to move the -xpp-xref-refer in the main element to the ::before element so that the "refer" is executed by composition first before the <ri> of the %refxxx system variable is being executed.

    As far as the <ri> of %refnum in the footnote::before element, that works because composition has set the %refxxx system variables as it composes the footnote (and not because you have done the -xpp-xref-mark in the main footnote element, because if that was the case you would have the same out-of-order situation where you have the <ri> in the ::before before you have the "mark").

    Anyway, those are my initial thoughts.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • Hi Jonathan

    Thanks, I will take another look, I thought I was following the example at the foot of page 4-41 of the CSS PDF but may not be fully understanding it! I am not around tomorrow so will probably not get to this until Friday.

    The (simplified XML) is this:

        <footnote id="00013707">
          <p>Text here.</p>
        </footnote>
        <footnote id="00013708">
          <p>Text here but see footnote <cross_reference ID="00013705"/>.</p></footnote>
        <footnote id="00013709">
          <p><Text here but see footnote <cross_reference ID="00013707"/>.</p>
        </footnote>

    The footnote numbers are being generated (see original post) and the cross references should report back the footnote being referred to by its ID.

  • Yeah, Chris, you (and the doc) could be right and I could very easily not be understanding the order that composition is executing the different properties in the main element versus the ::before element and the -xpp-xref-refer in the main element is being executed before the content property in the ::before element. If that's the case then I don't have an explanation for the behavior you are seeing.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • Have you read through the CSS Text Capture section at the end of Chapter 4 of the CSS manual?

    That talks about using the -xpp-text-set and -xpp-text properties to capture and output text, although you would have to figure out how to translate the "unique number" of the ID attribute to an XPP text register number (1-255).

    If you're not going to be using the -xpp-text property in a frill block to output the captured text, then I think you'll have to explicitly use the <pa> macro or in Perl there is the get_text() function available.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • Chris,

    Just noticed this; maybe the explanation is this simple.

    In your CSS for main element and ::before element for cross_reference you have: cross_reference[ID*="ALDF_"].

    But in the XML snippet you gave you have e.g.: <cross_reference ID="00013705"/>

    So, the ID's being referenced via the cross_reference elements don't appear to match the CSS selector of ID*="ALDF_", and so maybe the CSS rule you think is being used is simply not being used?

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • No sorry - that was me making the XML snippet "too" simple - that actual ID's are ALDF_00013705 etc.

  • Chris,

    I am not sure about this, but I would think that if you do: -xpp-xref-refer: attr(ID) foot this none; the ID will contain the full value of the attribute = ALDF_0001307 and not the id of the footnote (=001307) you want to refer to.(even if you did do an attribute selection like [ID*="ADLF_"])
    But hey I could be wrong.

    Also I think think that %refnum will always give you back the number of the current footnote.
    See macro doc: %refnum Footnote or pickup sequence number.

    So you will have to do this in another way...
    Some clever xyPerl might do the trick in which you collect the footnote ids and the number of footnotes associated with it (and maybe write it out continuously)
    And on the next compose, first you read back the hash you have written out and then you could read out the footnote number that is associated with the footnote id.
    (could work in 1 go if the reference to a footnote always happens after the referenced footnote has been composed) 

    Oh and in a similar way that you could also store the text that is associated with the ID of the cross ref elements.
    (your example is a bit confusing as the cross_reference element is referring to a different footnote but contains at the same time the text you want to output?) 

  • I don't think I agree with Bart's conclusions.

    Chris already mentioned that the ID (and I assume id) attribute values are actually both ALDF_###### values and it was just that Chris over-simplified the XML snippet he gave. Yes, the attr(ID) and attr(id) values will be the full ALDF_###### attribute values (and not any subset being matched with the attribute selector), but as long as they match in both elements this should be fine.

    And although the description of the %refnum system variable does not explicitly mention the <rf> macro (as it does with %refpage and %refpg1 - %refpg6), if you go to the documentation for the <rf> macro it does mention in the Comments that "it stores the pickup and footnote reference numbers in %refnum". Doing -xpp-xref-refer should be the equivalent of doing an <rf>.

    I'm still not seeing why it's not working for you. If you don't have any success, you might need to open a ticket and submit a sample.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • I agree with Jonathan's comments above - the documentation specifically mentions %refnum - I will do some more playing tomorrow and report back - suffice it to say that %refpg4 is working perfectly with the above CSS and "real" data - its only when I substitute %refpg4 with %refnum that it changes behavior and only reports the "current " %refnum rather than the one that is referenced in the cross-reference macro.

    As Bart says I may need to use Perl (either on import or interactively) to sort the outputting of text - the files are very large and I am worried about the limit of 255 text registers. However I think the %refnum should work out the box as per the CSS and XyMacro documentation.