You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Evert Haasdijk <E....@cable.a2000.nl> on 2001/04/24 13:25:43 UTC
Losing ID's on importNode()
Hi all,
My application 'copies' part of an XML document into another (using
DOM_Document::importNode()). Now, some of the imported DOM nodes have an ID,
but I can't retrieve them after importing them (calling
DOM_Document::getElementById()) because the document's fNodeIDMap isn't
updated on importNode().
Is there any way to update the ID map short of writing the new document and
re-parsing it?
TIA, Evert
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Reuse of SAX parser object!
Posted by Ravindra Shet <ra...@sasken.com>.
Hi,
Can anyone tell me/direct me to literature, on reusing the SAX parser object.
Would also be interested in optimization and performance tips.
Regards
Ravindra Shet
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Verifying DTD compliance in memory
Posted by Evert Haasdijk <E....@cable.a2000.nl>.
Hi all,
When modifying or creating a DOM_Document in memory, there seems to be only
one way to check that the results are valid in terms of the DTD. Also,
a lot of information is generated during the parse of a stream that cannot
be updated through the DOM (e.g. DOM_Document::getElementById() only works
if the element was parsed, there is no way to get it to work for newly
created or imported nodes).
It would be *very* useful to have some kind of 'parser' that, rather than a
stream, takes a DOM_Document and checks that against the DTD, updating the
document's ID map and what have you.
Has anyone tried creating such a beast or does anyone have any ideas how
that could be done? And, is anyone else interested in such a thing or am I
the only one?
TIA, Evert
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Updating ID Attributes
Posted by Rob Snell <ro...@ist.co.uk>.
On Thu, 26 Apr 2001, Evert Haasdijk wrote:
> There doesn't seem to be any way to add an attribute to a DOM_Element and
> specify that it's an ID. Similarly, changing the content of an ID atttribute
Yes I couldn't see a way of doing this either. Perhaps the parser
will implicitly detect attributes of type ID if they're defined as such
in the DTD. I haven't checked this.
Rob.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Updating ID Attributes
Posted by Evert Haasdijk <E....@cable.a2000.nl>.
Hi all,
There doesn't seem to be any way to add an attribute to a DOM_Element and
specify that it's an ID. Similarly, changing the content of an ID atttribute
isn't - as far as I can tell - reflected in the document.
Is there any way around this? I know that you can tell an AttrImpl that it's
an ID and that I can update a DocumentImpl's map of node ID's, but
obviously, I can't just get at these implementation classes.
Has anyone tried to solve this problem? Or does anyone have a suggestion?
TIA, Evert
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: Losing ID's on importNode()
Posted by Evert Haasdijk <E....@cable.a2000.nl>.
Hi all,
I've modified DocumentImpl::importNode() to update the importing document's
map fNodeIDMap when importing nodes with ID attributes.
The only problem occurs if the importing document's DTD doesn't define the
imported attribute as an ID. Is there any way to check against that?
Here's the code:
NodeImpl *DocumentImpl::importNode(NodeImpl *source, bool deep)
{
// SNIPPETYSNIP
case DOM_Node::ATTRIBUTE_NODE :
{
if (source->getLocalName() == null)
newnode = createAttribute(source->getNodeName());
else
newnode = createAttributeNS(source->getNamespaceURI(),
source->getNodeName());
// if source is an AttrImpl from this very same implementation
// avoid creating the child nodes if possible
// if (source instanceof AttrImpl) {
AttrImpl *attr = (AttrImpl *) source;
if (attr->hasStringValue()) {
AttrImpl *newattr = (AttrImpl *) newnode;
newattr->setValue(attr->getValue());
deep = false;
}
else {
deep = true;
}
//
// start importing ID
// The imported attribute is an ID. Add it to the hashtable of
IDs
// that is constructed for use by GetElementByID().
//
AttrImpl *newattr = (AttrImpl *) newnode;
if (attr->isIdAttr())
{
newattr->isIdAttr(true);
if (fNodeIDMap == 0)
fNodeIDMap = new NodeIDMap(500);
fNodeIDMap->add(newattr);
}
//
// end importing ID
//
// }
// else {
// // Kids carry value
// deep = true;
// }
}
break;
// SNIPPETYSNIP
> -----Original Message-----
> From: Evert Haasdijk [mailto:E.Haasdijk@cable.a2000.nl]
> Sent: Tuesday, April 24, 2001 13:26 PM
> To: xerces-c-dev@xml.apache.org
> Subject: Losing ID's on importNode()
>
>
> Hi all,
>
> My application 'copies' part of an XML document into another (using
> DOM_Document::importNode()). Now, some of the imported DOM nodes
> have an ID,
> but I can't retrieve them after importing them (calling
> DOM_Document::getElementById()) because the document's fNodeIDMap isn't
> updated on importNode().
> Is there any way to update the ID map short of writing the new
> document and
> re-parsing it?
>
> TIA, Evert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org