|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | + |
| 3 | +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" |
| 4 | + xmlns:functx="http://www.functx.com" |
| 5 | + xmlns="http://www.w3.org/1999/xhtml" |
| 6 | + xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/" |
| 7 | + xmlns:h="http://www.w3.org/1999/xhtml" |
| 8 | + xmlns:e="http://github.com/oreillymedia/epubrenderer" |
| 9 | + stylesheet="../chunk.xsl"> |
| 10 | + |
| 11 | + <!-- Tests around text nodes for formal XREF elements (those with data-type='xref') --> |
| 12 | + <x:scenario label="When *empty* XREF element is matched"> |
| 13 | + <x:context select="(//h:section//h:a[@data-type='xref'])[1]"> |
| 14 | + <section id="chapter1" data-type="chapter"> |
| 15 | + <p>Here comes a cross-reference: see <a data-type="xref" href="#chapter1"/></p> |
| 16 | + </section> |
| 17 | + </x:context> |
| 18 | + |
| 19 | + <x:scenario label="And autogenerate-xrefs param is disabled"> |
| 20 | + <x:context> |
| 21 | + <x:param name="autogenerate-xrefs" select="0"/> |
| 22 | + </x:context> |
| 23 | + <x:expect label="No XREF text node should be generated"> |
| 24 | + <a data-type="xref" href="..."/> |
| 25 | + </x:expect> |
| 26 | + </x:scenario> |
| 27 | + |
| 28 | + <x:scenario label="And autogenerate-xrefs param is enabled"> |
| 29 | + <x:context> |
| 30 | + <x:param name="autogenerate-xrefs" select="1"/> |
| 31 | + </x:context> |
| 32 | + <!-- Content based on params set globally for this spec doc and localization gentext --> |
| 33 | + <!-- If localizations change, test may produce false negative --> |
| 34 | + <x:expect label="XREF text node should be generated with proper content"> |
| 35 | + <a data-type="xref" href="...">Chapter 1</a> |
| 36 | + </x:expect> |
| 37 | + </x:scenario> |
| 38 | + </x:scenario> |
| 39 | + |
| 40 | + <x:scenario label="When *nonempty* XREF element is matched"> |
| 41 | + <x:context select="(//h:section//h:a[@data-type='xref'])[1]"> |
| 42 | + <section id="chapter1" data-type="chapter"> |
| 43 | + <p>Here comes a cross-reference: see <a data-type="xref" href="#chapter1">PLACEHOLDER</a></p> |
| 44 | + </section> |
| 45 | + </x:context> |
| 46 | + |
| 47 | + <x:scenario label="And autogenerate-xrefs param is disabled"> |
| 48 | + <x:context> |
| 49 | + <x:param name="autogenerate-xrefs" select="0"/> |
| 50 | + </x:context> |
| 51 | + <x:expect label="No XREF text node should be generated"> |
| 52 | + <a data-type="xref" href="...">PLACEHOLDER</a> |
| 53 | + </x:expect> |
| 54 | + </x:scenario> |
| 55 | + |
| 56 | + <x:scenario label="And autogenerate-xrefs param is enabled"> |
| 57 | + <x:context> |
| 58 | + <x:param name="autogenerate-xrefs" select="1"/> |
| 59 | + </x:context> |
| 60 | + <!-- Content based on params set globally for this spec doc and localization gentext --> |
| 61 | + <!-- If localizations change, test may produce false negative --> |
| 62 | + <x:expect label="XREF text node should be generated with proper content"> |
| 63 | + <a data-type="xref" href="...">Chapter 1</a> |
| 64 | + </x:expect> |
| 65 | + </x:scenario> |
| 66 | + </x:scenario> |
| 67 | + |
| 68 | + <x:scenario label="When an XREF points to an id in another location"> |
| 69 | + <x:context> |
| 70 | + <section id="chapter1" data-type="chapter"> |
| 71 | + <p>Here comes an XREF with an href pointing to another file: <a data-type="xref" id="empty_another_file" href="ch01.html#chapter1"/></p> |
| 72 | + <p>Another XREF with an href pointing to another file: <a data-type="xref" id="nonempty_another_file" href="ch01.html#chapter1">PLACEHOLDER</a></p> |
| 73 | + <p>XREF pointing to a URL <a data-type="xref" id="empty_web_url" href="http://oreilly.com/index.html#chapter1"/></p> |
| 74 | + <p>Another XREF with an href pointing to another file: <a data-type="xref" id="nonempty_web_url" href="http://oreilly.com/index.html#chapter1">PLACEHOLDER</a></p> |
| 75 | + </section> |
| 76 | + </x:context> |
| 77 | + |
| 78 | + <x:scenario label="Which is another local file (text node of XREF empty)"> |
| 79 | + <x:context select="//h:a[@id='empty_another_file']"/> |
| 80 | + <!-- Content based on params set globally for this spec doc and localization gentext --> |
| 81 | + <!-- If localizations change, test may produce false negative --> |
| 82 | + <x:expect label="XREF text node should be generated with proper content"> |
| 83 | + <a data-type="xref" id="empty_another_file" href="...">Chapter 1</a> |
| 84 | + </x:expect> |
| 85 | + </x:scenario> |
| 86 | + |
| 87 | + <x:scenario label="Which is another local file (text node of XREF nonempty)"> |
| 88 | + <x:context select="//h:a[@id='nonempty_another_file']"/> |
| 89 | + <!-- Content based on params set globally for this spec doc and localization gentext --> |
| 90 | + <!-- If localizations change, test may produce false negative --> |
| 91 | + <x:expect label="XREF text node should be generated with proper content"> |
| 92 | + <a data-type="xref" id="nonempty_another_file" href="...">Chapter 1</a> |
| 93 | + </x:expect> |
| 94 | + </x:scenario> |
| 95 | + |
| 96 | + <!-- For now, we're arguing that if the @href value is not a legit XREF, |
| 97 | + that should override the fact that data-type="xref" is on the <a> --> |
| 98 | + <x:scenario label="Which is a Web URL instead of a valid XREF (text node empty)"> |
| 99 | + <x:context select="//h:a[@id='empty_web_url']"/> |
| 100 | + <x:expect label="XREF text node should be left untouched"> |
| 101 | + <a data-type="xref" id="empty_web_url" href="..."/> |
| 102 | + </x:expect> |
| 103 | + </x:scenario> |
| 104 | + |
| 105 | + <x:scenario label="Which is a Web URL instead of a valid XREF (text node nonempty)"> |
| 106 | + <x:context select="//h:a[@id='nonempty_web_url']"/> |
| 107 | + <x:expect label="XREF text node should be left untouched"> |
| 108 | + <a data-type="xref" id="nonempty_web_url" href="...">PLACEHOLDER</a> |
| 109 | + </x:expect> |
| 110 | + </x:scenario> |
| 111 | + |
| 112 | + </x:scenario> |
| 113 | + |
| 114 | + |
| 115 | + <x:scenario label="When an XREF has a bogus href"> |
| 116 | + <x:context> |
| 117 | + <section id="chapter1" data-type="chapter"> |
| 118 | + <p>Here comes a bogus cross-reference: see <a data-type="xref" id="empty_bogus" href="#bogusbogus"/></p> |
| 119 | + <p>Another bogus cross-referece: see <a data-type="xref" id="empty_file_bogus" href="ch01.html#bogus"/></p> |
| 120 | + <p>Third bogus cross-reference: see <a data-type="xref" id="nonempty_bogus" href="#bogusbogus">I do believe this is bogus</a></p> |
| 121 | + <p>Fourth bogus cross-reference: See <a data-type="xref" id="nonempty_file_bogus" href="ch01.html#bogus">I do believe this is bogus</a></p> |
| 122 | + </section> |
| 123 | + </x:context> |
| 124 | + |
| 125 | + <x:scenario label="And an empty text node"> |
| 126 | + <x:context select="//h:a[@id='empty_bogus']"/> |
| 127 | + <x:expect label="Three question marks should be used for text node"> |
| 128 | + <a data-type="xref" id="empty_bogus" href="...">???</a> |
| 129 | + </x:expect> |
| 130 | + </x:scenario> |
| 131 | + |
| 132 | + <x:scenario label="Referencing another file and has an empty text node"> |
| 133 | + <x:context select="//h:a[@id='empty_file_bogus']"/> |
| 134 | + <x:expect label="Three question marks should be used for text node"> |
| 135 | + <a data-type="xref" id="empty_file_bogus" href="...">???</a> |
| 136 | + </x:expect> |
| 137 | + </x:scenario> |
| 138 | + |
| 139 | + <x:scenario label="And a nonempty text node"> |
| 140 | + <x:context select="//h:a[@id='nonempty_bogus']"/> |
| 141 | + <x:expect label="Three question marks should be used for text node"> |
| 142 | + <a data-type="xref" id="nonempty_bogus" href="...">???</a> |
| 143 | + </x:expect> |
| 144 | + </x:scenario> |
| 145 | + |
| 146 | + <x:scenario label="Referencing another file and has a nonempty text node"> |
| 147 | + <x:context select="//h:a[@id='nonempty_file_bogus']"/> |
| 148 | + <x:expect label="Three question marks should be used for text node"> |
| 149 | + <a data-type="xref" id="nonempty_file_bogus" href="...">???</a> |
| 150 | + </x:expect> |
| 151 | + </x:scenario> |
| 152 | + </x:scenario> |
| 153 | + |
| 154 | + <!-- Tests for text nodes of <a> elements that do not have data-type="xref" --> |
| 155 | + <x:scenario label="If an 'a' element does not contain data-type='xref'"> |
| 156 | + <x:context> |
| 157 | + <section id="chapter1" data-type="chapter"> |
| 158 | + <a id="no_data_type" href="#chapter1">DO NOT TOUCH ME</a> <!-- Don't update this one --> |
| 159 | + <a id="link" data-type="link" href="#chapter1">DO NOT TOUCH ME</a> <!-- Don't update this one --> |
| 160 | + <a id="no_data_type_no_text" href="#chapter1"/> <!-- Update this one --> |
| 161 | + <a id="link_no_text" data-type="link" href="#chapter1"/> <!-- Don't update this one --> |
| 162 | + <a id="no_data_type_no_text_bogus_href" href="#bogus"/> <!-- Update this one --> |
| 163 | + <a id="link_no_text_bogus_href" data-type="link" href="#bogus"/> <!-- Don't update this one --> |
| 164 | + <a id="no_data_type_no_text_href_not_xref" href="http://oreilly.com"/> <!-- Don't update this one --> |
| 165 | + <a id="link_no_text_href_not_xref" data-type="link" href="http://oreilly.com"/> <!-- Don't update this one --> |
| 166 | + </section> |
| 167 | + </x:context> |
| 168 | + |
| 169 | + <x:scenario label="And has a text node already"> |
| 170 | + <x:context select="//h:a[@id='no_data_type']"/> |
| 171 | + <x:expect label="Text node should not be modified"> |
| 172 | + <a id="no_data_type" href="...">DO NOT TOUCH ME</a> |
| 173 | + </x:expect> |
| 174 | + </x:scenario> |
| 175 | + |
| 176 | + <x:scenario label="And has a text node already (link)"> |
| 177 | + <x:context select="//h:a[@id='link']"/> |
| 178 | + <x:expect label="Text node should not be modified"> |
| 179 | + <a id="link" data-type="link" href="...">DO NOT TOUCH ME</a> |
| 180 | + </x:expect> |
| 181 | + </x:scenario> |
| 182 | + |
| 183 | + <x:scenario label="And does not have a text node already, and has a valid XREF link"> |
| 184 | + <x:context select="//h:a[@id='no_data_type_no_text']"/> |
| 185 | + <!-- Content based on params set globally for this spec doc and localization gentext --> |
| 186 | + <!-- If localizations change, test may produce false negative --> |
| 187 | + <x:expect label="Text node should be updated with proper gentext"> |
| 188 | + <a id="no_data_type_no_text" href="...">Chapter 1</a> |
| 189 | + </x:expect> |
| 190 | + </x:scenario> |
| 191 | + |
| 192 | + <x:scenario label="And does not have a text node already, but is a link with a valid XREF link"> |
| 193 | + <x:context select="//h:a[@id='link_no_text']"/> |
| 194 | + <x:expect label="Text node should not be modified"> |
| 195 | + <a id="link_no_text" data-type="link" href="..."/> |
| 196 | + </x:expect> |
| 197 | + </x:scenario> |
| 198 | + |
| 199 | + <x:scenario label="And does not have a text node already, and has a bogus XREF link"> |
| 200 | + <x:context select="//h:a[@id='no_data_type_no_text_bogus_href']"/> |
| 201 | + <!-- Content based on params set globally for this spec doc and localization gentext --> |
| 202 | + <!-- If localizations change, test may produce false negative --> |
| 203 | + <x:expect label="Text node should be updated with question marks"> |
| 204 | + <a id="no_data_type_no_text_bogus_href" href="...">???</a> |
| 205 | + </x:expect> |
| 206 | + </x:scenario> |
| 207 | + |
| 208 | + <x:scenario label="And does not have a text node already, and is a link with a bogus XREF link"> |
| 209 | + <x:context select="//h:a[@id='link_no_text_bogus_href']"/> |
| 210 | + <x:expect label="Text node should not be modified"> |
| 211 | + <a id="link_no_text_bogus_href" data-type="link" href="..."/> |
| 212 | + </x:expect> |
| 213 | + </x:scenario> |
| 214 | + |
| 215 | + <x:scenario label="And does not have a text node already, and has an href that is not an XREF"> |
| 216 | + <x:context select="//h:a[@id='no_data_type_no_text_href_not_xref']"/> |
| 217 | + <x:expect label="Text node should not be modified"> |
| 218 | + <a id="no_data_type_no_text_href_not_xref" href="..."/> |
| 219 | + </x:expect> |
| 220 | + </x:scenario> |
| 221 | + |
| 222 | + <x:scenario label="And does not have a text node already, and is a link with an href that is not an XREF"> |
| 223 | + <x:context select="//h:a[@id='link_no_text_href_not_xref']"/> |
| 224 | + <x:expect label="Text node should not be modified"> |
| 225 | + <a id="link_no_text_href_not_xref" data-type="link" href="..."/> |
| 226 | + </x:expect> |
| 227 | + </x:scenario> |
| 228 | + </x:scenario> |
| 229 | + |
| 230 | + <!-- Tests for hrefs on a elems with data-type="XREF" --> |
| 231 | + |
| 232 | + |
| 233 | +</x:description> |
0 commit comments