120 likes | 215 Views
References, ID and IDREFS. Elena Pierazzo 2006-2007. Cross references. We have provided a list ( see section 3.5 ) of bishops of Rochester... We have provided a list ( see page 96 ) of bishops of Rochester... . How can we do that?. Typing the text!
E N D
References, ID and IDREFS Elena Pierazzo 2006-2007
Cross references We have provided a list (see section 3.5) of bishops of Rochester... We have provided a list (see page 96) of bishops of Rochester...
How can we do that? • Typing the text! • But what if the number of sections changes or new paragraphs are added? • All the internal references should be edited by hand… • There’s a better way!
Anchors and links • We put a unique identifier to the object that need to be referred • We put a link to the identifier where we need the reference
Section 2 The SICK ROSE O Rose thou art sick. The invisible worm, That flies in the night In the howling storm: Has found out thy bed Of crimson joy: And his dark secret love Does thy life destroy. In the commentary, somewhere …In the Stick Rose poem (see section 2) the author tries to… An example id=stkRs ref=stkRs
<h4>Section 2</h4> <h3><a name="stkRs"></a>The SICK ROSE</h3> <div> O Rose thou art sick.<br> The invisible worm,<br> That flies in the night<br> In the howling storm: </div><div> Has found out thy bed<br> Of crimson joy:<br> And his dark secret love<br> Does thy life destroy.<br> </div> …In the Stick Rose poem (see the text <a href="#stkRS">here</a>) the author tries to… HTML example
And XML? • A cross reference system has to be provided in the DTD first!
DTD: two special kind of attributes • ID : provide a unique identifier • IDREF: provide a reference to an identifier placed somewhere in the text
For instance… <!ELEMENT title (#PCDATA)> <!ATTLIST title ident ID #IMPLIED> <!ELEMENT link (#PCDATA)> <!ATTLIST link refTo IDREF #REQUIRED> Type of attribute Attribute name Default value
<poem> <title ident="stkRs">The SICK ROSE</title> <stanza> <line>O Rose thou art sick.</line> <line>The invisible worm,</line> <line>That flies in the night</line> <line>In the howling storm:</line> </stanza> <stanza> <line>Has found out thy bed</line> <line>Of crimson joy:</line> <line>And his dark secret love</line> <line>Does thy life destroy.</line> </stanza> </poem> <comment> <p> …In the <link refTo="stkRS"> Stick Rose</link> poem the author tries to… </p> </comment> The texts…
…and the XSLT <xsl:template match=“title”> <h3> <a name=“{@ident}”></a> <xsl:apply-templates/> </h3> </template> <xsl:template match=“link”> <xsl:apply-templates/> (see the text <a href=“#{@refTo}”>here<a>) </xsl:template>
Exercises • Exercise 2, chap. 2