dbertoni    2003/07/10 14:42:37

  Modified:    c/src/xalanc/XSLT StylesheetRoot.cpp
  Log:
  Index key tables on calculated "root," rather than always on the owner 
document.  Fixes a bug with using the node-set() extension function and keys.  
Bugzilla 21474.
  
  Revision  Changes    Path
  1.3       +50 -3     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StylesheetRoot.cpp        1 Jul 2003 23:48:05 -0000       1.2
  +++ StylesheetRoot.cpp        10 Jul 2003 21:42:37 -0000      1.3
  @@ -709,6 +709,50 @@
   
   
   
  +inline XalanNode*
  +getKeyNode(
  +                     XalanNode*                                              
startNode,
  +                     StylesheetExecutionContext&             
executionContext)
  +{
  +     // This is a big hack for dealing with result tree fragments coerced to 
node-sets using the
  +     // node-set extension function.  For such cases, the "document" is 
really the
  +     // XalanDocumentFragment instance that owns the nodes, not the owner 
document.
  +     if (startNode->getFirstChild() == 0)
  +     {
  +             XalanNode*      currentNode = executionContext.getCurrentNode();
  +             assert(currentNode != 0);
  +
  +             if (currentNode->getOwnerDocument() == startNode)
  +             {
  +                     // OK, the current node belongs to the document, but 
the document
  +                     // is just a factory for fragments...
  +                     for(;;)
  +                     {
  +                             XalanNode*      parentNode = 
DOMServices::getParentOfNode(*currentNode);
  +
  +                             if (parentNode == 0)
  +                             {
  +                                     break;
  +                             }
  +                             else if (parentNode->getNodeType() == 
XalanNode::DOCUMENT_FRAGMENT_NODE)
  +                             {
  +                                     startNode = parentNode;
  +
  +                                     break;
  +                             }
  +                             else
  +                             {
  +                                     currentNode = parentNode;
  +                             }
  +                     }
  +             }
  +     }
  +
  +     return startNode;
  +}
  +
  +
  +
   void
   StylesheetRoot::getNodeSetByKey(
                        XalanDocument*                                  doc,
  @@ -721,12 +765,15 @@
   {
        assert(nodelist.empty() == true || nodelist.getDocumentOrder() == true);
   
  +     XalanNode* const        theKeyNode = getKeyNode(doc, executionContext);
  +     assert(theKeyNode != 0);
  +
        if(m_needToBuildKeysTable == true)
        {
                assert(m_keyDeclarations.empty() == false);
   
                const KeyTablesTableType::const_iterator        i =
  -                     theKeysTable.find(doc);
  +                     theKeysTable.find(theKeyNode);
   
                if (i != theKeysTable.end())
                {
  @@ -745,12 +792,12 @@
                {
                        KeyTable* const kt =
                                new KeyTable(
  -                                                      doc,
  +                                                      theKeyNode,
                                                         resolver,
                                                         m_keyDeclarations,
                                                         executionContext);
   
  -                     theKeysTable[doc] = kt;
  +                     theKeysTable[theKeyNode] = kt;
   
                        const MutableNodeRefList&       nl = 
kt->getNodeSetByKey(qname, ref);
   
  
  
  

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

Reply via email to