Bug #6407
closedTree Model option -tree seems to be ignored for initial source documents
100%
Description
I have been looking at the different tree models that can be defined in Saxon and seem to have come across a problem.
The command line documentation, https://www.saxonica.com/documentation12/index.html#!using-xsl/commandline, says: -tree:(linked|tiny|tinyc) Selects the implementation of the internal tree model: tiny selects the "tiny tree" model (the default), linked selects the linked tree model, tinyc selects the "condensed tiny tree" model. See Choosing a tree model.
I have tried all 3 tree models and the output, with -t, shows that for all 3 values the tiny tree, net.sf.saxon.tree.tiny.TinyBuilder, is used when reading the source document. When I read the same document via doc(base-uri()) then the trace shows the tree I chose being used.
I've attached some files:
TreeModelTestData.xml - very simple source file
TreeModelTest.xslt - my simple stylesheet that reads the source document again
Commands.txt - a copy of the commands I ran (I couldn't see any way of getting Saxon to output the parameters it was using)
TreeModelTest_tiny.txt - the output from -t -tree:tiny. You will see the tiny tree is used both times which is what I expect.
TreeModelTest_linked.txt - the output from -t -tree:linked. You will see the tiny tree is used first and then the linked tree when the source file is read again.
TreeModelTest_tinyc.txt - the output from -t -tree:tinyc. You will see the tiny tree is used first and then the tinyc tree when the source file is read again.
As a minor comment there is an error on the Choosing a tree model page, https://www.saxonica.com/documentation12/index.html#!sourcedocs/tree-models/choosingmodel - it has -tree:condensed but it should be -tree:tinyc.
Adrian
Files
Updated by Michael Kay 7 months ago
- Status changed from New to In Progress
- Platforms Java added
That is indeed a surprise, especially since I was using this command line option happily yesterday while investigating bug #6405. But it turns out the test case was reading the target document as a secondary document using doc()
, not using the -s option on the command line.
(It illustrates a secondary problem, which is that we have far too few tests using the command line. This is mainly because it's quite hard to make assertions about the expected results. We tend to have unit tests that use the equivalent configuration APIs).
Updated by Michael Kay 7 months ago
It's not immediately obvious how best to fix this.
The -tree option causes a call on config.setTreeModel(), which sets the tree model in the Configuration's defaultParseOptions
. The s9api DocumentBuilder
has its own treeModel
property. The Javadoc for DocumentBuilder.setTreeModel()
says that by default the TinyTree
is used irrespective of any options set at configuration level. So I guess we stick with that even though it seems a slightly odd design decision. The command line code should set the tree model on the s9api DocumentBuilder
explicitly.
Updated by Michael Kay 7 months ago
The Query
command line has the same problem.
Updated by Michael Kay 7 months ago
- Category set to Command Line
- Status changed from In Progress to Resolved
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Applies to branch 12, trunk added
- Fix Committed on Branch 12, trunk added
- Platforms .NET added
Fixed on the 12.x and main branches, including the documentation fix.
Updated by O'Neil Delpratt 5 months ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 12.5 added
Bug fix applied in the Saxon 12.5 Maintenance release.
Please register to edit this issue