xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r803121 - /xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
Date Tue, 11 Aug 2009 13:52:11 GMT
Author: amassari
Date: Tue Aug 11 13:52:10 2009
New Revision: 803121

URL: http://svn.apache.org/viewvc?rev=803121&view=rev
Log:
When validating an annotation, report the location of the error in the source schema, not
inside the annotation itself

Modified:
    xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp

Modified: xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp?rev=803121&r1=803120&r2=803121&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp Tue Aug 11 13:52:10 2009
@@ -9158,6 +9158,46 @@
     return annot;
 }
 
+class AnnotationErrorReporter : public XMLErrorReporter
+{
+public:
+    AnnotationErrorReporter(XMLErrorReporter* chainedErrorReporter)
+    {
+        fErrorReporter = chainedErrorReporter;
+        setSystemIdAndPosition(NULL, 0, 0);
+    }
+
+    void setSystemIdAndPosition(const XMLCh* systemId, XMLFileLoc line, XMLFileLoc column)
+    {
+        fSystemId=systemId;
+        fLine=line;
+        fColumn=column;
+    }
+
+    virtual void error
+    (
+        const   unsigned int        errCode
+        , const XMLCh* const        errDomain
+        , const ErrTypes            type
+        , const XMLCh* const        errorText
+        , const XMLCh* const        systemId
+        , const XMLCh* const        publicId
+        , const XMLFileLoc          lineNum
+        , const XMLFileLoc          colNum
+    )
+    {
+        if(fErrorReporter)
+            fErrorReporter->error(errCode, errDomain, type, errorText, fSystemId, publicId,
fLine+lineNum-1, lineNum==1?fColumn+colNum:colNum);
+    }
+
+    virtual void resetErrors() {}
+
+protected:
+    XMLErrorReporter*   fErrorReporter;
+    const XMLCh*        fSystemId;
+    XMLFileLoc          fLine, fColumn;
+};
+
 void TraverseSchema::validateAnnotations() {
 
     MemoryManager  *memMgr = fMemoryManager;
@@ -9279,8 +9319,12 @@
     );
     Janitor<XSAXMLScanner> janScanner(scanner);
 
-    scanner->setErrorReporter(fErrorReporter);
+    AnnotationErrorReporter annErrReporter(fErrorReporter);
+    scanner->setErrorReporter(&annErrReporter);
 
+    XMLFileLoc line, col;
+    xsAnnot.getLineCol(line, col);
+    annErrReporter.setSystemIdAndPosition(xsAnnot.getSystemId(), line, col);
     scanner->scanDocument(*memBufIS);
 
     nextAnnot = xsAnnot.getNext();
@@ -9290,12 +9334,16 @@
         if (nextAnnot) {
             memBufIS->resetMemBufInputSource((const XMLByte*)nextAnnot->getAnnotationString()
                                         , XMLString::stringLen(nextAnnot->getAnnotationString())*sizeof(XMLCh));
+            nextAnnot->getLineCol(line, col);
+            annErrReporter.setSystemIdAndPosition(nextAnnot->getSystemId(), line, col);
             nextAnnot = nextAnnot->getNext();
         }
         else {
             XSAnnotation& xsAnnot = xsAnnotationEnum.nextElement();
             memBufIS->resetMemBufInputSource((const XMLByte*)xsAnnot.getAnnotationString()
                                         , XMLString::stringLen(xsAnnot.getAnnotationString())*sizeof(XMLCh));
+            xsAnnot.getLineCol(line, col);
+            annErrReporter.setSystemIdAndPosition(xsAnnot.getSystemId(), line, col);
             nextAnnot = xsAnnot.getNext();
         }
         scanner->scanDocument(*memBufIS);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org


Mime
View raw message