private QilNode ParseRelativePathPattern() { if (++parseRelativePath > MaxParseRelativePathDepth) { if (System.Xml.XmlConfiguration.XsltConfigSection.LimitXPathComplexity) { throw scanner.CreateException(System.Xml.Utils.Res.Xslt_InputTooComplex); } } QilNode opnd = ParseStepPattern(); if (scanner.Kind == LexKind.Slash) { scanner.NextLex(); opnd = ptrnBuilder.JoinStep(opnd, ParseRelativePathPattern()); } else if (scanner.Kind == LexKind.SlashSlash) { scanner.NextLex(); opnd = ptrnBuilder.JoinStep(opnd, ptrnBuilder.JoinStep( ptrnBuilder.Axis(XPathAxis.DescendantOrSelf, XPathNodeType.All, null, null), ParseRelativePathPattern() ) ); } --parseRelativePath; return(opnd); }
private QilNode ParseRelativePathPattern() { if (++_parseRelativePath > MaxParseRelativePathDepth) { if (LocalAppContextSwitches.LimitXPathComplexity) { throw _scanner.CreateException(SR.Xslt_InputTooComplex); } } QilNode opnd = ParseStepPattern(); if (_scanner.Kind == LexKind.Slash) { _scanner.NextLex(); opnd = _ptrnBuilder.JoinStep(opnd, ParseRelativePathPattern()); } else if (_scanner.Kind == LexKind.SlashSlash) { _scanner.NextLex(); opnd = _ptrnBuilder.JoinStep(opnd, _ptrnBuilder.JoinStep( _ptrnBuilder.Axis(XPathAxis.DescendantOrSelf, XPathNodeType.All, null, null), ParseRelativePathPattern() ) ); } --_parseRelativePath; return(opnd); }
/* * StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate* * ChildOrAttributeAxisSpecifier ::= @ ? | ('child' | 'attribute') '::' */ private QilNode ParseStepPattern() { QilNode opnd; XPathAxis axis; switch (scanner.Kind) { case LexKind.Dot: case LexKind.DotDot: throw scanner.CreateException(Res.XPath_InvalidAxisInPattern); case LexKind.At: //>> '@' axis = XPathAxis.Attribute; scanner.NextLex(); break; case LexKind.Axis: //>> AxisName '::' axis = XPathParser.GetAxis(scanner.Name, scanner); if (axis != XPathAxis.Child && axis != XPathAxis.Attribute) { throw scanner.CreateException(Res.XPath_InvalidAxisInPattern); } scanner.NextLex(); break; case LexKind.Name: case LexKind.Star: // NodeTest must start with Name or '*' axis = XPathAxis.Child; break; default: throw scanner.CreateException(Res.XPath_UnexpectedToken, scanner.RawValue); } XPathNodeType nodeType; string nodePrefix, nodeName; XPathParser.InternalParseNodeTest(scanner, axis, out nodeType, out nodePrefix, out nodeName); opnd = ptrnBuilder.Axis(axis, nodeType, nodePrefix, nodeName); while (scanner.Kind == LexKind.LBracket) { opnd = ptrnBuilder.Predicate(opnd, ParsePredicate(opnd), /*reverseStep:*/ false); } return(opnd); }