[xml] Error report with RelaxNG




Hi, I'm using RelaxNG python binding with 2.6.17,
many errors are quite understandable (I mean for
human being), but now I've got an empty result
on the following error:

I've got an enumerate, the actual value in the XML
file has a typo on one of the enumerates. However, the
lastError function returns None, as if there was no
information about this enumerate error (again, many other
errors are correctly reported).

The grammar is :

DimensionalUnits_t = element DimensionalUnits_t 
{
 attribute   Name             {xsd:string "DimensionalUnits"},
 ( attribute MassUnits        {MassUnits_t}         
 & attribute LengthUnits      {LengthUnits_t}       
 & attribute TimeUnits        {TimeUnits_t}         
 & attribute TemperatureUnits {TemperatureUnits_t}  
 & attribute AngleUnits       {AngleUnits_t}
 )
}
   
MassUnits_t =
 "Null"          | 
 "Kilogram"      |
 "Gram"          |
 "Slug"          |
 "PoundMass"     |
 "UserDefined"
    
LengthUnits_t =
 "Null"          |
 "Meter"         |
 "Centimeter"    |
 "Millimeter"    |
 "Foot"          | 
 "Inch"          | 
 "UserDefined"
    
TimeUnits_t = 
 "Null"          | 
 "Second"        |
 "UserDefined" 
  
TemperatureUnits_t =
 "Null"          |
 "Kelvin"        | 
 "Celsius"       | 
 "Rankine"       | 
 "Fahrenheit"    | 
 "UserDefined"
    
AngleUnits_t =
 "Null"          | 
 "Degree"        | 
 "Radian"        |
 "UserDefined" 

The file is (Typo in "Kelvin"):

<?xml version="1.0"?>
<CGNSTree CGNSLibraryVersion="2.3">
  <CGNSBase_t Name="Test Structure" 
              PhysicalDimension="3" 
              CellDimension="3" 
              DataClass="Dimensional">
   <DimensionalUnits_t 
    Name="DimensionalUnits" 
    MassUnits="Kilogram" 
    LengthUnits="Meter" 
    TimeUnits="Second" 
    TemperatureUnits="Kalvin" 
    AngleUnits="Degree"/>
  </CGNSBase_t>
</CGNSTree>

The returned error code is None for a level of "severe".

The Python code of the error function (set with reagisterErrorHandler):

def cgnsParseError(localcontext,unused):
  e = libxml2.lastError()
  lfs=""
  if e.file():
    tf=open(e.file())
    ltf=tf.readlines()
    tf.close()
    lfs=ltf[e.line()-1]
    
  _diag=["Info","Warning","Severe","Fatal"]
  ustf.error(99,"[%s] near line %d in %s\nPhase: %s\nDiagnostic:\n%s\n"\
        %(_diag[e.level()],e.line(),e.file(),localcontext,e.message()),kill=0)
  if lfs: print lfs
  if (e.level() > 1):
    ustf.c5exit() # fails with None return (loop ?)

Any idea ?

-MP-
-----------------------------------------------------------------------
 Marc POINOT             Alias: marcvs        Email: poinot onera fr
 ONERA -MFE/DSNA/ELSA    Tel: 01.46.73.42.84  Info: elsa-info onera fr
 29, Div. Leclerc        Fax: 01.46.73.41.66  Site:     
 92322 Chatillon FRANCE  Project: elsA        Web: http://www.onera.fr



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]