xml-xalan-cvs 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 ElemAttributeSet.cpp ElemAttributeSet.hpp ElemUse.cpp Stylesheet.cpp Stylesheet.hpp StylesheetHandler.cpp StylesheetRoot.cpp StylesheetRoot.hpp
Date Wed, 01 Oct 2003 21:15:36 GMT
dbertoni    2003/10/01 14:15:36

  Modified:    c/src/xalanc/XSLT ElemAttributeSet.cpp ElemAttributeSet.hpp
                        ElemUse.cpp Stylesheet.cpp Stylesheet.hpp
                        StylesheetHandler.cpp StylesheetRoot.cpp
                        StylesheetRoot.hpp
  Log:
  Fixed issues with xsl:attribute-set and introduced error for unknown attribute set.
  
  Revision  Changes    Path
  1.3       +11 -2     xml-xalan/c/src/xalanc/XSLT/ElemAttributeSet.cpp
  
  Index: ElemAttributeSet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemAttributeSet.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemAttributeSet.cpp	19 Sep 2003 20:33:04 -0000	1.2
  +++ ElemAttributeSet.cpp	1 Oct 2003 21:15:36 -0000	1.3
  @@ -64,6 +64,7 @@
   
   #include "Constants.hpp"
   #include "Stylesheet.hpp"
  +#include "StylesheetRoot.hpp"
   #include "StylesheetConstructionContext.hpp"
   #include "StylesheetExecutionContext.hpp"
   
  @@ -98,8 +99,6 @@
   				atts.getValue(i),
   				stylesheetTree.getNamespaces(),
   				getLocator());
  -
  -			stylesheetTree.addAttributeSet(this);
   		}
   		else if(!(processUseAttributeSets(constructionContext, aname, atts, i) ||
   					isAttrOK(aname, atts, i, constructionContext)))
  @@ -167,6 +166,16 @@
   
   		attr = attr->getNextSiblingElem();
   	}
  +}
  +
  +
  +
  +void
  +ElemAttributeSet::addToStylesheet(
  +			StylesheetConstructionContext&	/* constructionContext */,
  +			Stylesheet&						theStylesheet)
  +{
  +	theStylesheet.getStylesheetRoot().addAttributeSet(*this);
   }
   
   
  
  
  
  1.3       +5 -0      xml-xalan/c/src/xalanc/XSLT/ElemAttributeSet.hpp
  
  Index: ElemAttributeSet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemAttributeSet.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemAttributeSet.hpp	19 Sep 2003 20:33:04 -0000	1.2
  +++ ElemAttributeSet.hpp	1 Oct 2003 21:15:36 -0000	1.3
  @@ -118,6 +118,11 @@
   	virtual	void
   	execute(StylesheetExecutionContext&		executionContext) const;
   
  +	virtual void
  +	addToStylesheet(
  +			StylesheetConstructionContext&	constructionContext,
  +			Stylesheet&						theStylesheet);
  +
   protected:
   
   	virtual bool
  
  
  
  1.3       +8 -5      xml-xalan/c/src/xalanc/XSLT/ElemUse.cpp
  
  Index: ElemUse.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemUse.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemUse.cpp	19 Sep 2003 20:33:04 -0000	1.2
  +++ ElemUse.cpp	1 Oct 2003 21:15:36 -0000	1.3
  @@ -71,6 +71,7 @@
   
   
   #include "Constants.hpp"
  +#include "ElemAttributeSet.hpp"
   #include "StylesheetRoot.hpp"
   #include "StylesheetConstructionContext.hpp"
   
  @@ -154,11 +155,13 @@
   	{
   		assert(canGenerateAttributes() == true);
   
  -		getStylesheet().getStylesheetRoot().applyAttrSets(
  -				m_attributeSetsNames, 
  -				m_attributeSetsNamesCount,
  -				executionContext,
  -				executionContext.getCurrentNode());
  +		const StylesheetRoot&		theStylesheetRoot = getStylesheet().getStylesheetRoot();
  +		const LocatorType* const	theLocator = getLocator();
  +
  +		for(size_type i = 0; i < m_attributeSetsNamesCount; ++i)
  +		{
  +			theStylesheetRoot.executeAttributeSet(executionContext, *m_attributeSetsNames[i], theLocator);
  +		}
   	}
   }
   
  
  
  
  1.4       +0 -54     xml-xalan/c/src/xalanc/XSLT/Stylesheet.cpp
  
  Index: Stylesheet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/Stylesheet.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Stylesheet.cpp	7 Aug 2003 21:51:00 -0000	1.3
  +++ Stylesheet.cpp	1 Oct 2003 21:15:36 -0000	1.4
  @@ -99,7 +99,6 @@
   #include "KeyTable.hpp"
   #include "StylesheetConstructionContext.hpp"
   #include "StylesheetExecutionContext.hpp"
  -#include "StylesheetRoot.hpp"
   
   
   
  @@ -146,8 +145,6 @@
   	m_nodePatternList(),
   	m_matchPattern2Container(),
   	m_patternCount(0),
  -	m_attributeSets(),
  -	m_attributeSetsSize(0),
   	m_elemDecimalFormats(),
   	m_namespacesHandler()
   {
  @@ -499,7 +496,6 @@
   	// Call postConstruction() on our own namespaces handler...
   	m_namespacesHandler.postConstruction(constructionContext);
   
  -
   	{
   		for (ElemTemplateElement* node = m_firstTemplate;
   			 node != 0;
  @@ -518,9 +514,6 @@
   		}
   	}
   
  -	// Cache the size...
  -	m_attributeSetsSize = m_attributeSets.size();
  -
   	addToTable(m_elementPatternTable, m_elementAnyPatternList);
   	addToTable(m_attributePatternTable, m_attributeAnyPatternList);
   
  @@ -1499,53 +1492,6 @@
   	}
   
   	return dfs;
  -}
  -
  -
  -
  -void
  -Stylesheet::applyAttrSets(
  -			const XalanQName**				attributeSetsNames,
  -			size_type						attributeSetsNamesCount,
  -			StylesheetExecutionContext& 	executionContext,			
  -			XalanNode*						sourceNode) const
  -{
  -	if(0 != attributeSetsNamesCount)
  -	{
  -		// Process up the import chain...
  -		const StylesheetVectorType::const_reverse_iterator	theEnd = m_imports.rend();
  -		StylesheetVectorType::const_reverse_iterator		i = m_imports.rbegin();
  -
  -		while(i != theEnd)
  -		{
  -			(*i)->applyAttrSets(
  -				attributeSetsNames,
  -				attributeSetsNamesCount,
  -				executionContext,
  -				sourceNode);
  -
  -			++i;
  -		}
  -
  -		for(size_type j = 0; j < attributeSetsNamesCount; j++)
  -		{
  -			const XalanQName* const		qname = attributeSetsNames[j];
  -			assert(qname != 0);
  -
  -			assert(m_attributeSetsSize == m_attributeSets.size());
  -
  -			for(StylesheetVectorType::size_type k = 0; k < m_attributeSetsSize; k++)
  -			{
  -				const ElemAttributeSet* const	attrSet = m_attributeSets[k];
  -				assert(attrSet != 0);
  -
  -				if(qname->equals(attrSet->getQName()))
  -				{
  -					attrSet->execute(executionContext);
  -				}
  -			}
  -		}
  -	}
   }
   
   
  
  
  
  1.3       +0 -50     xml-xalan/c/src/xalanc/XSLT/Stylesheet.hpp
  
  Index: Stylesheet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/Stylesheet.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Stylesheet.hpp	15 Jul 2003 01:05:22 -0000	1.2
  +++ Stylesheet.hpp	1 Oct 2003 21:15:36 -0000	1.3
  @@ -99,7 +99,6 @@
   
   class ExtensionNSHandler;
   class XalanDecimalFormatSymbols;
  -class ElemAttributeSet;
   class ElemDecimalFormat;
   class ElemTemplate;
   class ElemTemplateElement;
  @@ -141,7 +140,6 @@
   	typedef map<XalanQNameByReference,
   				const ElemTemplate*,
   				less<XalanQName> >					ElemTemplateMapType;
  -	typedef vector<ElemAttributeSet*> 				AttributeSetVectorType;
   	typedef vector<ElemVariable*> 					ElemVariableVectorType;
   	typedef vector<KeyDeclaration>					KeyDeclarationVectorType;
   	typedef map<const XalanNode*,
  @@ -155,7 +153,6 @@
   	typedef std::map<XalanQNameByReference,
   					 const ElemTemplate*,
   					 std::less<XalanQName> >				ElemTemplateMapType;
  -	typedef std::vector<ElemAttributeSet*> 					AttributeSetVectorType;
   	typedef std::vector<ElemVariable*> 						ElemVariableVectorType;
   	typedef std::vector<KeyDeclaration>						KeyDeclarationVectorType;
   	typedef std::map<const XalanNode*, KeyTable*>			KeyTablesTableType;
  @@ -434,17 +431,6 @@
   	}
   
   	/**
  -	 * Set the base identifier with which this stylesheet is associated.
  -	 * 
  -	 * @param str string for base identifier
  -	 */
  -	void
  -	setBaseIdentifier(const XalanDOMString&		str)
  -	{
  -		m_baseIdent = str;
  -	}
  -
  -	/**
   	 * Retrieve the base identifier for the most recently
   	 * included stylesheet.  This will return the same value
   	 * as getBaseIdentifier(), if no include is being
  @@ -493,35 +479,6 @@
   	getDecimalFormatSymbols(const XalanQName&	theQName) const;
   
   	/**
  -	 * Add an attribute set to the list.
  -	 *
  -	 * @param attrSet pointer to attribute set to add
  -	 */
  -	void
  -	addAttributeSet(ElemAttributeSet*	attrSet)
  -	{
  -		assert(attrSet != 0);
  -
  -		m_attributeSets.push_back(attrSet);
  -	}
  -
  -	/**
  -	 * Apply the set of named attributes to a node in a given context with a
  -	 * given mode
  -	 *
  -	 * @param attributeSetsNames The vector of attribute set names
  -	 * @param attributeSetsNamesCount The size of the vector
  -	 * @param executionContext	 The current execution context
  -	 * @param sourceNode		 The source node
  -	 */
  -	void
  -	applyAttrSets(
  -			const XalanQName**				attributeSetsNames,
  -			size_type						attributeSetsNamesCount,
  -			StylesheetExecutionContext& 	executionContext,
  -			XalanNode*						sourceNode) const;
  -
  -	/**
   	 * Add an imported stylesheet.
   	 *
   	 * @param theStylesheet The stylesheet to add.
  @@ -1056,13 +1013,6 @@
   	 * This caches the number of possible patterns we can match.
   	 */
   	MatchPattern2Container::size_type		m_patternCount;
  -
  -	AttributeSetVectorType 					m_attributeSets;
  -
  -	/**
  -	 * This caches the number of attribute sets.
  -	 */
  -	AttributeSetVectorType::size_type		m_attributeSetsSize;
   
   	ElemDecimalFormatVectorType				m_elemDecimalFormats;
   
  
  
  
  1.5       +6 -2      xml-xalan/c/src/xalanc/XSLT/StylesheetHandler.cpp
  
  Index: StylesheetHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetHandler.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StylesheetHandler.cpp	19 Sep 2003 20:33:04 -0000	1.4
  +++ StylesheetHandler.cpp	1 Oct 2003 21:15:36 -0000	1.5
  @@ -754,12 +754,16 @@
   			m_inTemplate = true; // fake it out
   			m_inScopeVariableNamesStack.resize(m_inScopeVariableNamesStack.size() + 1);
   
  -			m_elemStack.push_back(
  +			ElemTemplateElement* const	theAttributeSet =
   				m_constructionContext.createElement(
   					xslToken,
   					m_stylesheet,
   					atts,
  -					locator));
  +					locator);
  +
  +			theAttributeSet->addToStylesheet(m_constructionContext, m_stylesheet);
  +
  +			m_elemStack.push_back(theAttributeSet);
   		}
   		break;
   
  
  
  
  1.8       +63 -1     xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StylesheetRoot.cpp	19 Sep 2003 20:33:04 -0000	1.7
  +++ StylesheetRoot.cpp	1 Oct 2003 21:15:36 -0000	1.8
  @@ -97,6 +97,7 @@
   
   #include "Constants.hpp"
   #include "ElemApplyTemplates.hpp"
  +#include "ElemAttributeSet.hpp"
   #include "ElemTemplate.hpp"
   #include "ElemValueOf.hpp"
   #include "KeyTable.hpp"
  @@ -146,7 +147,8 @@
   	m_omitMETATag(false),
   	m_elemNumberNextID(0),
   	m_whitespacePreservingElements(),
  -	m_whitespaceStrippingElements()
  +	m_whitespaceStrippingElements(),
  +	m_attributeSetsMap()
   {
   	// Our base class has already resolved the URI and pushed it on
   	// the back of the include stack, so get it from there...
  @@ -171,6 +173,26 @@
   
   	initDefaultRule(constructionContext);
   
  +	{
  +		AttributeSetMapType::iterator			theCurrentMap = m_attributeSetsMap.begin();
  +		const AttributeSetMapType::iterator		theEndMap = m_attributeSetsMap.end();
  +
  +		while(theCurrentMap != theEndMap)
  +		{
  +			AttributeSetVectorType::iterator		theCurrentVector = (*theCurrentMap).second.begin();
  +			const AttributeSetVectorType::iterator	theEndVector = (*theCurrentMap).second.end();
  +
  +			while(theCurrentVector != theEndVector)
  +			{
  +				(*theCurrentVector)->postConstruction(constructionContext, getNamespacesHandler());
  +
  +				++theCurrentVector;
  +			}
  +
  +			++theCurrentMap;
  +		}	
  +	}
  +
   	// We may need to build keys, since we may have inherited them from
   	// our imports.
   	if (m_needToBuildKeysTable == false && m_keyDeclarations.empty() == false)
  @@ -900,6 +922,46 @@
   	}
   
   	return strip;
  +}
  +
  +
  +
  +void
  +StylesheetRoot::addAttributeSet(ElemAttributeSet&	theAttributeSet)
  +{
  +	m_attributeSetsMap[&theAttributeSet.getQName()].push_back(&theAttributeSet);
  +}
  +
  +
  +
  +void
  +StylesheetRoot::executeAttributeSet(
  +			StylesheetExecutionContext&		theExecutionContext,
  +			const XalanQName&				theQName,
  +			const LocatorType*				theLocator) const
  +{
  +	const AttributeSetMapType::const_iterator	i =
  +		m_attributeSetsMap.find(&theQName);
  +
  +	if (i == m_attributeSetsMap.end())
  +	{
  +		theExecutionContext.error(
  +			"Unknown xsl:attribute-set",
  +			theExecutionContext.getCurrentNode(),
  +			theLocator);
  +	}
  +	else
  +	{
  +		const AttributeSetVectorType&					theAttributeSets = (*i).second;
  +		const AttributeSetVectorType::const_iterator	theEnd = theAttributeSets.end();
  +
  +		for(AttributeSetVectorType::const_iterator i = theAttributeSets.begin(); i != theEnd;
++i)
  +		{
  +			assert(*i != 0);
  +
  +			(*i)->execute(theExecutionContext);
  +		}
  +	}
   }
   
   
  
  
  
  1.3       +24 -0     xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.hpp
  
  Index: StylesheetRoot.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StylesheetRoot.hpp	19 Sep 2003 20:33:04 -0000	1.2
  +++ StylesheetRoot.hpp	1 Oct 2003 21:15:36 -0000	1.3
  @@ -80,6 +80,7 @@
   
   
   
  +class ElemAttributeSet;
   class StylesheetConstructionContext;
   class XalanText;
   class XSLTResultTarget;
  @@ -98,9 +99,17 @@
   #if defined(XALAN_NO_STD_NAMESPACE)
   	typedef vector<const XalanQName*> 		XalanQNameVectorType;
   	typedef vector<const XPath*>			XPathVectorType;
  +	typedef vector<ElemAttributeSet*> 		AttributeSetVectorType;
  +	typedef map<const XalanQName*,
  +			    AttributeSetVectorType,
  +				pointer_less<const XalanQName> >	AttributeSetMapType;
   #else
   	typedef std::vector<const XalanQName*>	XalanQNameVectorType;
   	typedef std::vector<const XPath*>		XPathVectorType;
  +	typedef std::vector<ElemAttributeSet*> 	AttributeSetVectorType;
  +	typedef std::map<const XalanQName*,
  +					 AttributeSetVectorType,
  +					 pointer_less<const XalanQName> >	AttributeSetMapType;
   #endif
   
   	/**
  @@ -433,6 +442,15 @@
   			StylesheetExecutionContext&		executionContext,
   			const XalanText&				textNode) const;
   
  +	void
  +	addAttributeSet(ElemAttributeSet&	theAttributeSet);
  +
  +	void
  +	executeAttributeSet(
  +			StylesheetExecutionContext&		theExecutionContext,
  +			const XalanQName&				theQName,
  +			const LocatorType*				theLocator) const;
  +
   private:
   
   	/**
  @@ -582,6 +600,12 @@
   	 * A lookup table of all space stripping elements.
   	 */
   	XPathVectorType 			m_whitespaceStrippingElements;
  +
  +	/**
  +	 * A lookup table of all attribute sets.
  +	 */
  +	AttributeSetMapType			m_attributeSetsMap;
  +
   
   	// Not implemented...
       StylesheetRoot(const StylesheetRoot&);
  
  
  

---------------------------------------------------------------------
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