mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-17 18:12:04 +01:00
In XPath node() matches any node of any type. In an XSLT match pattern, node() matches everything except attributes and the document root node. Tweaked that match pattern grammar to introduce a new token in the AST.
This commit is contained in:
parent
adbdb31f65
commit
a52aafebd5
4 changed files with 11 additions and 5 deletions
|
@ -106,6 +106,7 @@ enum
|
|||
RelativePathPattern_id,
|
||||
StepPattern_id,
|
||||
ChildOrAttributeAxisSpecifier_id,
|
||||
NodeMatchPattern_id,
|
||||
|
||||
AttributeValueTemplate_id,
|
||||
DoubleLeftCurly_id,
|
||||
|
|
|
@ -357,10 +357,12 @@ struct xpath_grammar_match : public boost::spirit::grammar<xpath_grammar_match>
|
|||
RelativePathPattern = StepPattern >> *((base::SlashSlash | base::Slash) >> StepPattern);
|
||||
|
||||
// [5] StepPattern ::= ChildOrAttributeAxisSpecifier NodeTest Predicate*
|
||||
StepPattern = ChildOrAttributeAxisSpecifier >> base::NodeTest >> *base::Predicate;
|
||||
StepPattern = ChildOrAttributeAxisSpecifier >> (NodeMatchPattern|base::NodeTest) >> *base::Predicate;
|
||||
|
||||
// [6] ChildOrAttributeAxisSpecifier ::= AbbreviatedAxisSpecifier | ('child' | 'attribute') '::'
|
||||
ChildOrAttributeAxisSpecifier = ((base::Child | base::Attribute) >> discard_node_d[str_p("::")]) | base::AbbreviatedAxisSpecifier;
|
||||
|
||||
NodeMatchPattern = str_p("node()");
|
||||
} // definition
|
||||
|
||||
boost::spirit::rule<ScannerT, boost::spirit::parser_tag<Pattern_id> > const&
|
||||
|
@ -375,6 +377,7 @@ struct xpath_grammar_match : public boost::spirit::grammar<xpath_grammar_match>
|
|||
boost::spirit::rule<ScannerT, boost::spirit::parser_tag<RelativePathPattern_id> > RelativePathPattern;
|
||||
boost::spirit::rule<ScannerT, boost::spirit::parser_tag<StepPattern_id> > StepPattern;
|
||||
boost::spirit::rule<ScannerT, boost::spirit::parser_tag<ChildOrAttributeAxisSpecifier_id> > ChildOrAttributeAxisSpecifier;
|
||||
boost::spirit::rule<ScannerT, boost::spirit::parser_tag<NodeMatchPattern_id> > NodeMatchPattern;
|
||||
}; // definition<ScannerT>
|
||||
}; // xpath_grammar_match
|
||||
|
||||
|
|
|
@ -337,8 +337,8 @@ private:
|
|||
factory[impl::NameTest_id] = createSingleMatchStep;
|
||||
factory[impl::QName_id] = createSingleMatchStep;
|
||||
factory[impl::NCName_id] = createSingleMatchStep;
|
||||
factory[impl::NodeMatchPattern_id] = createSingleMatchStep;
|
||||
factory[impl::AnyName_id] = createSingleMatchStep;
|
||||
factory[impl::Node_id] = createSingleMatchStep;
|
||||
factory[impl::Text_id] = createSingleMatchStep;
|
||||
factory[impl::Comment_id] = createSingleMatchStep;
|
||||
factory[impl::ProcessingInstruction_id] = createSingleMatchStep;
|
||||
|
@ -465,6 +465,7 @@ private:
|
|||
names[impl::RelativePathPattern_id] = SA::construct_from_utf8("RelativePathPattern");
|
||||
names[impl::StepPattern_id] = SA::construct_from_utf8("StepPattern");
|
||||
names[impl::ChildOrAttributeAxisSpecifier_id] = SA::construct_from_utf8("ChildOrAttributeAxisSpecifier");
|
||||
names[impl::NodeMatchPattern_id] = SA::construct_from_utf8("node()");
|
||||
|
||||
names[impl::AttributeValueTemplate_id] = SA::construct_from_utf8("AttributeValueTemplate");
|
||||
names[impl::DoubleLeftCurly_id] = SA::construct_from_utf8("{{");
|
||||
|
@ -820,8 +821,8 @@ double XPath<string_type, string_adaptor>::defaultPriority(typename impl::types<
|
|||
return 0;
|
||||
}
|
||||
|
||||
case impl::NodeMatchPattern_id:
|
||||
case impl::AnyName_id:
|
||||
case impl::Node_id:
|
||||
case impl::Text_id:
|
||||
case impl::Comment_id:
|
||||
case impl::ProcessingInstruction_id:
|
||||
|
|
|
@ -399,16 +399,17 @@ private:
|
|||
case impl::SlashSlash_id:
|
||||
case impl::SelfSelect_id:
|
||||
case impl::ParentSelect_id:
|
||||
case impl::Node_id:
|
||||
{
|
||||
++node;
|
||||
return new AnyNodeTest<string_type, string_adaptor>();
|
||||
} // case Node_id
|
||||
|
||||
case impl::Node_id:
|
||||
case impl::NodeMatchPattern_id:
|
||||
{
|
||||
++node;
|
||||
return new NodeNodeTest<string_type, string_adaptor>();
|
||||
} // case Node_id
|
||||
} // case NodeMatchPattern_id
|
||||
|
||||
case impl::Slash_id:
|
||||
return new RootNodeTest<string_type, string_adaptor>();
|
||||
|
|
Loading…
Reference in a new issue