dbertoni 01/10/03 11:17:34
Modified: c/src/XalanSourceTree XalanSourceTreeContentHandler.cpp
XalanSourceTreeDocument.cpp
XalanSourceTreeDocument.hpp
Log:
Add xml namespace node.
Revision Changes Path
1.10 +5 -2
xml-xalan/c/src/XalanSourceTree/XalanSourceTreeContentHandler.cpp
Index: XalanSourceTreeContentHandler.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeContentHandler.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XalanSourceTreeContentHandler.cpp 2001/09/25 21:13:04 1.9
+++ XalanSourceTreeContentHandler.cpp 2001/10/03 18:17:34 1.10
@@ -499,13 +499,16 @@
{
assert(m_inDTD == false);
+ // If we're creating the document element, add the special xml
namespace attribute...
+ const bool fAddXMLNamespaceAttribute = theOwnerElement == 0 ? true
: false;
+
if (length(uri) != 0)
{
- return m_document->createElementNode(uri, localname, qname,
attrs, theOwnerElement);
+ return m_document->createElementNode(uri, localname, qname,
attrs, theOwnerElement, 0, 0, fAddXMLNamespaceAttribute);
}
else
{
- return m_document->createElementNode(qname, attrs,
theOwnerElement);
+ return m_document->createElementNode(qname, attrs,
theOwnerElement, 0, 0, fAddXMLNamespaceAttribute);
}
}
1.22 +143 -21
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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- XalanSourceTreeDocument.cpp 2001/09/26 21:59:51 1.21
+++ XalanSourceTreeDocument.cpp 2001/10/03 18:17:34 1.22
@@ -72,6 +72,10 @@
+#include <DOMSupport/DOMServices.hpp>
+
+
+
#include "XalanSourceTreeHelper.hpp"
@@ -556,14 +560,20 @@
const AttributeList& attrs,
XalanSourceTreeElement* theParentElement,
XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling)
+ XalanNode*
theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
- const AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
+ AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
// assert that we didn't lose anything...
assert(theAttributeCount == attrs.getLength());
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ ++theAttributeCount;
+ }
+
XalanSourceTreeAttr** const theAttributeVector =
theAttributeCount == 0 ? 0 :
m_attributesVector.allocate(theAttributeCount);
@@ -578,8 +588,39 @@
theNextSibling,
m_nextIndexValue++);
+ size_t theIndex = 0;
+
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ // The constructor parameters for AttrNS are:
+ //
+ // name
+ // local name
+ // namespace URI
+ // prefix
+ // value
+ // owner element
+ // index
+ //
+ theAttributeVector[theIndex] =
+ m_attributeNSAllocator.create(
+
m_namesStringPool.get(DOMServices::s_XMLNamespacePrefix),
+
m_namesStringPool.get(DOMServices::s_XMLString),
+
m_namesStringPool.get(DOMServices::s_XMLNamespacePrefixURI),
+
m_namesStringPool.get(DOMServices::s_XMLNamespace),
+
m_valuesStringPool.get(DOMServices::s_XMLNamespaceURI),
+ theNewElement,
+ m_nextIndexValue++);
+
+ assert(theAttributeVector[theIndex] != 0);
+
+ ++theIndex;
+ }
+
+ const AttributesCountType theSAXAttributeCount =
attrs.getLength();
+
// Now, create the attributes...
- for(AttributesCountType i = 0; i < theAttributeCount; ++i)
+ for(AttributesCountType i = 0; i < theSAXAttributeCount; ++i,
++theIndex)
{
const XalanDOMChar* const theName =
attrs.getName(i);
@@ -589,12 +630,14 @@
attrs.getValue(i);
assert(theValue != 0);
- theAttributeVector[i] =
+ theAttributeVector[theIndex] =
m_attributeAllocator.create(
m_namesStringPool.get(theName),
m_valuesStringPool.get(theValue),
theNewElement,
m_nextIndexValue++);
+
+ assert(theAttributeVector[theIndex] != 0);
}
return theNewElement;
@@ -609,14 +652,20 @@
const PrefixResolver& thePrefixResolver,
XalanSourceTreeElement* theParentElement,
XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling)
+ XalanNode*
theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
- const AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
+ AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
// assert that we didn't lose anything...
assert(theAttributeCount == attrs.getLength());
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ ++theAttributeCount;
+ }
+
XalanSourceTreeAttr** const theAttributeVector =
theAttributeCount == 0 ? 0 :
m_attributesVector.allocate(theAttributeCount);
@@ -629,10 +678,42 @@
thePreviousSibling,
theNextSibling,
thePrefixResolver);
+
assert(theNewElement != 0);
+ size_t theIndex = 0;
+
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ // The constructor parameters for AttrNS are:
+ //
+ // name
+ // local name
+ // namespace URI
+ // prefix
+ // value
+ // owner element
+ // index
+ //
+ theAttributeVector[theIndex] =
+ m_attributeNSAllocator.create(
+
m_namesStringPool.get(DOMServices::s_XMLNamespacePrefix),
+
m_namesStringPool.get(DOMServices::s_XMLString),
+
m_namesStringPool.get(DOMServices::s_XMLNamespacePrefixURI),
+
m_namesStringPool.get(DOMServices::s_XMLNamespace),
+
m_valuesStringPool.get(DOMServices::s_XMLNamespaceURI),
+ theNewElement,
+ m_nextIndexValue++);
+
+ assert(theAttributeVector[theIndex] != 0);
+
+ ++theIndex;
+ }
+
+ const AttributesCountType theSAXAttributeCount =
attrs.getLength();
+
// Now, create the attributes...
- for(AttributesCountType i = 0; i < theAttributeCount; ++i)
+ for(AttributesCountType i = 0; i < theSAXAttributeCount; ++i,
++theIndex)
{
const XalanDOMChar* const theName =
attrs.getName(i);
@@ -642,14 +723,14 @@
attrs.getValue(i);
assert(theValue != 0);
- theAttributeVector[i] =
+ theAttributeVector[theIndex] =
createAttribute(
theName,
theValue,
theNewElement,
thePrefixResolver);
- assert(theAttributeVector[i] != 0);
+ assert(theAttributeVector[theIndex] != 0);
}
return theNewElement;
@@ -686,15 +767,21 @@
const Attributes& attrs,
XalanSourceTreeElement* theParentElement,
XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling)
+ XalanNode*
theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
- const AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
+ AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
// assert that we didn't lose anything...
assert(theAttributeCount == attrs.getLength());
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ ++theAttributeCount;
+ }
+
XalanSourceTreeAttr** const theAttributeVector =
theAttributeCount == 0 ? 0 :
m_attributesVector.allocate(theAttributeCount);
@@ -718,7 +805,7 @@
if (theAttributeCount != 0)
{
- createAttributes(attrs, theAttributeVector, theAttributeCount,
theNewElement);
+ createAttributes(attrs, theAttributeVector, theNewElement,
fAddXMLNamespaceAttribute);
}
return theNewElement;
@@ -732,14 +819,20 @@
const Attributes& attrs,
XalanSourceTreeElement* theParentElement,
XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling)
+ XalanNode*
theNextSibling,
+ bool
fAddXMLNamespaceAttribute)
{
// We might have typedef'ed this to something smaller than unsigned int.
- const AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
+ AttributesCountType theAttributeCount =
AttributesCountType(attrs.getLength());
// assert that we didn't lose anything...
assert(theAttributeCount == attrs.getLength());
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ ++theAttributeCount;
+ }
+
XalanSourceTreeAttr** const theAttributeVector =
theAttributeCount == 0 ? 0 :
m_attributesVector.allocate(theAttributeCount);
@@ -758,7 +851,7 @@
if (theAttributeCount != 0)
{
- createAttributes(attrs, theAttributeVector, theAttributeCount,
theNewElement);
+ createAttributes(attrs, theAttributeVector, theNewElement,
fAddXMLNamespaceAttribute);
}
return theNewElement;
@@ -1087,11 +1180,40 @@
XalanSourceTreeDocument::createAttributes(
const Attributes& theAttributes,
XalanSourceTreeAttr** theAttributeVector,
- AttributesCountType
theAttributeCount,
- XalanSourceTreeElement* theOwnerElement)
+ XalanSourceTreeElement* theOwnerElement,
+ bool
fAddXMLNamespaceAttribute)
{
+ size_t theIndex = 0;
+
+ if (fAddXMLNamespaceAttribute == true)
+ {
+ // The constructor parameters for AttrNS are:
+ //
+ // name
+ // local name
+ // namespace URI
+ // prefix
+ // value
+ // owner element
+ // index
+ //
+ theAttributeVector[theIndex] =
+ m_attributeNSAllocator.create(
+
m_namesStringPool.get(DOMServices::s_XMLNamespacePrefix),
+
m_namesStringPool.get(DOMServices::s_XMLString),
+
m_namesStringPool.get(DOMServices::s_XMLNamespacePrefixURI),
+
m_namesStringPool.get(DOMServices::s_XMLNamespace),
+
m_valuesStringPool.get(DOMServices::s_XMLNamespaceURI),
+ theOwnerElement,
+ m_nextIndexValue++);
+
+ ++theIndex;
+ }
+
+ const AttributesCountType theSAXAttributeCount =
theAttributes.getLength();
+
// Now, create the attributes...
- for(AttributesCountType i = 0; i < theAttributeCount; ++i)
+ for(AttributesCountType i = 0; i < theSAXAttributeCount; ++i,
++theIndex)
{
const XalanDOMChar* const theQName =
theAttributes.getQName(i);
@@ -1106,7 +1228,7 @@
if (length(theURI) == 0)
{
- theAttributeVector[i] =
+ theAttributeVector[theIndex] =
m_attributeAllocator.create(
m_namesStringPool.get(theQName),
m_valuesStringPool.get(theValue),
@@ -1132,7 +1254,7 @@
// owner element
// index
//
- theAttributeVector[i] =
+ theAttributeVector[theIndex] =
m_attributeNSAllocator.create(
m_namesStringPool.get(theQName),
m_namesStringPool.get(theLocalName),
@@ -1160,7 +1282,7 @@
// always returned, so use insert(), rather than []
m_elementsByID.insert(
ElementByIDMapType::value_type(
-
c_wstr(theAttributeVector[i]->getValue()),
+
c_wstr(theAttributeVector[theIndex]->getValue()),
theOwnerElement));
}
}
1.13 +12 -7
xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.hpp
Index: XalanSourceTreeDocument.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XalanSourceTree/XalanSourceTreeDocument.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XalanSourceTreeDocument.hpp 2001/09/25 21:13:05 1.12
+++ XalanSourceTreeDocument.hpp 2001/10/03 18:17:34 1.13
@@ -344,7 +344,8 @@
const AttributeList& attrs,
XalanSourceTreeElement* theParentElement = 0,
XalanNode*
thePreviousSibling = 0,
- XalanNode*
theNextSibling = 0);
+ XalanNode*
theNextSibling = 0,
+ bool
fAddXMLNamespaceAttribute = false);
XalanSourceTreeElement*
createElementNode(
@@ -354,7 +355,8 @@
const Attributes& attrs,
XalanSourceTreeElement* theParentElement = 0,
XalanNode*
thePreviousSibling = 0,
- XalanNode*
theNextSibling = 0);
+ XalanNode*
theNextSibling = 0,
+ bool
fAddXMLNamespaceAttribute = false);
XalanSourceTreeElement*
createElementNode(
@@ -363,7 +365,8 @@
const PrefixResolver& thePrefixResolver,
XalanSourceTreeElement* theParentElement = 0,
XalanNode*
thePreviousSibling = 0,
- XalanNode*
theNextSibling = 0);
+ XalanNode*
theNextSibling = 0,
+ bool
fAddXMLNamespaceAttribute = false);
XalanSourceTreeElement*
createElementNode(
@@ -371,7 +374,8 @@
const Attributes& attrs,
XalanSourceTreeElement* theParentElement = 0,
XalanNode*
thePreviousSibling = 0,
- XalanNode*
theNextSibling = 0);
+ XalanNode*
theNextSibling = 0,
+ bool
fAddXMLNamespaceAttribute = false);
XalanSourceTreeComment*
createCommentNode(
@@ -448,7 +452,8 @@
AttributesCountType
theAttributeCount,
XalanSourceTreeElement* theParentElement,
XalanNode*
thePreviousSibling,
- XalanNode*
theNextSibling);
+ XalanNode*
theNextSibling,
+ bool
fAddXMLNamespaceAttribute);
XalanSourceTreeElement*
createElement(
@@ -464,8 +469,8 @@
createAttributes(
const Attributes& theAttributes,
XalanSourceTreeAttr** theAttributeVector,
- AttributesCountType
theAttributeCount,
- XalanSourceTreeElement* theOwnerElement);
+ XalanSourceTreeElement* theOwnerElement,
+ bool
fAddXMLNamespaceAttribute);
const XalanDOMString&
getTextNodeString(
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]