dbertoni 01/11/30 13:53:00
Modified: c/src/XalanSourceTree XalanSourceTreeDocument.cpp
Log:
Throw NOT_SUPPORTED_ERR exceptions for functions that aren't implemented.
Don't add an xml namespace definition if one is already present.
Revision Changes Path
1.25 +107 -34
xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.cpp
Index: XalanSourceTreeDocument.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XalanSourceTreeDocument.cpp 2001/11/15 15:43:20 1.24
+++ XalanSourceTreeDocument.cpp 2001/11/30 21:52:59 1.25
@@ -475,7 +475,8 @@
XalanNodeList*
XalanSourceTreeDocument::getElementsByTagName(const XalanDOMString& /*
tagname */) const
{
- // Not supported...
+ throw XalanDOMException(XalanDOMException::NOT_SUPPORTED_ERR);
+
return 0;
}
@@ -554,14 +555,58 @@
+static bool
+hasXMLNamespaceAttribute(const AttributeList& attrs)
+{
+ const unsigned int theLength = attrs.getLength();
+
+ for (unsigned int i = 0; i < theLength; ++i)
+ {
+ const XalanDOMChar* const theName =
+ attrs.getName(i);
+ assert(theName != 0);
+
+ if(equals(theName, DOMServices::s_XMLNamespacePrefix) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+static bool
+hasXMLNamespaceAttribute(const Attributes& attrs)
+{
+ const unsigned int theLength = attrs.getLength();
+
+ for (unsigned int i = 0; i < theLength; ++i)
+ {
+ const XalanDOMChar* const theName =
+ attrs.getQName(i);
+ assert(theName != 0);
+
+ if(equals(theName, DOMServices::s_XMLNamespacePrefix) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
XalanSourceTreeElement*
XalanSourceTreeDocument::createElementNode(
- const XalanDOMChar* name,
- const AttributeList& attrs,
- XalanNode*
theParentNode,
- XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling,
- bool
fAddXMLNamespaceAttribute)
+ const XalanDOMChar* name,
+ const AttributeList& attrs,
+ XalanNode* theParentNode,
+ XalanNode*
thePreviousSibling,
+ XalanNode* theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
@@ -571,7 +616,14 @@
if (fAddXMLNamespaceAttribute == true)
{
- ++theAttributeCount;
+ if (hasXMLNamespaceAttribute(attrs) == true)
+ {
+ fAddXMLNamespaceAttribute = false;
+ }
+ else
+ {
+ ++theAttributeCount;
+ }
}
XalanSourceTreeAttr** const theAttributeVector =
@@ -648,13 +700,13 @@
XalanSourceTreeElement*
XalanSourceTreeDocument::createElementNode(
- const XalanDOMChar* tagName,
- const AttributeList& attrs,
- const PrefixResolver& thePrefixResolver,
- XalanNode*
theParentNode,
- XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling,
- bool
fAddXMLNamespaceAttribute)
+ const XalanDOMChar* tagName,
+ const AttributeList& attrs,
+ const PrefixResolver& thePrefixResolver,
+ XalanNode* theParentNode,
+ XalanNode*
thePreviousSibling,
+ XalanNode* theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
@@ -664,7 +716,14 @@
if (fAddXMLNamespaceAttribute == true)
{
- ++theAttributeCount;
+ if (hasXMLNamespaceAttribute(attrs) == true)
+ {
+ fAddXMLNamespaceAttribute = false;
+ }
+ else
+ {
+ ++theAttributeCount;
+ }
}
XalanSourceTreeAttr** const theAttributeVector =
@@ -748,11 +807,11 @@
{
if(theColonIndex == theLength)
{
- return theStringPool->get(XalanDOMString());
+ return theStringPool->get(XalanDOMString());
}
else
{
- return theStringPool->get(qname, theColonIndex);
+ return theStringPool->get(qname, theColonIndex);
}
@@ -762,14 +821,14 @@
XalanSourceTreeElement*
XalanSourceTreeDocument::createElementNode(
- const XalanDOMChar* uri,
- const XalanDOMChar* localname,
- const XalanDOMChar* qname,
- const Attributes& attrs,
- XalanNode*
theParentNode,
- XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling,
- bool
fAddXMLNamespaceAttribute)
+ const XalanDOMChar* uri,
+ const XalanDOMChar* localname,
+ const XalanDOMChar* qname,
+ const Attributes& attrs,
+ XalanNode* theParentNode,
+ XalanNode*
thePreviousSibling,
+ XalanNode* theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
@@ -780,7 +839,14 @@
if (fAddXMLNamespaceAttribute == true)
{
- ++theAttributeCount;
+ if (hasXMLNamespaceAttribute(attrs) == true)
+ {
+ fAddXMLNamespaceAttribute = false;
+ }
+ else
+ {
+ ++theAttributeCount;
+ }
}
XalanSourceTreeAttr** const theAttributeVector =
@@ -816,12 +882,12 @@
XalanSourceTreeElement*
XalanSourceTreeDocument::createElementNode(
- const XalanDOMChar* name,
- const Attributes& attrs,
- XalanNode*
theParentNode,
- XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling,
- bool
fAddXMLNamespaceAttribute)
+ const XalanDOMChar* name,
+ const Attributes& attrs,
+ XalanNode* theParentNode,
+ XalanNode*
thePreviousSibling,
+ XalanNode* theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
@@ -831,7 +897,14 @@
if (fAddXMLNamespaceAttribute == true)
{
- ++theAttributeCount;
+ if (hasXMLNamespaceAttribute(attrs) == true)
+ {
+ fAddXMLNamespaceAttribute = false;
+ }
+ else
+ {
+ ++theAttributeCount;
+ }
}
XalanSourceTreeAttr** const theAttributeVector =
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]