1. A method for calculating an inferred type of a step in a path expression having an input expression followed by the step, the input expression having an associated input expression type with an associated input expression type cardinality, the step having an axis and a node test, the method comprising: preserving the input expression type cardinality for calculating the inferred type of the step; and calculating the inferred type of the step in accordance with the preserved input expression type cardinality, the axis, and the node test.