diff --git a/js/onixProcessor.js b/js/onixProcessor.js index eb3b68c..819ac67 100644 --- a/js/onixProcessor.js +++ b/js/onixProcessor.js @@ -26,7 +26,7 @@ var onixProcessor = (function() { // 4.1.2 Variables setup var all_textual_content_can_be_modified = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormFeature[onix:ProductFormFeatureType = "09" and onix:ProductFormFeatureValue = "36"]'); - var is_fixed_layout = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormDetail[text() = "E201"]') && !checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormDetail[text() = "E200"]'); + var is_fixed_layout = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormDetail[normalize-space() = "E201"]') && !checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormDetail[normalize-space() = "E200"]'); // 4.1.3 Instructions @@ -279,7 +279,7 @@ var onixProcessor = (function() { var audiobook = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:DescriptiveDetail[onix:PrimaryContentType = "81" or onix:ProductContentType = "81"]'); var all_content_audio = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormFeature[onix:ProductFormFeatureType = "09" and onix:ProductFormFeatureValue = "39"]'); var all_content_pre_recorded = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormFeature[onix:ProductFormFeatureType = "09" and onix:ProductFormFeatureValue = "51"]'); - var synchronised_pre_recorded_audio = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormFeature[onix:ProductFormFeatureType = "09" and onix:ProductFormFeatureValue = "20"]') && checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormDetail[text() = "A305"]'); + var synchronised_pre_recorded_audio = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormFeature[onix:ProductFormFeatureType = "09" and onix:ProductFormFeatureValue = "20"]') && checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:ProductFormDetail[normalize-space() = "A305"]'); var non_textual_content_audio = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:DescriptiveDetail[contains(" 21 22 ", onix:PrimaryContentType) or contains(" 21 22 ", onix:ProductContentType)]'); var non_textual_content_audio_in_video = checkForNode(onix, '/onix:ONIXMessage/onix:Product/onix:DescriptiveDetail/onix:DescriptiveDetail[contains(" 06 25 26 27 28 29 30 ", onix:PrimaryContentType) or contains(" 06 25 26 27 28 29 30 ", onix:ProductContentType)]'); diff --git a/js/packageProcessor.js b/js/packageProcessor.js index 50a3ad9..acf4de4 100644 --- a/js/packageProcessor.js +++ b/js/packageProcessor.js @@ -24,9 +24,9 @@ var packageProcessor = (function() { * 4.1 Visual adjustments */ - // 4.1.2 Variables setup - var all_textual_content_can_be_modified = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="displayTransformability"]'); - var is_fixed_layout = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="rendition:layout" and text()="pre-paginated"]'); + // 4.1.2 Variables setup + var all_textual_content_can_be_modified = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="displayTransformability"]'); + var is_fixed_layout = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="rendition:layout" and normalize-space()="pre-paginated"]'); // 4.1.3 Instructions @@ -39,12 +39,12 @@ var packageProcessor = (function() { var vis_result = document.createElement('p'); - if (all_textual_content_can_be_modified) { - vis_result.appendChild(document.createTextNode('Appearance can be modified')); + if (is_fixed_layout) { + vis_result.appendChild(document.createTextNode('Appearance cannot be modified')); } - else if (is_fixed_layout) { - vis_result.appendChild(document.createTextNode('Appearance cannot be modified')); + else if (all_textual_content_can_be_modified) { + vis_result.appendChild(document.createTextNode('Appearance can be modified')); } else { @@ -63,10 +63,10 @@ var packageProcessor = (function() { * 4.2 Supports nonvisual reading */ - // 4.2.2 Variables setup - var all_necessary_content_textual = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessModeSufficient" and text()="textual"]'); - var non_textual_content_images = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and (text()="chartOnVisual" or text()="chemOnVisual" or text()="diagramOnVisual" or text()="mathOnVisual" or text()="musicOnVisual" or text()="textOnVisual")]'); - var textual_alternative_images = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and (text()="longDescription" or text()="alternativeText" or text()="describedMath")]'); + // 4.2.2 Variables setup + var all_necessary_content_textual = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessModeSufficient" and normalize-space()="textual"]'); + var non_textual_content_images = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessMode" and contains(" chartOnVisual chemOnVisual diagramOnVisual mathOnVisual musicOnVisual textOnVisual ", normalize-space())]'); + var textual_alternative_images = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and contains(" longDescription alternativeText describedMath ", normalize-space())]'); // 4.2.3 Instructions @@ -80,6 +80,10 @@ var packageProcessor = (function() { var nonvis_result = document.createElement('p'); + if (textual_alternative_images) { + nonvis_result.appendChild(document.createTextNode('Has alt text')); + } + if (all_necessary_content_textual) { nonvis_result.appendChild(document.createTextNode('Readable in read aloud or dynamic braille')); } @@ -106,25 +110,26 @@ var packageProcessor = (function() { var conformance_string = ''; var wcag_level = ''; - if (checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and text() = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"] | /opf:package/opf:metadata/opf:link[@rel="dcterms:conformsTo" and @href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"]')) { + if (checkForNode(package_document, '/package/metadata/link[@rel="dcterms:conformsTo" and @href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"] | /package/metadata/meta[@property="dcterms:conformsTo" and normalize-space() = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"]')) { conformance_string = 'EPUB Accessibility 1.0 WCAG 2.0 Level A'; wcag_level = 'A'; } - if (checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and text() = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"] | /opf:package/opf:metadata/opf:link[@rel="dcterms:conformsTo" and @href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"]')) { + if (checkForNode(package_document, '/package/metadata/link[@rel="dcterms:conformsTo" and @href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"] | /package/metadata/meta[@property="dcterms:conformsTo" and text() = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"]')) { conformance_string = 'EPUB Accessibility 1.0 WCAG 2.0 Level AA'; wcag_level = 'AA'; } - if (checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and text() = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"] | /opf:package/opf:metadata/opf:link[@rel="dcterms:conformsTo" and @href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"]')) { + if (checkForNode(package_document, '/package/metadata/link[@rel="dcterms:conformsTo" and @href="http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"] | /package/metadata/meta[@property="dcterms:conformsTo" and text() = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"]')) { conformance_string = 'EPUB Accessibility 1.0 WCAG 2.0 Level AAA'; wcag_level = 'AAA'; } - // js evaluate() can't handle this expression /opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and matches(text(), "EPUB Accessibility 1\.1 - WCAG 2\.[0-2] Level [A]+")] + // js evaluate() can't handle this expression: + // /opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and matches(normalize-space(), "EPUB Accessibility 1\.1 - WCAG 2\.[0-2] Level [A]+")] // using contains() instead to match most of it - var conformance = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and contains(text(), "EPUB Accessibility 1.1 - WCAG 2.")]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; + var conformance = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="dcterms:conformsTo" and contains(normalize-space(), "EPUB Accessibility 1.1 - WCAG 2.")]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; if (conformance) { conformance_string = conformance.replace(' - ', ' '); @@ -133,10 +138,10 @@ var packageProcessor = (function() { wcag_level = conformance.replace(level_re, ''); } - var certifier = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="a11y:certifiedBy"]/text()', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; - var certifier_credentials = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="a11y:certifierCredential"]/text()', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; + var certifier = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="a11y:certifiedBy"]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; + var certifier_credentials = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="a11y:certifierCredential"]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; var certification_date = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="dcterms:date" and @refines=//opf:meta[@property="a11y:certifiedBy"]/@id]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; - var certifier_report = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="a11y:certifierReport"]/text()', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; + var certifier_report = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="a11y:certifierReport"]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; // 4.3.3 Instructions @@ -144,8 +149,12 @@ var packageProcessor = (function() { conf_hd.appendChild(document.createTextNode('Conformance')); result.appendChild(conf_hd); - if (conformance_string) { - + if (!conformance_string) { + result.appendChild(document.createTextNode('No information is available.')); + } + + else { + var conf_p = document.createElement('p'); if (wcag_level == 'AAA') { @@ -225,26 +234,6 @@ var packageProcessor = (function() { cert_p.appendChild(document.createTextNode(certification_date)); } - if (certifier) { - cert_p.appendChild(document.createTextNode(' by ')); - cert_p.appendChild(document.createTextNode(certifier)); - } - - if (certifier_credentials) { - cert_p.appendChild(document.createTextNode(' with a credential of ')); - - if (certifier_credentials.match('^http')) { - var cert_link = document.createElement('a'); - cert_link.href = certifier_credentials; - cert_link.appendChild(document.createTextNode(certifier_credentials)); - cert_p.appendChild(cert_link); - } - - else { - cert_p.appendChild(document.createTextNode(certifier_credentials)); - } - } - // add punctuation - not in algorithm cert_p.appendChild(document.createTextNode('.')); @@ -254,11 +243,9 @@ var packageProcessor = (function() { var rep_p = document.createElement('p'); - rep_p.appendChild(document.createTextNode('For more information refer to the certifier\'s report ')); - var rep_link = document.createElement('a'); rep_link.href = certifier_credentials; - rep_link.appendChild(document.createTextNode(certifier_report)); + rep_link.appendChild(document.createTextNode('For more information refer to the certifier\'s report')); rep_p.appendChild(rep_link); // add punctuation - not in algorithm @@ -268,20 +255,15 @@ var packageProcessor = (function() { } } - - else { - result.appendChild(document.createTextNode('The publication does not include a conformance statement')); - } - /* * 4.4 Prerecorded audio */ // 4.4.2 Variables setup - var all_content_audio = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessModeSufficient" and text()="auditory"]'); - var synchronised_pre_recorded_audio = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="sychronizedAudioText"]'); - var audio_content = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessMode" and text()="auditory"]'); + var all_content_audio = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessModeSufficient" and normalize-space()="auditory"]'); + var synchronised_pre_recorded_audio = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="sychronizedAudioText"]'); + var audio_content = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessMode" and normalize-space()="auditory"]'); // 4.4.3 Instructions @@ -304,7 +286,7 @@ var packageProcessor = (function() { } else { - prerec_result.appendChild(document.createTextNode('No information about pre-recorded audio is available')); + prerec_result.appendChild(document.createTextNode('No information is available')); } // add punctuation - not in algorithm @@ -318,10 +300,10 @@ var packageProcessor = (function() { */ // 4.5.2 Variables setup - var table_of_contents_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="tableOfContents"]'); - var index_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="index"]'); - var page_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="pageNavigation"]'); - var next_previous_structural_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="structuralNavigation"]'); + var table_of_contents_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="tableOfContents"]'); + var index_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="index"]'); + var page_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="pageNavigation"]'); + var next_previous_structural_navigation = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="structuralNavigation"]'); // 4.5.3 Instructions @@ -329,117 +311,189 @@ var packageProcessor = (function() { nav_hd.appendChild(document.createTextNode('Navigation')); result.appendChild(nav_hd); - var nav_result = document.createElement('p'); - if (table_of_contents_navigation || index_navigation || page_navigation || next_previous_structural_navigation) { - var navigation = []; + var navigation = document.createElement('ul'); if (table_of_contents_navigation) { - navigation.push("table of contents"); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Table of contents')); + navigation.appendChild(li); } if (index_navigation) { - navigation.push("index"); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Index')); + navigation.appendChild(li); } if (page_navigation) { - navigation.push("supports page navigation"); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Go to page')); + navigation.appendChild(li); } if (next_previous_structural_navigation) { - navigation.push("headings"); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Headings')); + navigation.appendChild(li); } - var navigation_string = joinArray(navigation); - navigation_string = "Navigation by " + navigation_string; - - nav_result.appendChild(document.createTextNode(navigation_string)); + result.appendChild(navigation); } else { - nav_result.appendChild(document.createTextNode('No information about navigation is available')); + var nav_result = document.createElement('p'); + nav_result.appendChild(document.createTextNode('No information is available')); + + // add punctuation - not in algorithm + nav_result.appendChild(document.createTextNode('.')); + + result.appendChild(nav_result); } - // add punctuation - not in algorithm - nav_result.appendChild(document.createTextNode('.')); - - result.appendChild(nav_result); - /* - * 4.6 Charts, diagrams, math, and formulas + * 4.6 Rich content */ - // 4.6.2 Variables setup - var contains_charts_diagrams = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="chartOnVisual"]'); - var long_text_descriptions = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="longDescriptions"]'); - var contains_chemical_formula = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="chemOnVisual"]'); - var chemical_formula_as_chemml = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="ChemML"]'); - var contains_math_formula = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="describedMath"]'); - var math_formula_as_latex = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="latex"]'); - var math_formula_as_mathml = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="MathML"]'); + // 4.6.2 Variables setup + var contains_charts_diagrams = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessMode" and normalize-space()="chartOnVisual"]'); + var long_text_descriptions = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="longDescriptions"]'); + var contains_chemical_formula = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessMode" and normalize-space()="chemOnVisual"]'); + var chemical_formula_as_latex = checkForNode(package_document, '/package/metadata/meta[@property="schema:accessibilityFeature" and normalize-space()="latex-chemistry"]'); + var chemical_formula_as_mathml = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="MathML-chemistry"]'); + var contains_math_formula = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="describedMath"]'); + var math_formula_as_latex = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="latex"]'); + var math_formula_as_mathml = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="MathML"]'); + var closed_captions = checkForNode(package_document, '/package/metadata/meta[@property="schema:accessibilityFeature" and normalize-space()="closedCaptions"]'); + var open_captions = checkForNode(package_document, '/package/metadata/meta[@property="schema:accessibilityFeature" and normalize-space()="openCaptions"]'); + var transcript = checkForNode(package_document, '/package/metadata/meta[@property="schema:accessibilityFeature" and normalize-space()="transcript"]'); // 4.6.3 Instructions - var cdmf_hd = document.createElement(hd_type); - cdmf_hd.appendChild(document.createTextNode('Charts, diagrams, math, and formulas')); - result.appendChild(cdmf_hd); + var rc_hd = document.createElement(hd_type); + rc_hd.appendChild(document.createTextNode('Rich content')); + result.appendChild(rc_hd); - if (contains_charts_diagrams && long_text_descriptions) { - var p = document.createElement('p'); - p.appendChild(document.createTextNode('Charts and diagrams have extended descriptions')); + var richcontent = document.createElement('ul'); + + if (math_formula_as_mathml) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Math as MathML')); // add punctuation - not in algorithm - p.appendChild(document.createTextNode('.')); + li.appendChild(document.createTextNode('.')); - result.appendChild(p); + richcontent.appendChild(li); } - if (chemical_formula_as_chemml) { - var p = document.createElement('p'); - p.appendChild(document.createTextNode('Accessible chemistry content')); + if (math_formula_as_latex) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Math as LaTeX')); // add punctuation - not in algorithm - p.appendChild(document.createTextNode('.')); + li.appendChild(document.createTextNode('.')); - result.appendChild(p); + richcontent.appendChild(li); } - if (math_formula_as_latex || math_formula_as_mathml) { - var p = document.createElement('p'); - p.appendChild(document.createTextNode('Accessible math content')); + if (contains_math_formula) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Math as images with text description')); // add punctuation - not in algorithm - p.appendChild(document.createTextNode('.')); + li.appendChild(document.createTextNode('.')); - result.appendChild(p); + richcontent.appendChild(li); } - if ((contains_charts_diagrams || contains_chemical_formula || contains_math_formula) && !(long_text_descriptions || chemical_formula_as_chemml || math_formula_as_latex || math_formula_as_mathml)) { - var p = document.createElement('p'); - p.appendChild(document.createTextNode('accessibility of formulas, charts, math, and diagrams not identified as being accessible')); + if (chemical_formula_as_mathml) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Chemical formulas in MathML')); // add punctuation - not in algorithm - p.appendChild(document.createTextNode('.')); + li.appendChild(document.createTextNode('.')); - result.appendChild(p); + richcontent.appendChild(li); } + if (chemical_formula_as_latex) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Chemical formulas in LaTex')); + + // add punctuation - not in algorithm + li.appendChild(document.createTextNode('.')); + + richcontent.appendChild(li); + } + + if (long_text_descriptions) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Information-rich images are described by extended descriptions')); + + // add punctuation - not in algorithm + li.appendChild(document.createTextNode('.')); + + richcontent.appendChild(li); + } + + if (closed_captions) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Videos have closed captions')); + + // add punctuation - not in algorithm + li.appendChild(document.createTextNode('.')); + + richcontent.appendChild(li); + } + + if (open_captions) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Videos have open captions')); + + // add punctuation - not in algorithm + li.appendChild(document.createTextNode('.')); + + richcontent.appendChild(li); + } + + if (transcript) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Has transcript')); + + // add punctuation - not in algorithm + li.appendChild(document.createTextNode('.')); + + richcontent.appendChild(li); + } + + if (!(math_formula_as_mathml || math_formula_as_latex || (contains_math_formula && long_text_descriptions) || chemical_formula_as_mathml || long_text_descriptions || closed_captions || open_captions || transcript)) { + var li = document.createElement('li'); + li.appendChild(document.createTextNode('No information is available')); + + // add punctuation - not in algorithm + li.appendChild(document.createTextNode('.')); + + richcontent.appendChild(li); + } + + result.appendChild(richcontent); + /* * 4.7 Hazards */ // 4.7.2 Variables setup - var no_hazards_or_warnings_confirmed = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="none"]'); - var flashing_hazard = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="flashing"]'); - var no_flashing_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="noFlashingHazard"]'); - var motion_simulation_hazard = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="motionSimulation"]'); - var no_motion_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="noMotionSimulation"]'); - var sound_hazard = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="sound"]'); - var no_sound_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="noSoundHazard"]'); - var unknown_if_contains_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and text()="unknown"]'); + var no_hazards_or_warnings_confirmed = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="none"]'); + var flashing_hazard = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="flashing"]'); + var no_flashing_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="noFlashingHazard"]'); + var motion_simulation_hazard = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="motionSimulation"]'); + var no_motion_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="noMotionSimulation"]'); + var sound_hazard = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="sound"]'); + var no_sound_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="noSoundHazard"]'); + var unknown_if_contains_hazards = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityHazard" and normalize-space()="unknown"]'); // 4.7.3 Instructions @@ -447,53 +501,64 @@ var packageProcessor = (function() { haz_hd.appendChild(document.createTextNode('Hazards')); result.appendChild(haz_hd); - var haz_result = document.createElement('p'); - if (no_hazards_or_warnings_confirmed || (no_flashing_hazards && no_motion_hazards && no_sound_hazards)) { - haz_result.appendChild(document.createTextNode('No hazards')); + var p = document.createElement('p'); + p.appendChild(document.createTextNode('No hazards')); + result.appendChild(p); } else if (flashing_hazard || motion_simulation_hazard || sound_hazard) { - var hazards = []; - if (flashing_hazard) { - hazards.push('flashing'); + var p = document.createElement('p'); + p.appendChild(document.createTextNode('Flashing')); + + // add punctuation - not in algorithm + p.appendChild(document.createTextNode('.')); + + hazards.appendChild(p); } if (motion_simulation_hazard) { - hazards.push('motion simulation'); - } + var p = document.createElement('p'); + p.appendChild(document.createTextNode('Motion simulation')); - if (sound_hazard) { - hazards.push('sound'); + // add punctuation - not in algorithm + p.appendChild(document.createTextNode('.')); + + hazards.appendChild(p); } - var hazards_string = joinArray(hazards); - hazards_string = String(hazards_string).charAt(0).toUpperCase() + String(hazards_string).slice(1); + if (sound_hazard) { + var p = document.createElement('p'); + p.appendChild(document.createTextNode('Loud sounds')); - if (hazards.length > 1) { - hazards_string = hazards_string + ' hazards'; - } - else { - hazards_string = hazards_string + ' hazard'; + // add punctuation - not in algorithm + p.appendChild(document.createTextNode('.')); + + hazards.appendChild(p); } - - haz_result.appendChild(document.createTextNode(hazards_string)); } else if (unknown_if_contains_hazards) { - haz_result.appendChild(document.createTextNode('The presence of hazards is unknown')); - } + var p = document.createElement('p'); + p.appendChild(document.createTextNode('The presence of hazards is unknown')); - else { - haz_result.appendChild(document.createTextNode('No information about possible hazards is available')); + // add punctuation - not in algorithm + p.appendChild(document.createTextNode('.')); + + hazards.appendChild(p); } - // add punctuation - not in algorithm - haz_result.appendChild(document.createTextNode('.')); + else { + var p = document.createElement('p'); + p.appendChild(document.createTextNode('No information is available')); - result.appendChild(haz_result); + // add punctuation - not in algorithm + p.appendChild(document.createTextNode('.')); + + hazards.appendChild(p); + } /* @@ -503,7 +568,7 @@ var packageProcessor = (function() { // 4.8.2 Variables setup var accessibility_summary = package_document.evaluate('/opf:package/opf:metadata/opf:meta[@property="schema:accessibilitySummary"][1]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; var lang_attribute_accessibility_summary = package_document.evaluate('(/opf:package/opf:metadata/opf:meta[@property="schema:accessibilitySummary"][1]/@xml:lang | /opf:package/@xml:lang)[last()]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; - var language_of_text = package_document.evaluate('/opf:package/opf:metadata/dc:language[1]/text()', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; + var language_of_text = package_document.evaluate('/opf:package/opf:metadata/dc:language[1]', package_document, nsResolver, XPathResult.STRING_TYPE, null).stringValue; // 4.8.3 Instructions @@ -529,7 +594,7 @@ var packageProcessor = (function() { } else { - sum_result.appendChild(document.createTextNode('No accessibility summary is available')); + sum_result.appendChild(document.createTextNode('No information is available')); // add punctuation - not in algorithm sum_result.appendChild(document.createTextNode('.')); @@ -543,9 +608,9 @@ var packageProcessor = (function() { */ // 4.9.2 Variables setup - var eaa_exemption_micro_enterprises = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="a11y:exemption" and text()="eaa-microenterprise"]'); - var eaa_exception_disproportionate_burden = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="a11y:exemption" and text()="eaa-disproportionate-burden"]'); - var eaa_exception_fundamental_modification = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="a11y:exemption" and text()="eaa-fundamental-alteration"]'); + var eaa_exemption_micro_enterprises = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="a11y:exemption" and normalize-space()="eaa-microenterprise"]'); + var eaa_exception_disproportionate_burden = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="a11y:exemption" and normalize-space()="eaa-disproportionate-burden"]'); + var eaa_exception_fundamental_modification = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="a11y:exemption" and normalize-space()="eaa-fundamental-alteration"]'); // 4.9.3 Instructions @@ -556,11 +621,11 @@ var packageProcessor = (function() { var legal_result = document.createElement('p'); if (eaa_exemption_micro_enterprises || eaa_exception_disproportionate_burden || eaa_exception_fundamental_modification) { - legal_result.appendChild(document.createTextNode('TBD')); + legal_result.appendChild(document.createTextNode('Claims an accessibility exemption in some jurisdictions')); } else { - legal_result.appendChild(document.createTextNode('No legal considerations')); + legal_result.appendChild(document.createTextNode('No information is available')); } // add punctuation - not in algorithm @@ -579,123 +644,108 @@ var packageProcessor = (function() { // 4.10.1 Adaptation // 4.10.1.2 Variables setup - var audio_descriptions = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="audioDescription"]'); - var braille = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="braille"]'); - var closed_captions = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="closedCaptions"]'); - var open_captions = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="openCaptions"]'); - var tactile_graphic = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="tactileGraphic"]'); - var tactile_object = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="tactileObject"]'); - var transcript = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="transcript"]'); - var sign_language = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="signLanguage"]'); + var audio_descriptions = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="audioDescription"]'); + var braille = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="braille"]'); + var tactile_graphic = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="tactileGraphic"]'); + var tactile_object = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="tactileObject"]'); + var sign_language = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="signLanguage"]'); // 4.10.1.3 Instructions - var adaptation = []; + var aai = document.createElement('ul'); if (audio_descriptions) { - adaptation.push('audio descriptions'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Audio descriptions')); + aai.appendChild(li); } if (braille) { - adaptation.push('braille'); - } - - if (closed_captions) { - adaptation.push('closed captions'); - } - - if (open_captions) { - adaptation.push('open captions'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Braille')); + aai.appendChild(li); } if (tactile_graphic) { - adaptation.push('tactile graphic'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Tactile graphics')); + aai.appendChild(li); } if (tactile_object) { - adaptation.push('tactile 3D object'); - } - - if (transcript) { - adaptation.push('transcript'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Tactile 3D objects')); + aai.appendChild(li); } if (sign_language) { - adaptation.push('sign language'); - } - - if (adaptation.length) { - var adaptation_string = joinArray(adaptation); - adaptation_string = String(adaptation_string).charAt(0).toUpperCase() + String(adaptation_string).slice(1); - - var adapt_result = document.createElement('p'); - adapt_result.appendChild(document.createTextNode('Adaptability: ' + adaptation_string)); - - // add punctuation - not in algorithm - adapt_result.appendChild(document.createTextNode('.')); - - result.appendChild(adapt_result); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Sign language')); + aai.appendChild(li); } // 4.10.2 Clarity // 4.10.2.2 Variables setup - var aria = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="aria"]'); - var full_ruby_annotations = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="fullRubyAnnotations"]'); - var text_to_speech_hinting = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="ttsMarkup"]'); - var high_contrast_between_foreground_and_background_audio = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="highContrastAudio"]'); - var high_contrast_between_text_and_background = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="highContrastDisplay"]'); - var large_print = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="largePrint"]'); - var page_break_markers = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="pageBreakMarkers"]'); - var ruby_annotations = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and text()="rubyAnnotations"]'); + var aria = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="aria"]'); + var full_ruby_annotations = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="fullRubyAnnotations"]'); + var text_to_speech_hinting = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="ttsMarkup"]'); + var high_contrast_between_foreground_and_background_audio = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="highContrastAudio"]'); + var high_contrast_between_text_and_background = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="highContrastDisplay"]'); + var large_print = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="largePrint"]'); + var page_break_markers = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="pageBreakMarkers"]'); + var ruby_annotations = checkForNode(package_document, '/opf:package/opf:metadata/opf:meta[@property="schema:accessibilityFeature" and normalize-space()="rubyAnnotations"]'); // 4.10.2.3 Instructions - var clarity = []; - if (aria) { - clarity.push('aria'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('ARIA')); + aai.appendChild(li); } if (full_ruby_annotations) { - clarity.push('full ruby annotations'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Full ruby annotations')); + aai.appendChild(li); } if (text_to_speech_hinting) { - clarity.push('text-to-speech hinting provided'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Text-to-speech hinting provided')); + aai.appendChild(li); } if (high_contrast_between_foreground_and_background_audio) { - clarity.push('high contrast between foreground and background audio'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('High contrast between foreground and background audio')); + aai.appendChild(li); } if (high_contrast_between_text_and_background) { - clarity.push('high contrast between text and background'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('High contrast between text and background')); + aai.appendChild(li); } if (large_print) { - clarity.push('large print'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Large print')); + aai.appendChild(li); } if (page_break_markers) { - clarity.push('page breaks'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Page breaks')); + aai.appendChild(li); } if (ruby_annotations) { - clarity.push('ruby annotations'); + var li = document.createElement('li'); + li.appendChild(document.createTextNode('Ruby annotations')); + aai.appendChild(li); } - if (clarity.length) { - var clarity_string = joinArray(adaptation); - clarity_string = String(clarity_string).charAt(0).toUpperCase() + String(clarity_string).slice(1); - - var clarity_result = document.createElement('p'); - clarity_result.appendChild(document.createTextNode('Clarity: ' + clarity_string)); - - // add punctuation - not in algorithm - clarity_result.appendChild(document.createTextNode('.')); - - result.appendChild(clarity_result); - } + result.appendChild(aai); return result;