Skip to content

Commit 655fd9b

Browse files
Updating extended description POC
- Added third example with two images in a figure container with links outside figcaption, issue #61 - Demonstrated using an icon as extended description link - Fixed JavaScript XPath query by adding namespace resolver for XHTML
1 parent aca568a commit 655fd9b

File tree

7 files changed

+76
-10
lines changed

7 files changed

+76
-10
lines changed
429 KB
Binary file not shown.

experiments/extended-desc/extended-description-poc/OEBPS/content.opf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
<item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" properties="nav" />
2727
<item id="chart-ebcaadfb" href="chart-ebcaadfb.png" media-type="image/png" />
2828
<item id="ex1" href="ex1.jpg" media-type="image/jpeg" />
29+
<item id="info-circle-icon" href="info-circle-icon.svg" media-type="image/svg+xml" />
30+
<item id="infographic-1786704_1280" href="infographic-1786704_1280.png" media-type="image/png" />
31+
<item id="pie-chart-154411_640" href="pie-chart-154411_640.png" media-type="image/png" />
2932
</manifest>
3033
<spine>
3134
<itemref idref="poc-external-page-extended-description" />
Lines changed: 1 addition & 0 deletions
Loading
224 KB
Loading
207 KB
Loading

experiments/extended-desc/extended-description-poc/OEBPS/poc-external-page-extended-description-appendix.xhtml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Extended Descriptions</title>
6+
<style>
7+
img {
8+
max-width: 100%;
9+
}
10+
</style>
611
</head>
712
<body>
813
<h1>Extended Descriptions</h1>
@@ -74,5 +79,33 @@
7479
<a role="doc-backlink" href="poc-external-page-extended-description.xhtml#img2">Navigate back to heart and lung diagram</a>.
7580
</p>
7681
</section>
82+
<section id="extended-description-img3">
83+
<h2>Description of Pie chart</h2>
84+
<img role="presentation" src="pie-chart-154411_640.png" />
85+
<p>A pie chart with 4 parts:</p>
86+
<ol>
87+
<li>45%</li>
88+
<li>25%</li>
89+
<li>20%</li>
90+
<li>10%</li>
91+
</ol>
92+
<p>
93+
<a role="doc-backlink" href="poc-external-page-extended-description.xhtml#img3">Navigate back to pie chart</a>.
94+
</p>
95+
</section>
96+
<section id="extended-description-img4">
97+
<h2>Description of Infographic</h2>
98+
<img role="presentation" src="infographic-1786704_1280.png" />
99+
<p>An infographic divided in four parts:</p>
100+
<ol>
101+
<li>I: bla</li>
102+
<li>II: bla bla</li>
103+
<li>III: bla bla bla</li>
104+
<li>IV: bla bla bla bla</li>
105+
</ol>
106+
<p>
107+
<a role="doc-backlink" href="poc-external-page-extended-description.xhtml#img4">Navigate back to infographic</a>.
108+
</p>
109+
</section>
77110
</body>
78111
</html>

experiments/extended-desc/extended-description-poc/OEBPS/poc-external-page-extended-description.xhtml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>External Page Extended Description</title>
6+
<style>
7+
.icon {
8+
width: 1em;
9+
}
10+
11+
img {
12+
max-width: 100%;
13+
}
14+
</style>
615
</head>
716
<body>
817
<section role="doc-chapter">
@@ -26,31 +35,51 @@
2635
<p><a id="anchor-extended-description-img2" href="poc-external-page-extended-description-appendix.xhtml#extended-description-img2">Extended description second image</a></p>
2736
<p>This is placeholder text designed to simulate the actual text of the chapter.</p>
2837
<p>This is placeholder text serving as a substitute of the actual text of the chapter. The quick brown fox jumps over the lazy dog, demonstrating how various letters appear in different contexts. Meanwhile, the five boxing wizards jump quickly, showcasing another pangram that contains every letter of the alphabet. These sample sentences help designers and developers visualize how text will look in their layouts before the actual content becomes available.</p>
38+
<p>A third example with two images in a <code>figure</code> container, with the link to the extended description outside the <code>figcaption</code>:</p>
39+
<figure>
40+
<img id="img3" aria-details="anchor-extended-description-img3" src="pie-chart-154411_640.png" alt="Pie chart"/>
41+
<p><a id="anchor-extended-description-img3" href="poc-external-page-extended-description-appendix.xhtml#extended-description-img3">Extended description for the first image of this container</a></p>
42+
<img id="img4" aria-details="anchor-extended-description-img4" src="infographic-1786704_1280.png" alt="Infographic"/>
43+
<p><a id="anchor-extended-description-img4" href="poc-external-page-extended-description-appendix.xhtml#extended-description-img4"><img src="info-circle-icon.svg" class="icon" alt="Extended description for the second image of this container - taken from https://uxwing.com/license/" /></a></p>
44+
<figcaption>
45+
<p>This is the caption for these two images.</p>
46+
<p>Image by <a href="https://pixabay.com/users/openclipart-vectors-30363/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=154411">OpenClipart-Vectors</a> from <a href="https://pixabay.com//?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=154411">Pixabay</a></p>
47+
<p>Image by <a href="https://pixabay.com/users/gustavofer74-791316/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1786704">Gustavo Ferreira Gustavo</a> from <a href="https://pixabay.com//?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1786704">Pixabay</a></p>
48+
</figcaption>
49+
</figure>
2950
</section>
3051

3152
<script>
3253
function runTest() {
3354
console.log('=== XPATH TEST to identify extended descriptions for reading system developers ===');
34-
55+
3556
try {
57+
// Namespace resolver for XHTML documents
58+
const nsResolver = function(prefix) {
59+
const ns = {
60+
'xhtml': 'http://www.w3.org/1999/xhtml'
61+
};
62+
return ns[prefix] || null;
63+
};
64+
3665
// Test 1: identify links to extended descriptions
37-
const linkXPath = "//a[@id=//img[@aria-details]/@aria-details]";
38-
const linkResult = document.evaluate(linkXPath, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
39-
66+
const linkXPath = "//xhtml:a[@id=//xhtml:img[@aria-details]/@aria-details]";
67+
const linkResult = document.evaluate(linkXPath, document, nsResolver, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
68+
4069
console.log('\nTest 1 - identify links to extended descriptions:');
4170
console.log('\t- XPath used:', linkXPath);
42-
71+
4372
const linkNodes = [];
4473
let linkNode;
45-
74+
4675
// Raccoglie tutti i nodi che corrispondono al criterio
4776
while (linkNode = linkResult.iterateNext()) {
4877
linkNodes.push(linkNode);
4978
}
50-
79+
5180
if (linkNodes.length > 0) {
5281
console.log(`\t- ✓ Found ${linkNodes.length} link(s):`);
53-
82+
5483
linkNodes.forEach((node, index) => {
5584
console.log(`\t Link ${index + 1}:`);
5685
console.log(`\t - ID: ${node.id}`);
@@ -60,13 +89,13 @@
6089
} else {
6190
console.log('\t- ✗ No links found in the page');
6291
}
63-
92+
6493
} catch (error) {
6594
console.error('Error during the test:', error.message);
6695
console.error('Stack trace:', error.stack);
6796
}
6897
}
69-
98+
7099
// Run the test automatically when the page loads
71100
window.addEventListener('load', runTest);
72101
</script>

0 commit comments

Comments
 (0)