[XML-SIG] Another Sax2 Enhancement: dataSource

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Fri, 27 Apr 2001 19:34:40 +0200


> I need to be able to get from a DOM the filename or URI of the file it
> was constructed from (if it was constructed from a file). I didn't see
> anything in the code that preserved this data, so I've hacked my local
> copy of the code to add an optional "dataSource" parameter to the
> FromFile/URI/Stream methods that propogates to the Sax reader. This is
> set as the friend property _dataSource on the resulting DOM node.
> 
> Is this an appropriate solution?

I would not think so. Are you sure you need this on every node?
That seems to be quite expensive for a rarely-used extension.

If you really only put the parameter to FromFile into the tree, isn't
putting it into the document sufficient?

But then, aren't you interested in the data sources of the elements
originating from an external parsed entity?

> I need this because uparsed entity resolution does not preserve the
> absolute path of the entities, only the system ID as specified in the
> declaration. As I am using relative paths, I must have the path of the
> declaring document in order to be able to construct new DOMs from
> referenced XML document entities.

I'm not sure I understand. Are you saying that the DOM requires to
store the relative path in Entity::systemId? Where does the spec say
so?

> My business problem is processing a hyperdocument consisting of many
> subordinate documents, where each document is declared as an unparsed
> entity with a relative path (this hyperdocument is generated by an
> automatic process and the intent is for the resulting package of
> documents to be self contained so that it can be packaged and moved
> without the need to rework any external identifiers or catalog files).

To solve this problem, isn't it sufficient to carry the document's
system ID along with the document, instead of putting it *into* the
document?

Regards,
Martin