dbertoni    2003/08/21 17:47:48

  Modified:    c/src/xalanc/XPath XalanQName.cpp XalanQName.hpp
                        XalanQNameByValue.cpp XalanQNameByValue.hpp
  Log:
  Cleaned up glitches.
  
  Revision  Changes    Path
  1.2       +53 -1     xml-xalan/c/src/xalanc/XPath/XalanQName.cpp
  
  Index: XalanQName.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XalanQName.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanQName.cpp    29 Jun 2003 03:58:01 -0000      1.1
  +++ XalanQName.cpp    22 Aug 2003 00:47:48 -0000      1.2
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -354,6 +354,58 @@
                return XalanQName::isValidNCName(thePrefix, theIndex) &&
                           XalanQName::isValidNCName(theLocalName, theLength - 
theIndex - 1);
        }
  +}
  +
  +
  +
  +XalanQName::InvalidQNameException::InvalidQNameException(
  +                     const XalanDOMChar*                     theQName,
  +                     XalanDOMString::size_type       theQNameLength,
  +                     const XalanDOMString&           theURI,
  +                     int                                                     
theLineNumber,
  +                     int                                                     
theColumnNumber) :
  +     XSLException(format(theQName, theQNameLength), theURI, theLineNumber, 
theColumnNumber, XalanDOMString("InvalidQNameException"))
  +{
  +}
  +
  +
  +
  +XalanQName::InvalidQNameException::InvalidQNameException(
  +                     const LocatorType&                      theLocator,
  +                     const XalanDOMChar*                     theQName,
  +                     XalanDOMString::size_type       theQNameLength) :
  +     XSLException(theLocator, format(theQName, theQNameLength), 
XalanDOMString("InvalidQNameException"))
  +{
  +}
  +
  +
  +
  +XalanQName::InvalidQNameException::InvalidQNameException(
  +                     const XalanDOMChar*                     theQName,
  +                     XalanDOMString::size_type       theQNameLength) :
  +     XSLException(format(theQName, theQNameLength), 
XalanDOMString("InvalidQNameException"))
  +{
  +}
  +
  +
  +
  +XalanQName::InvalidQNameException::~InvalidQNameException()
  +{
  +}
  +
  +
  +
  +const XalanDOMString
  +XalanQName::InvalidQNameException::format(
  +                     const XalanDOMChar*                     theQName,
  +                     XalanDOMString::size_type       theQNameLength)
  +{
  +     XalanDOMString  theResult("'");
  +
  +     theResult.append(theQName, theQNameLength);
  +     theResult += XalanDOMString("' is not a valid QName");
  +
  +     return theResult;
   }
   
   
  
  
  
  1.2       +58 -1     xml-xalan/c/src/xalanc/XPath/XalanQName.hpp
  
  Index: XalanQName.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XalanQName.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanQName.hpp    29 Jun 2003 03:58:01 -0000      1.1
  +++ XalanQName.hpp    22 Aug 2003 00:47:48 -0000      1.2
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -74,6 +74,7 @@
   
   #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
   #include <xalanc/PlatformSupport/PrefixResolver.hpp>
  +#include <xalanc/PlatformSupport/XSLException.hpp>
   
   
   
  @@ -350,6 +351,62 @@
        isValidQName(
                        const XalanDOMChar*                     theQName,
                        XalanDOMString::size_type       theLength = 
XalanDOMString::npos);
  +
  +     class InvalidQNameException : public XSLException
  +     {
  +     public:
  +
  +             /**
  +              * Constructor
  +              * 
  +              * @param theQName The QName string that is not valid.
  +              * @param theQNameLength The length of the string.
  +              * @param theURI the URI of the related document, if known
  +              * @param theLineNumber the line number of the related document.
  +              * @param theColumnNumber the column number of the related document.
  +              * @param theType type of exception, default is "XSLException"
  +              */
  +             InvalidQNameException(
  +                             const XalanDOMChar*                     theQName,
  +                             XalanDOMString::size_type       theQNameLength,
  +                             const XalanDOMString&           theURI,
  +                             int                                                    
 theLineNumber,
  +                             int                                                    
 theColumnNumber);
  +
  +             /**
  +              * Constructor
  +              * 
  +              * @param theLocator The locator instance for error reporting.
  +              * @param theQName The QName string that is not valid.
  +              * @param theQNameLength The length of the string.
  +              * @param theType type of exception, default is "XSLException"
  +              */
  +             InvalidQNameException(
  +                             const LocatorType&                      theLocator,
  +                             const XalanDOMChar*                     theQName,
  +                             XalanDOMString::size_type       theQNameLength);
  +
  +             /**
  +              * Constructor
  +              * 
  +              * @param theQName The QName string that is not valid.
  +              * @param theQNameLength The length of the string.
  +              * @param theType type of exception, default is "XSLException"
  +              */
  +             InvalidQNameException(
  +                             const XalanDOMChar*                     theQName,
  +                             XalanDOMString::size_type       theQNameLength);
  +
  +             virtual
  +             ~InvalidQNameException();
  +
  +     private:
  +
  +             static const XalanDOMString
  +             format(
  +                             const XalanDOMChar*                     theQName,
  +                             XalanDOMString::size_type       theQNameLength);
  +     };
   
   protected:
   
  
  
  
  1.2       +44 -10    xml-xalan/c/src/xalanc/XPath/XalanQNameByValue.cpp
  
  Index: XalanQNameByValue.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XalanQNameByValue.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanQNameByValue.cpp     29 Jun 2003 03:58:01 -0000      1.1
  +++ XalanQNameByValue.cpp     22 Aug 2003 00:47:48 -0000      1.2
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -319,9 +319,15 @@
   
                m_localpart.assign(qname, indexOfNSSep);
   
  -             if(m_localpart == DOMServices::s_XMLNamespace)
  +             if(m_localpart == DOMServices::s_XMLString)
  +             {
  +                     m_namespace = DOMServices::s_XMLNamespaceURI;
  +             }
  +             else if(m_localpart == DOMServices::s_XMLNamespace)
                {
  -                     m_localpart.clear();
  +                     // The xmlns prefix is not normally bound to a namespace URI, 
but we're really trying
  +                     // to form a QName, so we'll do what the DOM does...
  +                     m_namespace = DOMServices::s_XMLNamespacePrefixURI;
                }
                else
                {
  @@ -338,9 +344,9 @@
                        {
                                m_namespace = *theNamespace;
                        }
  -
  -                     m_localpart.assign(qname + indexOfNSSep + 1);
                }
  +
  +             m_localpart.assign(qname + indexOfNSSep + 1, len - (indexOfNSSep + 1));
        }
        else
        {
  @@ -361,6 +367,8 @@
   
                m_localpart = qname;
        }
  +
  +     validate(qname, len, locator);
   }
   
   
  @@ -374,7 +382,11 @@
   {
        const XalanDOMString::size_type         indexOfNSSep = indexOf(qname, 
XalanUnicode::charColon);
   
  -     if(indexOfNSSep >= theLength)
  +     if (indexOfNSSep == 0)
  +     {
  +             throwException(TranscodeFromLocalCodePage("A prefix of length 0 was 
detected"), locator);
  +     }
  +     else if(indexOfNSSep >= theLength)
        {
                m_localpart.assign(qname, theLength);
   
  @@ -392,12 +404,11 @@
                {
                        m_namespace = DOMServices::s_XMLNamespaceURI;
                }
  -             // The default namespace is not resolved.
                else if(m_localpart == DOMServices::s_XMLNamespace)
                {
  -                     m_localpart.clear();
  -
  -                     return;
  +                     // The xmlns prefix is not normally bound to a namespace URI, 
but we're really trying
  +                     // to form a QName, so we'll do what the DOM does...
  +                     m_namespace = DOMServices::s_XMLNamespacePrefixURI;
                }
                else if (theResolver == 0)
                {
  @@ -429,8 +440,31 @@
   
                m_localpart.assign(qname + indexOfNSSep + 1, theLength - (indexOfNSSep 
+ 1));
        }
  +
  +     validate(qname, theLength, locator);
   }
   
   
   
  +void
  +XalanQNameByValue::validate(
  +                     const XalanDOMChar*                     qname,
  +                     XalanDOMString::size_type       theLength,
  +                     const LocatorType*                      locator)
  +{
  +     if (isValid() == false)
  +     {
  +             if (locator != 0)
  +             {
  +                     throw InvalidQNameException(*locator, qname, theLength);
  +             }
  +             else
  +             {
  +                     throw InvalidQNameException(qname, theLength);
  +             }
  +     }
  +}
  +
  +
  +     
   XALAN_CPP_NAMESPACE_END
  
  
  
  1.2       +5 -0      xml-xalan/c/src/xalanc/XPath/XalanQNameByValue.hpp
  
  Index: XalanQNameByValue.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XalanQNameByValue.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanQNameByValue.hpp     29 Jun 2003 03:58:01 -0000      1.1
  +++ XalanQNameByValue.hpp     22 Aug 2003 00:47:48 -0000      1.2
  @@ -327,6 +327,11 @@
                        const PrefixResolver*           theResolver,
                        const LocatorType*                      locator);
   
  +     void
  +     validate(
  +                     const XalanDOMChar*                     qname,
  +                     XalanDOMString::size_type       theLength,
  +                     const LocatorType*                      locator);
   
        // Data members...
        XalanDOMString  m_namespace;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to