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
Support for conditional styling. #128
Comments
Since it will not be possible to break the uniqueness constraint without making content invalid XML, a different solution will be required for this use case. |
@skynavga I'd appreciate your thoughts on the alternative solutions described in the issue. |
Notes from 2016-09-20 f2f meeting: one option to consider here is to use a conditional |
@nigelmegitt Are you still interested in adding this capability to TTML2? If so, can you suggest a PR based on the |
@skynavga please review and comment on this |
@palemieux as discussed, yes, I believe this still needs to be addressed so that there are clear usable patterns for applying attributes based on Possible approaches1. Chained referential stylingThis is where conditionally removed elements may still be referenced by other elements and define the behaviour in that case to be "do nothing", e.g. <style xml:id="dependentStyleHighContrast" condition="parameter('high_contrast')='true'" tts:backgroundColor="#000000ff"/>
<style xml:id="dependentStyleNotHighContrast" condition="parameter('high_contrast')='false'" tts:backgroundColor="#00000080"/>
<style xml:id="backgroundStyle" style="dependentStyleHighContrast dependentStyleNotHighContrast"/> This appears to be possible now (so in that case one might say that this "works for me") however I think it rather inelegant from an authoring perspective and even slightly weird. Still, if no other resolution can be found then this would work I suppose - I would really like there to be clear examples and probably an appendix describing this pattern. Action point: Specifically, we need to explain/clarify in the style resolution process that a 2a. Conditional anonymous
|
When are |
Evaluation time is currently undefined as far as I can tell. |
On Mon, May 15, 2017 at 4:19 AM, Nigel Megitt ***@***.***> wrote:
Evaluation time is currently undefined as far as I can tell.
Yes, this needs to be defined, however, it may not be possible to do in a
precise manner. Basically, the design is predicated on determining whether
the semantics of a conditionalized element is ignored or not. So evaluation
can theoretically be delayed until the time when those semantics are
relevant, so what I know we can say is:
- we should not force (premature) eager evaluation, i.e., we need to
permit lazy evaluation;
- evaluation must not occur more than once, i.e., the condition should
not be re-evaluated every time its semantics need to be used;
|
This is too limiting. For responsive scenarios such as windows that can be resized, that would modify the input data for the equivalent of media queries, so it must be an available option to re-evaluate based on changing input data. |
On Mon, May 15, 2017 at 5:12 AM, Nigel Megitt ***@***.***> wrote:
- evaluation must not occur more than once, i.e., the condition should
not be re-evaluated every time its semantics need to be used;
This is too limiting. For responsive scenarios such as windows that can be
resized, that would modify the input data for the equivalent of media
queries, so it must be an available option to re-evaluate based on changing
input data.
ok, that is a reasonable position
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#128 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAXCb8XWBEKyh5PIF4Rb-5Nwc9tfsvQjks5r6DMUgaJpZM4GcAlv>
.
|
If What about simply using |
Some preliminary comments, without reviewing the above:
At present, the TTT toolset implements the above semantics, and needs this behavior in order to support an effective mapping of the IMSC1 I should also mention that the use and support of conditionalized styling does not prevent merging/flattening/reducing style specifications with respect to ISD instances; however, it does mean that conditionalized styling cannot be fully merged/flattened/reduced at ISD generation time. |
I'm not sure yet where I stand on breaking/not breaking chains of referential styles, but it seems intuitive to me to expect conditionally excluded style to break the chain. Otherwise a larger group of styles might all need the same condition to be applied. |
@nigelmegitt or the author could merely collect into the conditionalized style all style attribute they think should be ignored (while retaining the chain overall); |
@skynavga sorry, I don't follow you - please could you elaborate on #128 (comment) ? Are you saying that there should be an equivalent of |
I am saying that if you have
then The context where this came up was in supporting IMSC1's
where IMSC1 Input
TTML2 Output
|
@skynavga okay, then what happens in this case: <styling>
<initial tts:color="blue"/>
<style xml:id="s1" tts:color="yellow"/>
<style xml:id="s2" style="s1" condition="false" tts:color="white"/>
</styling>
...
<p style="s2">Blue, white or yellow?</p> In other words does the exclusion of a named style attribute cause all similarly named style attributes to be excluded or just the attribute defined in a context where the condition evaluates to |
yellow |
Thanks, I understand, so the proposal is that it is impossible to break the chain, only to conditionally set some specified style attributes when <styling>
<initial tts:color="blue"/>
<style xml:id="s1" tts:color="lime"/>
<style xml:id="s2" style="s1" condition="false"/> <!-- only there to define the chain? -->
<style xml:id="s3" style="s2" tts:backgroundColor="black"/>
</styling>
...
<p style="s3">Lime or blue?</p> in this example the conditional style defines no style attributes, so the assumption might be that the only thing the condition affects is the chain. But if I've understood correctly that isn't the case and the text comes out lime regardless? |
background color is black, from s3, and foreground color is lime, from s3->s2->s1 s2 doesn't specify any styles directly so the condition is vacuous in this case |
Okay that's consistent, and should be covered by the already requested clarification of what the condition semantic includes (and excludes), possibly with an informative note to say that there is no way to break style chaining using Additionally, now that we have a bit more clarity about what is intended, we should also check that this approach does not exclude any use cases that we expect to be supported. |
Changing this issue to the question "how to conditionalize styles?". Since style vocabulary is already subject to @condition usage, what remains is to clarify how this is done and any special semantics that need to be defined, such as whether style chaining is broken when a style element's @condition evaluates to false. |
A few comments on #128 (comment) above:
My conclusion is that no new technical mechanism is required, and that this issue can be fully resolved by adding clarifications to the effect:
I will post a PR that adds such clarifying language. |
OK I can accept not adding |
On Wed, May 31, 2017 at 1:47 AM, Nigel Megitt ***@***.***> wrote:
OK I can accept not adding set to style, but I see also that the region
element permits condition. Since the region attribute can only reference
a single region, and there is no chaining of regions, what region applies
to an element that specifies a region whose condition evaluates to false?
Multiple conditional explicit inline regions can be specified where the
first one whose condition is not false gets used. Same for walking up the
hierarchy to find first ancestor whose conditionalized region is not false.
… —
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#128 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAXCb-hb_SlOVcnxvNFwi0ad8JNbs-n5ks5r_Rr9gaJpZM4GcAlv>
.
|
I think that's too limiting and syntactically awkward - we should be able to use referential region specification too, but are blocked by this part of the spec:
The easiest (!) solution seems to be to change this to IDREFS and resolve the computed value to the first listed region whose condition resolves to true. |
Consider the use case in which an author wishes to permit the viewer of a TTML2 document to select from one of a number of style choices, either depending on a parameter or a media query, for example choices that vary tts:fontSize and tts:extent to accommodate 'normal size font', 'large size font' and 'small size font' options.
The condition attribute can only be used to omit an element from semantic processing, not to change its behaviour. One might imagine that the following is a way to proceed:
However this construct, which requires use of xml:id for style and region reference, breaks xml:id uniqueness rules, resulting in invalid documents. What options are there for achieving this use case? I can see:
a) repeating all the content in the document with different style and region references and specifying condition only on the content,
b) basing everything on the initial element and making that conditional (since nothing needs to refer to initial by xml:id), and specifying all regions inline - unfortunately this may be very verbose in terms of repeating regions on many content elements, but it could work for cases where there are only a few regions and they can be associated with body or div elements.
Neither of these two options is particularly attractive - a) is highly repetitious and offers no advantage over the provision of multiple documents with any associated costs for asset management and distribution there. b) is limited in basing style on initial so it is a 'one chance' condition, and it is potentially repetitious in region definition.
By the way, there are at least three audience groups for which this use case exists: 1) Those who have reading difficulties with normal size text; 2) users of different devices, where it has been established that text needs to be rendered at different sizes on large screen televisions from smartphones for example; 3) those who just want to be able to customise the display.
It would be great if the condition construct could be used to allow some predefined viewing options to be authored into the document, i.e. in a controlled way by the document author. I can't see how this can be achieved at present though.
What solution choices are there? Perhaps the easiest is to redefine the condition construct so that it also includes an 'if then else if' syntax in which attributes can be defined, so you might end up with, for example:
Then xml:id rules are not broken and region r1 can be referenced safely with the attribute evaluation only being conditional. I'd advocate retaining the ability to specify a condition that can be used to exclude the entire element from semantic processing, as now.
Another solution to this problem might be to define some preprocessing using XPath to select specific elements and/or attributes and set values on the basis of the same condition functions that have already been specified, i.e. parameter, media, supports. Something like:
It would be an error for a path attribute to refer to anywhere except or or their descendants.
This option would also have the incidental effect that it would provide similar functionality to declarative styling. All the rules would be executed in document order prior to processing the . Preprocessing could of course also be performed externally to the document before processing, if a 'user style' is desirable (as is the case for any XML document) .
(raised by Nigel Megitt on 2015-01-16)
From tracker issue http://www.w3.org/AudioVideo/TT/tracker/issues/366
The text was updated successfully, but these errors were encountered: