dbertoni 02/03/27 23:07:57 Modified: c/src/XSLT XSLTEngineImpl.cpp XSLTEngineImpl.hpp Log: Cleaned-up unused map. Improved result namespace handling. Revision Changes Path 1.136 +35 -57 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.135 retrieving revision 1.136 diff -u -r1.135 -r1.136 --- XSLTEngineImpl.cpp 13 Mar 2002 04:34:57 -0000 1.135 +++ XSLTEngineImpl.cpp 28 Mar 2002 07:07:56 -0000 1.136 @@ -962,19 +962,6 @@ tok = (*j).second; } } - else if(equals(ns, s_XSLT4JNameSpaceURL)) - { - const XalanDOMString& localName = - DOMServices::getLocalNameOfNode(node); - - const ElementKeysMapType::const_iterator j = - s_XSLT4JElementKeys.find(localName); - - if(j != s_XSLT4JElementKeys.end()) - { - tok = (*j).second; - } - } return tok; } @@ -2735,44 +2722,52 @@ void XSLTEngineImpl::addResultNamespace( + const XalanDOMString& thePrefix, + const XalanDOMString& theName, + const XalanNode& theNode, + AttributeListImpl& thePendingAttributes, + bool fOnlyIfPrefixNotPresent) +{ + if (fOnlyIfPrefixNotPresent == false || + m_resultNamespacesStack.prefixIsPresentLocal(thePrefix) == false) + { + const XalanDOMString* const desturi = getResultNamespaceForPrefix(thePrefix); + const XalanDOMString& srcURI = theNode.getNodeValue(); + + if(desturi == 0 || equals(srcURI, *desturi) == false) + { + addResultAttribute(thePendingAttributes, theName, srcURI); + } + } +} + + + +void +XSLTEngineImpl::addResultNamespace( const XalanNode& theNode, AttributeListImpl& thePendingAttributes, bool fOnlyIfPrefixNotPresent) { + assert(m_executionContext != 0); assert(theNode.getNodeType() == XalanNode::ATTRIBUTE_NODE); const XalanDOMString& aname = theNode.getNodeName(); - const bool isPrefix = startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator); - - const XalanDOMString prefix = isPrefix == true ? - substring(aname, DOMServices::s_XMLNamespaceWithSeparatorLength) : XalanDOMString(); - - if (equals(aname, DOMServices::s_XMLNamespace) || isPrefix) + if (equals(aname, DOMServices::s_XMLNamespace) == true) { - if (fOnlyIfPrefixNotPresent == true) - { - if (m_resultNamespacesStack.prefixIsPresentLocal(prefix) == false) - { - const XalanDOMString* const desturi = getResultNamespaceForPrefix(prefix); - const XalanDOMString& srcURI = theNode.getNodeValue(); + // Default namespace declaration... + addResultNamespace(s_emptyString, aname, theNode, thePendingAttributes, fOnlyIfPrefixNotPresent); + } + else if (startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator)) + { + StylesheetExecutionContext::GetAndReleaseCachedString prefixGuard(*m_executionContext); - if(desturi == 0 || equals(srcURI, *desturi) == false) - { - addResultAttribute(thePendingAttributes, aname, srcURI); - } - } - } - else - { - const XalanDOMString* const desturi = getResultNamespaceForPrefix(prefix); - const XalanDOMString& srcURI = theNode.getNodeValue(); + XalanDOMString& thePrefix = prefixGuard.get(); - if(desturi == 0 || equals(srcURI, *desturi) == false) - { - addResultAttribute(thePendingAttributes, aname, srcURI); - } - } + substring(aname, thePrefix, DOMServices::s_XMLNamespaceWithSeparatorLength); + + addResultNamespace(thePrefix, aname, theNode, thePendingAttributes, fOnlyIfPrefixNotPresent); } } @@ -3391,15 +3386,6 @@ -void -XSLTEngineImpl::initializeXSLT4JElementKeys(ElementKeysMapType& theElementKeys) -{ - theElementKeys[Constants::ELEMNAME_COMPONENT_STRING] = Constants::ELEMNAME_COMPONENT; - theElementKeys[Constants::ELEMNAME_SCRIPT_STRING] = Constants::ELEMNAME_SCRIPT; -} - - - static XalanDOMString s_XSLNameSpaceURL; static XalanDOMString s_XSLT4JNameSpaceURL; @@ -3410,8 +3396,6 @@ static XSLTEngineImpl::ElementKeysMapType s_elementKeys; -static XSLTEngineImpl::ElementKeysMapType s_XSLT4JElementKeys; - const double XSLTEngineImpl::s_XSLTVerSupported(1.0); @@ -3427,8 +3411,6 @@ const XSLTEngineImpl::ElementKeysMapType& XSLTEngineImpl::s_elementKeys = ::s_elementKeys; -const XSLTEngineImpl::ElementKeysMapType& XSLTEngineImpl::s_XSLT4JElementKeys = ::s_XSLT4JElementKeys; - void @@ -3445,8 +3427,6 @@ initializeAttributeKeysTable(::s_attributeKeys); initializeElementKeysTable(::s_elementKeys); - - initializeXSLT4JElementKeys(::s_XSLT4JElementKeys); } @@ -3454,8 +3434,6 @@ void XSLTEngineImpl::terminate() { - ElementKeysMapType().swap(::s_XSLT4JElementKeys); - ElementKeysMapType().swap(::s_elementKeys); AttributeKeysMapType().swap(::s_attributeKeys); 1.81 +9 -31 xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp Index: XSLTEngineImpl.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- XSLTEngineImpl.hpp 23 Feb 2002 04:23:17 -0000 1.80 +++ XSLTEngineImpl.hpp 28 Mar 2002 07:07:56 -0000 1.81 @@ -662,28 +662,6 @@ getXSLTVerSupported(); /** - * Accessor method for hash table of XSLT IDs for attribute names. - * - * @return hash table of key names and IDs - */ - static const AttributeKeysMapType& - getAttributeKeys() - { - return s_attributeKeys; - } - - /** - * Accessor method for hash table of XSLT IDs for element names. - * - * @return hash table of key names and IDs - */ - static const ElementKeysMapType& - getElementKeys() - { - return s_elementKeys; - } - - /** * Given an XSL tag name, return an integer token that corresponds to * ELEMNAME_XXX constants defined in Constants.hpp * @@ -711,7 +689,7 @@ static int getAttrTok(const XalanDOMString& name) { - AttributeKeysMapType::const_iterator iter= + ElementKeysMapType::const_iterator iter= s_attributeKeys.find(name); return iter == s_attributeKeys.end() ? -2 : (*iter).second; @@ -1464,6 +1442,14 @@ void addResultNamespace( + const XalanDOMString& thePrefix, + const XalanDOMString& theName, + const XalanNode& theNode, + AttributeListImpl& thePendingAttributes, + bool fOnlyIfPrefixNotPresent); + + void + addResultNamespace( const XalanNode& theNode, AttributeListImpl& thePendingAttributes, bool fOnlyIfPrefixNotPresent = false); @@ -1510,11 +1496,6 @@ static const XalanDOMString& s_uniqueNamespacePrefix; /** - * Map that can look up XSLT4J extensions element IDs via name. - */ - static const ElementKeysMapType& s_XSLT4JElementKeys; - - /** * Map of XSLT IDs for attribute names. */ static const AttributeKeysMapType& s_attributeKeys; @@ -1672,9 +1653,6 @@ static void initializeElementKeysTable(ElementKeysMapType& theElementKeys); - - static void - initializeXSLT4JElementKeys(ElementKeysMapType& theElementKeys); static const XalanDOMString s_emptyString; };
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]