You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2001/01/25 17:56:00 UTC
cvs commit: xml-xalan/c/src/XPath FunctionLocalName.cpp FunctionNamespaceURI.cpp
dbertoni 01/01/25 08:56:00
Modified: c/src/XPath FunctionLocalName.cpp FunctionNamespaceURI.cpp
Log:
Fixed problems involving namespace nodes.
Revision Changes Path
1.10 +24 -6 xml-xalan/c/src/XPath/FunctionLocalName.cpp
Index: FunctionLocalName.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionLocalName.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FunctionLocalName.cpp 2001/01/03 19:32:37 1.9
+++ FunctionLocalName.cpp 2001/01/25 16:55:59 1.10
@@ -58,6 +58,10 @@
+#include <PlatformSupport/DOMStringHelper.hpp>
+
+
+
#include <DOMSupport/DOMServices.hpp>
@@ -163,23 +167,37 @@
+static const XalanDOMString theEmptyString;
+
+
+
XObjectPtr
FunctionLocalName::getLocalName(
XPathExecutionContext& executionContext,
const XalanNode& node)
{
+ const XalanDOMString* theResult = &theEmptyString;
+
const XalanNode::NodeType theType = node.getNodeType();
- if(theType == XalanNode::ATTRIBUTE_NODE ||
- theType == XalanNode::ELEMENT_NODE ||
- theType == XalanNode::PROCESSING_INSTRUCTION_NODE)
+ if(theType == XalanNode::ELEMENT_NODE ||
+ theType == XalanNode::PROCESSING_INSTRUCTION_NODE)
{
- return executionContext.getXObjectFactory().createStringReference(DOMServices::getLocalNameOfNode(node));
+ theResult = &DOMServices::getLocalNameOfNode(node);
}
- else
+ else if (theType == XalanNode::ATTRIBUTE_NODE)
{
- return executionContext.getXObjectFactory().createString(XalanDOMString());
+ const XalanDOMString& theLocalName = DOMServices::getLocalNameOfNode(node);
+
+ if (equals(theLocalName, DOMServices::s_XMLNamespace) == false)
+ {
+ theResult = &theLocalName;
+ }
}
+
+ assert(theResult != 0);
+
+ return executionContext.getXObjectFactory().createStringReference(*theResult);
}
1.10 +37 -8 xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp
Index: FunctionNamespaceURI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FunctionNamespaceURI.cpp 2001/01/08 18:28:22 1.9
+++ FunctionNamespaceURI.cpp 2001/01/25 16:55:59 1.10
@@ -58,6 +58,10 @@
+#include <PlatformSupport/DOMStringHelper.hpp>
+
+
+
#include <DOMSupport/DOMServices.hpp>
@@ -78,6 +82,10 @@
+static const XalanDOMString theEmptyString;
+
+
+
XObjectPtr
FunctionNamespaceURI::execute(
XPathExecutionContext& executionContext,
@@ -92,10 +100,32 @@
}
else
{
- // The XPath standard says that if there are no arguments,
- // the argument defaults to a node set with the context node
- // as the only member.
- return executionContext.getXObjectFactory().createStringReference(context->getNamespaceURI());
+ const XalanDOMString* theResult = &theEmptyString;
+
+ const XalanNode::NodeType theType = context->getNodeType();
+
+ if (theType == XalanNode::ELEMENT_NODE)
+ {
+ theResult = &context->getNamespaceURI();
+ }
+ else if (theType == XalanNode::ATTRIBUTE_NODE)
+ {
+ const XalanDOMString& theNodeName = context->getNodeName();
+
+ if (equals(theNodeName, DOMServices::s_XMLNamespace) == false &&
+ startsWith(theNodeName, DOMServices::s_XMLNamespaceWithSeparator) == false)
+ {
+ theResult = &context->getNamespaceURI();
+ }
+ }
+ else
+ {
+ theResult = &context->getNamespaceURI();
+ }
+
+ assert(theResult != 0);
+
+ return executionContext.getXObjectFactory().createStringReference(*theResult);
}
}
@@ -113,13 +143,13 @@
if (theList.getLength() == 0)
{
- return executionContext.getXObjectFactory().createString(XalanDOMString());
+ return executionContext.getXObjectFactory().createStringReference(theEmptyString);
}
else
{
assert(theList.item(0) != 0);
- return executionContext.getXObjectFactory().createStringReference(theList.item(0)->getNamespaceURI());
+ return execute(executionContext, theList.item(0));
}
}
@@ -183,6 +213,5 @@
const XalanDOMString
FunctionNamespaceURI::getError() const
{
- return XALAN_STATIC_UCODE_STRING(
- "The namespace-uri() function takes zero arguments or one argument!");
+ return XALAN_STATIC_UCODE_STRING("The namespace-uri() function takes zero arguments or one argument!");
}