xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbert...@apache.org
Subject cvs commit: xml-xalan/c/src/xalanc/XSLT ElemTemplateElement.cpp StylesheetExecutionContextDefault.hpp XSLTEngineImpl.cpp XSLTEngineImpl.hpp
Date Fri, 07 Oct 2005 22:49:52 GMT
dbertoni    2005/10/07 15:49:52

  Modified:    c/src/xalanc/XSLT ElemTemplateElement.cpp
                        StylesheetExecutionContextDefault.hpp
                        XSLTEngineImpl.cpp XSLTEngineImpl.hpp
  Log:
  Fixes for XALANC-554.
  
  Revision  Changes    Path
  1.28      +20 -23    xml-xalan/c/src/xalanc/XSLT/ElemTemplateElement.cpp
  
  Index: ElemTemplateElement.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemTemplateElement.cpp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ElemTemplateElement.cpp	2 May 2005 19:11:39 -0000	1.27
  +++ ElemTemplateElement.cpp	7 Oct 2005 22:49:52 -0000	1.28
  @@ -1460,37 +1460,34 @@
   {
       const XalanDOMString*   nameSpace = 0;
   
  -    if (isEmpty(prefix) == false)
  +    if(getFinishedConstruction() == false)
       {
  -        if(getFinishedConstruction() == true)
  +        nameSpace = getStylesheet().getNamespaceForPrefixFromStack(prefix);
  +    }
  +    else
  +    {
  +        if (equals(prefix, DOMServices::s_XMLString) == true)
           {
  -            if (equals(prefix, DOMServices::s_XMLString) == true)
  -            {
  -                nameSpace = &DOMServices::s_XMLNamespaceURI;
  -            }
  -            else
  +            nameSpace = &DOMServices::s_XMLNamespaceURI;
  +        }
  +        else
  +        {
  +            nameSpace = getNamespacesHandler().getNamespace(prefix);
  +
  +            if(nameSpace == 0)
               {
  -                nameSpace = getNamespacesHandler().getNamespace(prefix);
  +                if (m_parentNode != 0)
  +                {
  +                    nameSpace = m_parentNode->getNamespaceForPrefixInternal(prefix);
  +                }
   
  -                if(nameSpace == 0)
  +                // Try one last time with the stylesheet...
  +                if (nameSpace == 0)
                   {
  -                    if (m_parentNode != 0)
  -                    {
  -                        nameSpace = m_parentNode->getNamespaceForPrefixInternal(prefix);
  -                    }
  -
  -                    // Try one last time with the stylesheet...
  -                    if (nameSpace == 0)
  -                    {
  -                        nameSpace = getStylesheet().getNamespaceForPrefix(prefix);
  -                    }
  +                   nameSpace = getStylesheet().getNamespaceForPrefix(prefix);
                   }
               }
           }
  -        else
  -        {
  -            nameSpace = getStylesheet().getNamespaceForPrefixFromStack(prefix);
  -        }
       }
   
       return nameSpace;
  
  
  
  1.40      +12 -2     xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- StylesheetExecutionContextDefault.hpp	18 Aug 2005 05:11:45 -0000	1.39
  +++ StylesheetExecutionContextDefault.hpp	7 Oct 2005 22:49:52 -0000	1.40
  @@ -1170,9 +1170,8 @@
       FormatterToSourceTreeCacheType      m_formatterToSourceTreeCache;
   
       NodeSorterCacheType                 m_nodeSorterCache;
  -#endif
  +#else
   
  -#if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
       class FormatterToTextDOMString : public FormatterToText
       {
       public:
  @@ -1190,6 +1189,17 @@
   
       private:
   
  +        // These are not defined...
  +        FormatterToTextDOMString(const FormatterToTextDOMString&);
  +
  +        FormatterToTextDOMString&
  +        operator=(const FormatterToTextDOMString&);
  +
  +        bool
  +        operator==(const FormatterToTextDOMString&) const;
  +
  +
  +        // Data members...
           DOMStringPrintWriter    m_printWriter;
   
           static XalanDOMString   s_dummyString;
  
  
  
  1.32      +76 -18    xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.cpp
  
  Index: XSLTEngineImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.cpp,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- XSLTEngineImpl.cpp	30 Jun 2005 23:35:43 -0000	1.31
  +++ XSLTEngineImpl.cpp	7 Oct 2005 22:49:52 -0000	1.32
  @@ -652,8 +652,6 @@
       const XalanDOMString::size_type     fragIndex =
           indexOf(localXSLURLString, XalanUnicode::charNumberSign);
   
  -    const XalanDocument*    stylesheetDoc = 0;
  -
       if(fragIndex == 0)
       {
           const CCGetAndReleaseCachedString theGuard(constructionContext);
  @@ -820,8 +818,6 @@
           }
           else
           {
  -            stylesheetDoc = 0;
  -
               const CCGetAndReleaseCachedString theGuard(constructionContext);
   
               error(
  @@ -1370,7 +1366,10 @@
   XSLTEngineImpl::addResultAttribute(
               AttributeListImpl&          attList,
               const XalanDOMString&       aname,
  -            const XalanDOMChar*         value)
  +            const XalanDOMChar*         value,
  +            XalanDOMString::size_type   theLength,
  +            bool                        fromCopy,
  +			const LocatorType*	        locator)
   {
       assert(value != 0);
   
  @@ -1389,8 +1388,6 @@
               const XalanDOMString* const     currentDefaultNamespace =
                           getNamespaceForPrefix(s_emptyString);
   
  -            const XalanDOMString::size_type     theLength = length(value);
  -
               // Note that we use an empty string for the prefix, instead of "xmlns", since
the
               // prefix really is "".
               if (theLength != 0)
  @@ -1398,11 +1395,19 @@
                   if (currentDefaultNamespace != 0 &&
                       equals(*currentDefaultNamespace, value, theLength) == true)
                   {
  -                    fExcludeAttribute = true;
  +                        fExcludeAttribute = true;
                   }
                   else
                   {
  -                    addResultNamespaceDecl(s_emptyString, value, theLength);
  +                    if (fromCopy == false /* ||
  +                        m_resultNamespacesStack.prefixIsPresentLocal(s_emptyString) ==
false */)
  +                    {
  +                        addResultNamespaceDecl(s_emptyString, value, theLength);
  +                    }
  +                    else
  +                    {
  +                        reportDuplicateNamespaceNodeError(s_emptyString, locator);
  +                    }
                   }
               }
               else
  @@ -1434,10 +1439,22 @@
   
               const XalanDOMString::size_type     theLength = length(value);
   
  -            if (theNamespace == 0 || equals(*theNamespace, value, theLength) == false)
  +            if (theNamespace == 0)
               {
                   addResultNamespaceDecl(prefix, value, theLength);
               }
  +            else if (equals(*theNamespace, value, theLength) == false)
  +            {
  +                if (fromCopy == false /* ||
  +                    m_resultNamespacesStack.prefixIsPresentLocal(prefix) == false */)
  +                {
  +                    addResultNamespaceDecl(prefix, value, theLength);
  +                }
  +                else
  +                {
  +                    reportDuplicateNamespaceNodeError(prefix, locator);
  +                }
  +            }
               else
               {
                   fExcludeAttribute = true;
  @@ -1456,6 +1473,44 @@
   
   
   
  +void
  +XSLTEngineImpl::reportDuplicateNamespaceNodeError(
  +            const XalanDOMString&   theName,
  +            const LocatorType*      locator)
  +{
  +    assert(m_executionContext != 0);
  +
  +    const ECGetAndReleaseCachedString   theGuard(*m_executionContext);
  +
  +    XalanDOMString&     theMessage =
  +            theGuard.get();
  +
  +    if (theName.length() == 0)
  +    {
  +        XalanMessageLoader::getMessage(
  +            theMessage,
  +            XalanMessages::ErrorCopyingNamespaceNodeForDefault);
  +    }
  +    else
  +    {
  +        XalanMessageLoader::getMessage(
  +            theMessage,
  +            XalanMessages::ErrorCopyingNamespaceNode_1Param,
  +            theName);
  +    }
  +
  +    if (locator != 0)
  +    {
  +        error(theMessage, *locator);
  +    }
  +    else
  +    {
  +        error(theMessage);
  +    }
  +}
  +
  +
  +
   bool
   XSLTEngineImpl::pendingAttributesHasDefaultNS() const
   {
  @@ -1894,6 +1949,7 @@
   }
   
   
  +
   void
   XSLTEngineImpl::entityReference(const XalanDOMChar*     name)
   {
  @@ -1958,7 +2014,7 @@
           // will also "turn-off" the default namespace, if necessary.
           if (theResultNamespace != 0 && theElementNamespaceURI != *theResultNamespace)
           {
  -            addResultAttribute(DOMServices::s_XMLNamespace, theElementNamespaceURI);
  +            addResultAttribute(DOMServices::s_XMLNamespace, theElementNamespaceURI, false,
0);
           }
       }
   }
  @@ -1972,7 +2028,7 @@
   {
       assert(m_executionContext != 0);
   
  -    ECGetAndReleaseCachedString     theGuard(*m_executionContext);
  +    const ECGetAndReleaseCachedString   theGuard(*m_executionContext);
   
       const XalanDOMString&   theMessage =
           XalanMessageLoader::getMessage(
  @@ -2191,7 +2247,9 @@
                   addResultAttribute(
                           getPendingAttributesImpl(),
                           node.getNodeName(),
  -                        node.getNodeValue());
  +                        node.getNodeValue(),
  +                        true,
  +                        locator);
               }
               else
               {
  @@ -2502,10 +2560,10 @@
           }
           else
           {
  -            typedef const ECGetAndReleaseCachedString   GetAndReleaseCachedString;
  +            typedef ECGetAndReleaseCachedString     GetAndReleaseCachedString;
   
  -            GetAndReleaseCachedString   elemLocalNameGuard(*m_executionContext);
  -            GetAndReleaseCachedString   prefixGuard(*m_executionContext);
  +            const GetAndReleaseCachedString     elemLocalNameGuard(*m_executionContext);
  +            const GetAndReleaseCachedString     prefixGuard(*m_executionContext);
   
               XalanDOMString&     elemLocalName = elemLocalNameGuard.get();
               XalanDOMString&     prefix = prefixGuard.get();
  @@ -2736,7 +2794,7 @@
   
           if(desturi == 0 || equals(srcURI, *desturi) == false)
           {
  -            addResultAttribute(thePendingAttributes, theName, srcURI);
  +            addResultAttribute(thePendingAttributes, theName, srcURI, false, 0);
               addResultNamespaceDecl(thePrefix, srcURI);
           }
       }
  @@ -2926,7 +2984,7 @@
               const XalanDOMString&   attrValue,
               AttributeListImpl&      attrList)
   {
  -    addResultAttribute(attrList, attrName, attrValue);
  +    addResultAttribute(attrList, attrName, attrValue, false, 0);
   }
   
   
  
  
  
  1.18      +68 -7     xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.hpp
  
  Index: XSLTEngineImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.hpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XSLTEngineImpl.hpp	2 May 2005 19:33:49 -0000	1.17
  +++ XSLTEngineImpl.hpp	7 Oct 2005 22:49:52 -0000	1.18
  @@ -440,17 +440,23 @@
   	 * @param attList attribute list added to
   	 * @param aname   name of attribute
   	 * @param value   value of attribute
  +     * @param fromCopy true if the attribute is being copied from the source tree
  +     * @param locator The Locator for reporting errors.
   	 */
   	void
   	addResultAttribute(
   			AttributeListImpl&		attList,
   			const XalanDOMString&	aname,
  -			const XalanDOMString&	value)
  +			const XalanDOMString&	value,
  +            bool                    fromCopy = false,
  +			const LocatorType*	    locator = 0)
   	{
   		addResultAttribute(
   			attList,
   			aname,
  -			value.c_str());
  +			value.c_str(),
  +            fromCopy,
  +            locator);
   	}
   
   	/**
  @@ -460,12 +466,45 @@
   	 * @param attList attribute list added to
   	 * @param aname name of attribute
   	 * @param value value of attribute
  +     * @param fromCopy true if the attribute is being copied from the source tree
  +     * @param locator The Locator for reporting errors.
  +	 */
  +	void
  +	addResultAttribute(
  +			AttributeListImpl&		attList,
  +			const XalanDOMString&	aname,
  +			const XalanDOMChar*	    value,
  +            bool                    fromCopy = false,
  +			const LocatorType*	    locator = 0)
  +    {
  +	    addResultAttribute(
  +			attList,
  +			aname,
  +            value,
  +            length(value),
  +            fromCopy,
  +            locator);
  +    }
  +
  +	/**
  +	 * Add attribute to attribute list, and if it is a namespace, add it to the
  +	 * namespaces stack.
  +	 *
  +	 * @param attList attribute list added to
  +	 * @param aname name of attribute
  +	 * @param value value of attribute
  +     * @param theLength The length of the value
  +     * @param fromCopy true if the attribute is being copied from the source tree
  +     * @param locator The Locator for reporting errors.
   	 */
   	void
   	addResultAttribute(
   			AttributeListImpl&			attList,
   			const XalanDOMString&		aname,
  -			const XalanDOMChar*			value);
  +			const XalanDOMChar*			value,
  +            XalanDOMString::size_type   theLength,
  +            bool                        fromCopy = false,
  +			const LocatorType*	        locator = 0);
   
   	/**
   	 * Add attribute to pending attributes list, and if it is a namespace, add
  @@ -473,18 +512,24 @@
   	 *
   	 * @param aname name of attribute
   	 * @param value value of attribute
  +     * @param fromCopy true if the attribute is being copied from the source tree
  +     * @param locator The Locator for reporting errors.
   	 */
   	void
   	addResultAttribute(
   			const XalanDOMString&		aname,
  -			const XalanDOMChar*			value)
  +			const XalanDOMChar*			value,
  +            bool                        fromCopy = false,
  +			const LocatorType*	        locator = 0)
   	{
   		assert(m_outputContextStack.empty() == false);
   
   		addResultAttribute(
   				getPendingAttributesImpl(),
   				aname,
  -				value);
  +				value,
  +                fromCopy,
  +                locator);
   	}
   
   	/**
  @@ -493,20 +538,36 @@
   	 *
   	 * @param aname   name of attribute
   	 * @param value   value of attribute
  +     * @param fromCopy true if the attribute is being copied from the source tree
  +     * @param locator The Locator for reporting errors.
   	 */
   	void
   	addResultAttribute(
   			const XalanDOMString&	aname,
  -			const XalanDOMString&	value)
  +			const XalanDOMString&	value,
  +            bool                    fromCopy = false,
  +			const LocatorType*	    locator = 0)
   	{
   		assert(m_outputContextStack.empty() == false);
   
   		addResultAttribute(
   				getPendingAttributesImpl(),
   				aname,
  -				value);
  +				value,
  +                fromCopy,
  +                locator);
   	}
   
  +	/**
  +	 * Report an error copying a duplicate namespace node.
  +	 *
  +	 * @param theName The name of the node.
  +	 */
  +    void
  +    reportDuplicateNamespaceNodeError(
  +            const XalanDOMString&   theName,
  +			const LocatorType*	    locator);
  +
   	void
   	setDocumentLocator(const LocatorType*	locator);
   
  
  
  

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


Mime
View raw message