dbertoni    01/02/10 21:18:14

  Modified:    c/src/XSLT ElemElement.cpp XSLTEngineImpl.cpp
  Log:
  Fixed some problems with namespace and xsl:element (namespace39 and namespace 
42).
  
  Revision  Changes    Path
  1.18      +14 -8     xml-xalan/c/src/XSLT/ElemElement.cpp
  
  Index: ElemElement.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemElement.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElemElement.cpp   2001/01/30 22:05:11     1.17
  +++ ElemElement.cpp   2001/02/11 05:18:12     1.18
  @@ -175,14 +175,18 @@
   
        m_nameAVT->evaluate(elemName, sourceNode, *this, executionContext);
   
  -     bool                                    isIllegalElement = false;
  +     bool                            isIllegalElement = false;
   
  -     unsigned int                    len = length(elemName);
  +     unsigned int            len = length(elemName);
   
  -     const unsigned int              indexOfNSSep = indexOf(elemName, 
XalanUnicode::charColon);
  +     const unsigned int      indexOfNSSep = indexOf(elemName, 
XalanUnicode::charColon);
   
  -     const bool                              haveNamespace = indexOfNSSep == 
len ? false : true;
  +     StylesheetExecutionContext::GetAndReleaseCachedString   
prefixGuard(executionContext);
   
  +     XalanDOMString&         prefix = prefixGuard.get();
  +
  +     const bool                      haveNamespace = indexOfNSSep == len ? 
false : true;
  +
        if(haveNamespace == true)
        {
                if (indexOfNSSep + 1 == len ||
  @@ -204,10 +208,6 @@
        }
        else if (haveNamespace == true)
        {
  -             StylesheetExecutionContext::GetAndReleaseCachedString   
prefixGuard(executionContext);
  -
  -             XalanDOMString&         prefix = prefixGuard.get();
  -
                prefix = substring(elemName, 0, indexOfNSSep);
   
                const XalanDOMString&   theNamespace = 
executionContext.getResultNamespaceForPrefix(prefix);
  @@ -251,6 +251,12 @@
                                if(indexOfNSSep == len)
                                {
                                        
executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace);
  +                             }
  +                             else
  +                             {
  +                                     insert(prefix, 0, 
DOMServices::s_XMLNamespaceWithSeparator);
  +
  +                                     
executionContext.addResultAttribute(prefix, elemNameSpace);
                                }
                        }
                }
  
  
  
  1.87      +45 -8     xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
  
  Index: XSLTEngineImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- XSLTEngineImpl.cpp        2001/02/09 19:22:32     1.86
  +++ XSLTEngineImpl.cpp        2001/02/11 05:18:13     1.87
  @@ -1493,19 +1493,56 @@
                        const XalanDOMString&   aname,
                        const XalanDOMString&   value)
   {
  -     const bool      isPrefix = startsWith(aname, 
DOMServices::s_XMLNamespaceWithSeparator);
  +     bool    fExcludeAttribute = false;
   
  -     if (equals(aname, DOMServices::s_XMLNamespace) || isPrefix == true) 
  +     if (equals(aname, DOMServices::s_XMLNamespace)) 
        {
  -             const XalanDOMString    p = isPrefix == true ? substring(aname, 
6) : XalanDOMString();
  +             // OK, we're adding a default namespace declaration.  So see if 
the length
  +             // of the namespace is 0.  If it's not, go ahead and add the 
declaration.
  +             // If it's not, it means we're "turning off" the previous 
default
  +             // declaration.
  +             if (length(value) != 0)
  +             {
  +                     addResultNamespaceDecl(s_emptyString, value);
  +             }
  +             else
  +             {
  +                     // OK, we're turning of the previous default namespace 
declaration.
  +                     // Check to see if there is one, and if there isn't, 
don't add
  +                     // the namespace declaration _and_ don't add the 
attribute.
  +                     const XalanDOMString&   currentDefaultNamespace =
  +                                     
getNamespaceForPrefix(DOMServices::s_XMLNamespace);
   
  -             addResultNamespaceDecl(p, value);
  +                     if (length(currentDefaultNamespace) != 0)
  +                     {
  +                             addResultNamespaceDecl(s_emptyString, value);
  +                     }
  +                     else
  +                     {
  +                             fExcludeAttribute = true;
  +                     }
  +             }
        }
  +     else if (startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator) == 
true)
  +     {
  +             assert(m_executionContext != 0);
  +
  +             StylesheetExecutionContext::GetAndReleaseCachedString   
prefixGuard(*m_executionContext);
  +
  +             XalanDOMString&         prefix = prefixGuard.get();
  +
  +             prefix = substring(aname, 
DOMServices::s_XMLNamespaceWithSeparatorLength);
   
  -     attList.addAttribute(
  -             c_wstr(aname),
  -             c_wstr(Constants::ATTRTYPE_CDATA),
  -             c_wstr(value));
  +             addResultNamespaceDecl(prefix, value);
  +     }
  +
  +     if (fExcludeAttribute == false)
  +     {
  +             attList.addAttribute(
  +                     c_wstr(aname),
  +                     c_wstr(Constants::ATTRTYPE_CDATA),
  +                     c_wstr(value));
  +     }
   }
   
   
  
  
  

Reply via email to