dbertoni    00/06/01 09:23:41

  Modified:    c/src/DOMSupport DOMServices.cpp DOMServices.hpp
  Log:
  Added function to get the XSLT name of a node.  Fixed bug in namespace code.
  
  Revision  Changes    Path
  1.11      +50 -5     xml-xalan/c/src/DOMSupport/DOMServices.cpp
  
  Index: DOMServices.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMServices.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DOMServices.cpp   2000/05/15 15:50:38     1.10
  +++ DOMServices.cpp   2000/06/01 16:23:41     1.11
  @@ -92,8 +92,13 @@
   
   #endif
   
  +const unsigned int           DOMServices::s_XMLStringLength = 
length(s_XMLString);
  +const unsigned int           DOMServices::s_XMLNamespaceURILength = 
length(s_XMLNamespaceURI);
  +const unsigned int           DOMServices::s_XMLNamespaceLength = 
length(s_XMLNamespace);
  +const unsigned int           DOMServices::s_XMLNamespaceWithSeparatorLength 
= length(s_XMLNamespaceWithSeparator);
   
   
  +
   DOMServices::WhitespaceSupport::WhitespaceSupport()
   {
   }
  @@ -224,6 +229,44 @@
   
   
   XalanDOMString
  +DOMServices::getNameOfNode(const XalanNode&          n)
  +{
  +     XalanDOMString  theResult;
  +
  +     const XalanNode::NodeType       theNodeType =
  +                             n.getNodeType();
  +
  +     if (theNodeType == XalanNode::ATTRIBUTE_NODE)
  +     {
  +             const XalanAttr&        theAttributeNode =
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                             (const XalanAttr&)(n);
  +#else
  +                             static_cast<const XalanAttr&>(n);
  +#endif
  +
  +             theResult = theAttributeNode.getName();
  +
  +             if (startsWith(theResult, 
DOMServices::s_XMLNamespaceWithSeparator) == true)
  +             {
  +                     // Uh oh, it's a namespace node, represented as an 
attribute in
  +                     // the DOM.  XSLT says we have to strip off the xmlns: 
part...
  +                     theResult = substring(theResult, 
length(DOMServices::s_XMLNamespaceWithSeparator));
  +             }
  +
  +     }
  +     else if (theNodeType == XalanNode::ELEMENT_NODE ||
  +                      theNodeType == XalanNode::PROCESSING_INSTRUCTION_NODE)
  +     {
  +             theResult = n.getNodeName();
  +     }
  +
  +     return theResult;
  +}
  +
  +
  +
  +XalanDOMString
   DOMServices::getLocalNameOfNode(const XalanNode&     n)
   {
        const XalanDOMString    qname = n.getNodeName();
  @@ -375,10 +418,12 @@
   
                                        const XalanDOMString            aname = 
attr->getNodeName();
   
  -                                     const bool isPrefix =
  +                                     const unsigned int                      
len = length(aname);
  +
  +                                     const bool isPrefix = len <= 
s_XMLNamespaceWithSeparatorLength ? false :
                                                        equals(substring(aname,
                                                                                
         0,
  -                                                                             
         length(s_XMLNamespaceWithSeparator)),
  +                                                                             
         s_XMLNamespaceWithSeparatorLength),
                                                                   
s_XMLNamespaceWithSeparator);
   
                                        if (equals(aname, s_XMLNamespace) || 
isPrefix) 
  @@ -386,11 +431,11 @@
                                                const unsigned int      index = 
indexOf(aname,
                                                                                
                                        ':');
                 
  -                                             const XalanDOMString p =
  +                                             const XalanDOMString    p =
                                                        isPrefix ? 
substring(aname,
                                                                                
                 index + 1,
  -                                                                             
                 length(aname)) : XalanDOMString();
  -              
  +                                                                             
                 len) : XalanDOMString();
  +
                                                if (equals(p, prefix) == true)
                                                {
                                                        theNamespace = 
attr->getNodeValue();
  
  
  
  1.10      +19 -1     xml-xalan/c/src/DOMSupport/DOMServices.hpp
  
  Index: DOMServices.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMServices.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DOMServices.hpp   2000/04/19 18:13:33     1.9
  +++ DOMServices.hpp   2000/06/01 16:23:41     1.10
  @@ -100,6 +100,11 @@
   
   #endif
   
  +     static const unsigned int               s_XMLStringLength;
  +     static const unsigned int               s_XMLNamespaceURILength;
  +     static const unsigned int               s_XMLNamespaceLength;
  +     static const unsigned int               
s_XMLNamespaceWithSeparatorLength;
  +
        class XALAN_DOMSUPPORT_EXPORT WhitespaceSupport
        {
        public:
  @@ -150,8 +155,21 @@
        static XalanDOMString
        getNodeData(const XalanNode&    node);
   
  +     /**
  +      * Retrieve the name of the node, taking into
  +      * account the differences between the DOM and
  +      * XSLT data models.
  +      * 
  +      * @param node  DOM node whose name is returned
  +      * @return name of the node
  +      */
  +     static XalanDOMString
  +     getNameOfNode(const XalanNode&  n);
  +
        /**
  -      * Retrieve local name of node
  +      * Retrieve local name of node, taking into
  +      * account the differences between the DOM and
  +      * XSLT data models.
         * 
         * @param node  DOM node whose name is returned
         * @return name of node without namespace
  
  
  

Reply via email to