-
Notifications
You must be signed in to change notification settings - Fork 5
Description
XVRL give the error-code of the "detection" which quite usefull.
But when you want to rewrite the message itself for user's convenience, you'll need to use regex (or so) to isolate parts of the message.
For example:
<detection code="invalid_attribute_value">
<message xml:lang="en">value of attribute "class" is invalid; must be equal to 'foo' or 'bar'</message>
</detection>Let's say in my specific project class attribute is special and represent element's name (I do this in real life :)), so I would like to change the message to:
This element should not appear here, element 'foo' or 'bar' expected here"
To be able to perform this translation, I could use regex and isolate parts of the message ("class", "foo" and "bar"). And I would need to rely on the english message here, hoping it will not depends on implementation.
When the message comes from a Relax NG validation with Jing, the message are computed using a this Messages.properties file (other languages translations here).
In my exemple case, it uses this lines:
invalid_attribute_value=value of attribute {0} is invalid{1}
require_values=must be equal to {0}
I don't know exactly how to represent this in XVRL so it make my translation safer (no regex) and less implementation dependent.
Maybe something like:
<detection code="invalid_attribute_value" arg-0="class" arg-1="'foo' or 'bar'">
<message xml:lang="en">value of attribute {0} is invalid; must be equal to {1}</message>
</detection>Or something like:
<detection code="invalid_attribute_value">
<message xml:lang="en">value of attribute <var name="invalid_attribute-name">class</var> is invalid; must be equal to '<var name="require_value">foo</var>' or '<var name="require_value">bar</var>'</message>
</detection>One last thing to reach my need in my real project would be to have information one each var:
-
<var name="invalid_attribute-name">would need information on the real parent element such as<div class="bad-class" data-label="label">, so I can use the data-label in my message
Maybe I can get this information from another XVRL element like<context> -
<var name="require_value">would need information of the schema such as thedefinename:<var name="require_value" rng-schema-element-define="foo-element">
I now it's a lot of thing here, but as it's a need I have in my real project, I thought it was good to say all :) and open the discussion !