Re: [xml] Localizing the validation messages
- From: Patrick <patrick hapax qc ca>
- To: veillard redhat com
- Cc: xml gnome org
- Subject: Re: [xml] Localizing the validation messages
- Date: Fri, 09 Nov 2012 19:29:28 -0500
Daniel,
   I'm not sure that the structured error handler (as I understand it) 
gives me everything I need to implement easily localization.
    The XML Validation messages generated are frequently made up of 
several potential parts :
            * a prefix giving the content, for instance "Element 'a':"
            * an error message, e.g. "Missing child element(s)."
            * a  suffix with expected values, for example : Expected is 
( c ).
    The xmlError structure contains the full (with prefix and suffix)  
English message in the message field. The way I understand it, the code 
field corresponds to the central part of the message (1871 = Missing 
child element(s)").
    In some cases, if I understand it properly, the code may correspond 
to various messages: 1871 (XML_SCHEMAV_ELEMENT_CONTENT) seems to be 
associated to "Missing child element(s)" or "This element is not 
expected"... It looks like some codes correspond to messages with 
variables parts (SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, "The attribute '%s' is 
not allowed").
    Is there any way to get a unique error code that corresponds to a 
single string? In other words, an error code that specifies "Missing 
child element(s)"  and another for "This element is not expected"?
    Is there a way to get a separate code/message number that 
corresponds to the prefix (Element/Attribute) and another one specifying 
the suffix (expected list)?
    Does the structured error handler give access to the parameters 
corresponding to a given error code (for the prefix, central and suffix 
parts)? For example, for SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, where do I get 
the attribute value (without parsing the English message)?
    The way I see it, the localization layer (above libxml2) 
would/should simply replace the message (The attribute 'b' is not 
allowed) using for instance its error code 
(SCHEMAV_CVC_COMPLEX_TYPE_3_2_1) to index a localized file and then 
inject the parameters into the said translated string ("L'attribut '%s' 
n'est pas permis").
P. A.
  You can localize on top of libxml2.
The structured error handler should give you everything you need
to implement your own localization.
I'm not sure I want to do this in libxml2, due to dependencies,
portability and the fact that it's a developper toolkit, not the
right level to emit user level messages.
Daniel
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]