dbertoni    01/07/17 21:21:41

  Modified:    c/src/XalanSourceTree XalanSourceTreeDocument.hpp
                        XalanSourceTreeDocument.cpp
  Log:
  Fixed bug with creating elements in the default namespace.
  
  Revision  Changes    Path
  1.10      +2 -1      
xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.hpp
  
  Index: XalanSourceTreeDocument.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XalanSourceTreeDocument.hpp       2001/05/14 00:59:54     1.9
  +++ XalanSourceTreeDocument.hpp       2001/07/18 04:21:41     1.10
  @@ -461,7 +461,8 @@
        getNamespaceForPrefix(
                        const XalanDOMChar*             theName,
                        const PrefixResolver&   thePrefixResolver,
  -                     XalanDOMString&                 thePrefix);
  +                     XalanDOMString&                 thePrefix,
  +                     bool                                    fUseDefault);
   
        // Not implemented...
        XalanSourceTreeDocument(const XalanSourceTreeDocument&  theSource);
  
  
  
  1.18      +44 -12    
xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.cpp
  
  Index: XalanSourceTreeDocument.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XalanSourceTreeDocument.cpp       2001/06/29 18:44:25     1.17
  +++ XalanSourceTreeDocument.cpp       2001/07/18 04:21:41     1.18
  @@ -828,25 +828,33 @@
   XalanSourceTreeDocument::getNamespaceForPrefix(
                        const XalanDOMChar*             theName,
                        const PrefixResolver&   thePrefixResolver,
  -                     XalanDOMString&                 thePrefix)
  +                     XalanDOMString&                 thePrefix,
  +                     bool                                    fUseDefault)
   {
        const unsigned int      theLength = length(theName);
        const unsigned int      theColonIndex = indexOf(theName, 
XalanUnicode::charColon);
   
  -     if (theColonIndex == theLength)
  +     if (theColonIndex != theLength)
        {
  -             clear(thePrefix);
  -
  -             return thePrefixResolver.getNamespaceForPrefix(s_emptyString);
  -     }
  -     else
  -     {
                // Get the prefix from theName...
                assign(thePrefix, theName, theColonIndex);
                assert(length(thePrefix) != 0);
   
                return thePrefixResolver.getNamespaceForPrefix(thePrefix);
        }
  +     else
  +     {
  +             clear(thePrefix);
  +
  +             if (fUseDefault == false)
  +             {
  +                     return 0;
  +             }
  +             else
  +             {
  +                     return 
thePrefixResolver.getNamespaceForPrefix(s_emptyString);
  +             }
  +     }
   }
   
   
  @@ -942,9 +950,18 @@
                        XalanSourceTreeElement*         theOwnerElement,
                        const PrefixResolver&           thePrefixResolver)
   {
  +     // Get the namespace for the theName.  Since attributes do not use
  +     // the default namespace, make sure we don't get it...
        const XalanDOMString* const             theNamespace =
  -             getNamespaceForPrefix(theName, thePrefixResolver, 
m_stringBuffer);
  +             getNamespaceForPrefix(
  +                             theName,
  +                             thePrefixResolver,
  +                             m_stringBuffer,
  +                             false);
   
  +     assert(theNamespace == 0 && length(m_stringBuffer) == 0 ||
  +                theNamespace != 0 && length(m_stringBuffer) != 0);
  +
        if (theNamespace == 0 || length(*theNamespace) == 0)
        {
                return m_attributeAllocator.create(
  @@ -955,6 +972,9 @@
        }
        else
        {
  +             // There must be a prefix, so we don't have to check to see if
  +             // we got one...
  +
                // The constructor parameters for AttrNS are:
                //
                // name
  @@ -990,7 +1010,11 @@
                        const PrefixResolver&           thePrefixResolver)
   {
        const XalanDOMString* const             theNamespace =
  -             getNamespaceForPrefix(theTagName, thePrefixResolver, 
m_stringBuffer);
  +             getNamespaceForPrefix(
  +                             theTagName,
  +                             thePrefixResolver,
  +                             m_stringBuffer,
  +                             true);
   
        if (theNamespace == 0 || length(*theNamespace) == 0)
        {
  @@ -1009,6 +1033,15 @@
        }
        else
        {
  +             // We need figure out if there's a prefix on theTagName.  If 
not,
  +             // the local name is the same as the tag name.  Otherwise, we 
need
  +             // to remove the prefix and the ':' that separates them.  If
  +             // m_stringBuffer is of length 0, there's no prefix.
  +             const unsigned int                      thePrefixLength = 
length(m_stringBuffer);
  +
  +             const XalanDOMChar* const       theLocalName =
  +                     thePrefixLength == 0 ? theTagName : theTagName + 
thePrefixLength + 1;
  +
                // The constructor parameters for ElementNS are:
                //
                // tag name
  @@ -1025,9 +1058,8 @@
                //
                return m_elementNSAllocator.create(
                                m_namesStringPool.get(theTagName),
  -                             m_namesStringPool.get(theTagName + 
length(m_stringBuffer) + 1),
  +                             m_namesStringPool.get(theLocalName),
                                m_namesStringPool.get(*theNamespace),
  -                             // This is the prefix...
                                m_namesStringPool.get(m_stringBuffer),
                                this,
                                theAttributeVector,
  
  
  

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

Reply via email to