You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2001/10/09 22:46:19 UTC

cvs commit: xml-xerces/c/src/validators/datatype NOTATIONDatatypeValidator.cpp

peiyongz    01/10/09 13:46:19

  Modified:    c/src/validators/datatype NOTATIONDatatypeValidator.cpp
  Log:
  NOTATION: checkContent(): <URI>:<localPart>
  
  Revision  Changes    Path
  1.8       +42 -4     xml-xerces/c/src/validators/datatype/NOTATIONDatatypeValidator.cpp
  
  Index: NOTATIONDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/datatype/NOTATIONDatatypeValidator.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NOTATIONDatatypeValidator.cpp	2001/10/02 18:59:29	1.7
  +++ NOTATIONDatatypeValidator.cpp	2001/10/09 20:46:19	1.8
  @@ -55,8 +55,11 @@
    */
   
   /*
  - * $Id: NOTATIONDatatypeValidator.cpp,v 1.7 2001/10/02 18:59:29 peiyongz Exp $
  + * $Id: NOTATIONDatatypeValidator.cpp,v 1.8 2001/10/09 20:46:19 peiyongz Exp $
    * $Log: NOTATIONDatatypeValidator.cpp,v $
  + * Revision 1.8  2001/10/09 20:46:19  peiyongz
  + * NOTATION: checkContent(): <URI>:<localPart>
  + *
    * Revision 1.7  2001/10/02 18:59:29  peiyongz
    * Invalid_Facet_Tag to display the tag name
    *
  @@ -82,6 +85,7 @@
   //  Includes
   // ---------------------------------------------------------------------------
   #include <validators/datatype/NOTATIONDatatypeValidator.hpp>
  +#include <util/XMLUri.hpp>
   #include <validators/datatype/InvalidDatatypeFacetException.hpp>
   #include <validators/datatype/InvalidDatatypeValueException.hpp>
   
  @@ -102,7 +106,7 @@
                           , const int                           finalSet)
   :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::NOTATION)
   {
  -    init(baseValidator, facets, enums);
  +    init(enums);
   }
   
   DatatypeValidator* NOTATIONDatatypeValidator::newInstance(
  @@ -136,9 +140,43 @@
   void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content)
   {
       //
  -    // check 3.2.19: QName
  +    //  NOTATATION: <URI>:<localPart>
  +    //  both URI and localPart must be present
       //
  -    if ( !XMLString::isValidQName(content))
  +    int contentLength = XMLString::stringLen(content);
  +    int colonPosition = XMLString::lastIndexOf(content, chColon);
  +
  +    if ((colonPosition == -1)                ||  // no ':'
  +        (colonPosition == 0 )                ||  // ':'<localPart>
  +        (colonPosition == contentLength - 1)  )  // <URI>':'
  +        ThrowXML1(InvalidDatatypeValueException
  +                , XMLExcepts::VALUE_NOTATION_Invalid
  +                , content);
  +
  +    // Extract URI
  +    XMLCh* uriPart = new XMLCh[colonPosition + 1];
  +    ArrayJanitor<XMLCh> jan1(uriPart);
  +    XMLString::subString(uriPart, content, 0, colonPosition - 1);
  +
  +    try 
  +    {
  +        // no relative uri support here
  +        XMLUri  *newURI = new XMLUri(uriPart);   
  +        delete newURI;
  +    }
  +    catch (...) 
  +    {
  +        ThrowXML1(InvalidDatatypeValueException
  +                , XMLExcepts::VALUE_NOTATION_Invalid
  +                , content);
  +    }
  +
  +    // Extract localpart
  +    XMLCh* localPart = new XMLCh[contentLength - colonPosition];
  +    ArrayJanitor<XMLCh> jan2(localPart);
  +    XMLString::subString(localPart, content, colonPosition + 1, contentLength - 1);
  +
  +    if ( !XMLString::isValidNCName(localPart))
       {
           ThrowXML1(InvalidDatatypeValueException
                   , XMLExcepts::VALUE_NOTATION_Invalid
  
  
  

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