Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Schematron/Formatters/FormattingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private FormattingUtils()
{
}

private static XPathExpression precedingSiblingsExpr = XPathExpression.Compile("preceding-sibling::*");

/// <summary>
/// Returns the full path to the context node. Clone the navigator to avoid loosing positioning.
/// </summary>
Expand Down Expand Up @@ -75,9 +77,8 @@ public static string GetFullNodePosition(XPathNavigator context, string previous
}

int sibs = 1;

while (context.MoveToPrevious())
if (context.Name == curr) sibs++;
foreach (XPathNavigator prev in context.Select(precedingSiblingsExpr))
if (prev.Name == curr) sibs++;

if (context.MoveToParent())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Schematron/SyncEvaluationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private bool Evaluate(Pattern pattern, StringBuilder output)
/// different methods for accessing the underlying source.
/// <para>
/// This makes the implementation both performant and compliant with
/// the restriction about node mathing (see <linkref id="schematron" />) in the spec.
/// the restriction about node matching (see <linkref id="schematron" />) in the spec.
/// </para>
/// <para>
/// <seealso cref="DomMatchedNodes"/>
Expand Down