Project

Profile

Help

AugmentedSource doesnt Augment

Added by Anonymous almost 16 years ago

Legacy ID: #6368953 Legacy Poster: David Lee (daldei)

First off I realize this is in the "dark realm" of unsupported non-public implementation of Saxon, so I am not asking it be "fixed" but am reporting it as "non obvious" In a previous question/answer I asked how to turn a TinyTree model node into a Tree model node (so I could use MutableNodeInfo). The suggestion was to wrap it in an AugmentedSource and rebuild a tree. I wrote the following function: private XdmNode build( Source src ) throws SaxonApiException { AugmentedSource asrc = AugmentedSource.makeAugmentedSource(src); asrc.setTreeModel(Builder.LINKED_TREE); return mBuilder.build(asrc); } Where mBuilder is a DocumentBuilder created with a Processor previously setup with TINY_TREE as the model, and Source is from a call to XdmNode.asSource() This works great ... well It did ... as long as the node isnt a document. But when the node is a document then the build() method totally ignores the tree model of the augmented source and directly returns the underlying node without rebuilding it. I tracked this down to : Configuration.buildDocument() line 2909 if (underSource instanceof DocumentInfo || underSource instanceof DOMSource) { If the augmented source wraps a DocumentInfo its returned directly, and is not augmented at all... My guess is that this is an optimization to avoid rebuilding documents ... which I'm all for ... except that AugmentedSource is supposed to ... well "augment" ... I think I would work around this "feature" but not augmenting the document but maybe get the root element which isnt a Document and use that instead ... but that goes against a lot of things where I have to work really hard to ADD a document node when one isnt present ... I think that this is an indication I'm digging too deep into SaxonNoManLand ... and I think I should take the more recent suggestion of not trying to do this, and instead use another non-saxon tree entirely , (suggestion was "xom" which I think is worth investigating) In any case, I'm curious if this is considered a bug or a feature.


Replies (1)

RE: AugmentedSource doesnt Augment - Added by Anonymous almost 16 years ago

Legacy ID: #6369071 Legacy Poster: David Lee (daldei)

Sorry I hit "Refresh" by accident and it reposted this question

    (1-1/1)

    Please register to reply