Project

Profile

Help

Bug #6407

closed

Tree Model option -tree seems to be ignored for initial source documents

Added by Adrian Bird 8 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Command Line
Sprint/Milestone:
-
Start date:
2024-04-29
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

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

Commands.txt (561 Bytes) Commands.txt commands used to generate the output Adrian Bird, 2024-04-29 14:10
TreeModelTest.xslt (484 Bytes) TreeModelTest.xslt simple stylesheet Adrian Bird, 2024-04-29 14:10
TreeModelTest_linked.txt (632 Bytes) TreeModelTest_linked.txt output from -t -tree:linked Adrian Bird, 2024-04-29 14:10
TreeModelTest_tiny.txt (672 Bytes) TreeModelTest_tiny.txt output from -t -tree:tiny Adrian Bird, 2024-04-29 14:10
TreeModelTest_tinyc.txt (682 Bytes) TreeModelTest_tinyc.txt output from -t -tree:tinyc Adrian Bird, 2024-04-29 14:10
TreeModelTestData.xml (79 Bytes) TreeModelTestData.xml simple source file Adrian Bird, 2024-04-29 14:10
Actions #1

Updated by Michael Kay 8 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).

Actions #2

Updated by Michael Kay 8 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.

Actions #3

Updated by Michael Kay 8 months ago

The Query command line has the same problem.

Actions #4

Updated by Michael Kay 8 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.

Actions #5

Updated by O'Neil Delpratt 6 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

Also available in: Atom PDF