Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify language selection in package document #508

Open
mattgarrish opened this issue Nov 28, 2024 · 3 comments
Open

Simplify language selection in package document #508

mattgarrish opened this issue Nov 28, 2024 · 3 comments
Labels
a11y-display-techniques-epub Issue with the epub accessibility metadata display techniques

Comments

@mattgarrish
Copy link
Member

mattgarrish commented Nov 28, 2024

Ignoring #503 for now, the javascript xpath resolver also reports the expression to get the language of the summary is invalid:

/package/metadata/meta[@property="schema:accessibilitySummary"]/(@lang|ancestor::*/@lang)[last()]

I haven't dug into what it specifically doesn't like, but I can see right away that it will never match the language and it's more complicated than needed for epub processing.

The big issue here is that it is looking for a lang attribute but the package document only allows xml:lang.

But there are also only two locations where you can get the language of a metadata element: on the element itself or from the root package element. You don't need to inspect the ancestor chain because the only other element in the ancestor chain is metadata and it's not allowed to have an xml:lang declaration.

In other words, for getting the language, you only need to check:

/package/metadata/meta[@property="schema:accessibilitySummary"]/@xml:lang

or:

/package/@xml:lang

@mattgarrish mattgarrish added the a11y-display-techniques-epub Issue with the epub accessibility metadata display techniques label Nov 28, 2024
@mattgarrish
Copy link
Member Author

I haven't dug into what it specifically doesn't like,

For anyone interested, it looks like it's any expression using features above xpath 1.0. Most of the processing is easily implemented in javascript, but there are a couple of sticking points.

@mattgarrish
Copy link
Member Author

Combining the above, I was able to use this to get the language for the summary:

(/opf:package/opf:metadata/opf:meta[@property="schema:accessibilitySummary"]/@xml:lang | /opf:package/@xml:lang)[last()]

@mattgarrish
Copy link
Member Author

The preceding xpath is buggy. It needs to be specific to the first summary, so:

(/opf:package/opf:metadata/opf:meta[@Property="schema:accessibilitySummary"][1]/@xml:lang | /opf:package/@xml:lang)[last()]

For the techniques, you could still use the original but just be more specific about the ancestor:

/package/metadata/meta[@Property="schema:accessibilitySummary"]/(@lang|/package/@lang)[last()]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y-display-techniques-epub Issue with the epub accessibility metadata display techniques
Projects
None yet
Development

No branches or pull requests

1 participant