src/xmlpatterns/parser/qquerytransformparser.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   416 {
   416 {
   417     Template::Ptr &e = parseInfo->namedTemplates[name];
   417     Template::Ptr &e = parseInfo->namedTemplates[name];
   418 
   418 
   419     if(e)
   419     if(e)
   420     {
   420     {
   421         parseInfo->staticContext->error(QtXmlPatterns::tr("A template by name %1 "
   421         parseInfo->staticContext->error(QtXmlPatterns::tr("A template with name %1 "
   422                                                           "has already been declared.")
   422                                                           "has already been declared.")
   423                                         .arg(formatKeyword(parseInfo->staticContext->namePool(),
   423                                         .arg(formatKeyword(parseInfo->staticContext->namePool(),
   424                                                                          name)),
   424                                                                          name)),
   425                                         ReportContext::XTSE0660,
   425                                         ReportContext::XTSE0660,
   426                                         fromYYLTYPE(sourceLocator, parseInfo));
   426                                         fromYYLTYPE(sourceLocator, parseInfo));
   880 
   880 
   881 static void variableUnavailable(const QXmlName &variableName,
   881 static void variableUnavailable(const QXmlName &variableName,
   882                                 const ParserContext *const parseInfo,
   882                                 const ParserContext *const parseInfo,
   883                                 const YYLTYPE &location)
   883                                 const YYLTYPE &location)
   884 {
   884 {
   885     parseInfo->staticContext->error(QtXmlPatterns::tr("No variable by name %1 exists")
   885     parseInfo->staticContext->error(QtXmlPatterns::tr("No variable with name %1 exists")
   886                                        .arg(formatKeyword(parseInfo->staticContext->namePool(), variableName)),
   886                                        .arg(formatKeyword(parseInfo->staticContext->namePool(), variableName)),
   887                                     ReportContext::XPST0008, fromYYLTYPE(location, parseInfo));
   887                                     ReportContext::XPST0008, fromYYLTYPE(location, parseInfo));
   888 }
   888 }
   889 
   889 
   890 /**
   890 /**
  4026 #line 1678 "querytransformparser.ypp"
  4026 #line 1678 "querytransformparser.ypp"
  4027     {
  4027     {
  4028         const AtomicValue::Ptr val(Decimal::fromLexical((yyvsp[(2) - (2)].sval)));
  4028         const AtomicValue::Ptr val(Decimal::fromLexical((yyvsp[(2) - (2)].sval)));
  4029         if(val->hasError())
  4029         if(val->hasError())
  4030         {
  4030         {
  4031             parseInfo->staticContext->error(QtXmlPatterns::tr("The value of attribute %1 must of type %2, which %3 isn't.")
  4031             parseInfo->staticContext->error(QtXmlPatterns::tr("The value of attribute %1 must be of type %2, which %3 isn't.")
  4032                                                              .arg(formatKeyword(QLatin1String("priority")),
  4032                                                              .arg(formatKeyword(QLatin1String("priority")),
  4033                                                                   formatType(parseInfo->staticContext->namePool(), BuiltinTypes::xsDecimal),
  4033                                                                   formatType(parseInfo->staticContext->namePool(), BuiltinTypes::xsDecimal),
  4034                                                                   formatData((yyvsp[(2) - (2)].sval))),
  4034                                                                   formatData((yyvsp[(2) - (2)].sval))),
  4035                                             ReportContext::XTSE0530,
  4035                                             ReportContext::XTSE0530,
  4036                                             fromYYLTYPE((yyloc), parseInfo));
  4036                                             fromYYLTYPE((yyloc), parseInfo));
  4102                                             ReportContext::XQST0070, fromYYLTYPE((yyloc), parseInfo));
  4102                                             ReportContext::XQST0070, fromYYLTYPE((yyloc), parseInfo));
  4103         }
  4103         }
  4104         else if ((yyvsp[(5) - (7)].sval) == CommonNamespaces::XML || (yyvsp[(3) - (7)].sval) == QLatin1String("xml"))
  4104         else if ((yyvsp[(5) - (7)].sval) == CommonNamespaces::XML || (yyvsp[(3) - (7)].sval) == QLatin1String("xml"))
  4105         {
  4105         {
  4106              parseInfo->staticContext->error(QtXmlPatterns::tr(
  4106              parseInfo->staticContext->error(QtXmlPatterns::tr(
  4107                                             "The prefix %1 can not be bound. By default, it is already bound "
  4107                                             "The prefix %1 cannot be bound. By default, it is already bound "
  4108                                             "to the namespace %2.")
  4108                                             "to the namespace %2.")
  4109                                              .arg(formatKeyword("xml"))
  4109                                              .arg(formatKeyword("xml"))
  4110                                              .arg(formatURI(CommonNamespaces::XML)),
  4110                                              .arg(formatURI(CommonNamespaces::XML)),
  4111                                              ReportContext::XQST0070,
  4111                                              ReportContext::XQST0070,
  4112                                              fromYYLTYPE((yyloc), parseInfo));
  4112                                              fromYYLTYPE((yyloc), parseInfo));
  4413 #line 2002 "querytransformparser.ypp"
  4413 #line 2002 "querytransformparser.ypp"
  4414     {
  4414     {
  4415         allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(3) - (9)].enums.Bool));
  4415         allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(3) - (9)].enums.Bool));
  4416         if(variableByName((yyvsp[(5) - (9)].qName), parseInfo))
  4416         if(variableByName((yyvsp[(5) - (9)].qName), parseInfo))
  4417         {
  4417         {
  4418             parseInfo->staticContext->error(QtXmlPatterns::tr("A variable by name %1 has already "
  4418             parseInfo->staticContext->error(QtXmlPatterns::tr("A variable with name %1 has already "
  4419                                                               "been declared.")
  4419                                                               "been declared.")
  4420                                                .arg(formatKeyword(parseInfo->staticContext->namePool()->toLexical((yyvsp[(5) - (9)].qName)))),
  4420                                                .arg(formatKeyword(parseInfo->staticContext->namePool()->toLexical((yyvsp[(5) - (9)].qName)))),
  4421                                             parseInfo->isXSLT() ? ReportContext::XTSE0630 : ReportContext::XQST0049,
  4421                                             parseInfo->isXSLT() ? ReportContext::XTSE0630 : ReportContext::XQST0049,
  4422                                             fromYYLTYPE((yyloc), parseInfo));
  4422                                             fromYYLTYPE((yyloc), parseInfo));
  4423         }
  4423         }
  4453                     // TODO ensure that duplicates are trapped.
  4453                     // TODO ensure that duplicates are trapped.
  4454                 }
  4454                 }
  4455                 else
  4455                 else
  4456                 {
  4456                 {
  4457                     parseInfo->staticContext->error(QtXmlPatterns::tr("No value is available for the external "
  4457                     parseInfo->staticContext->error(QtXmlPatterns::tr("No value is available for the external "
  4458                                                                       "variable by name %1.")
  4458                                                                       "variable with name %1.")
  4459                                                        .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (9)].qName))),
  4459                                                        .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (9)].qName))),
  4460                                                     parseInfo->isXSLT() ? ReportContext::XTDE0050 : ReportContext::XPDY0002,
  4460                                                     parseInfo->isXSLT() ? ReportContext::XTDE0050 : ReportContext::XPDY0002,
  4461                                                     fromYYLTYPE((yyloc), parseInfo));
  4461                                                     fromYYLTYPE((yyloc), parseInfo));
  4462                 }
  4462                 }
  4463             }
  4463             }
  4672 
  4672 
  4673         for(; it != end; ++it)
  4673         for(; it != end; ++it)
  4674         {
  4674         {
  4675             if((*it)->name() == (yyvsp[(3) - (3)].functionArgument)->name())
  4675             if((*it)->name() == (yyvsp[(3) - (3)].functionArgument)->name())
  4676             {
  4676             {
  4677                 parseInfo->staticContext->error(QtXmlPatterns::tr("An argument by name %1 has already "
  4677                 parseInfo->staticContext->error(QtXmlPatterns::tr("An argument with name %1 has already "
  4678                                                    "been declared. Every argument name "
  4678                                                    "been declared. Every argument name "
  4679                                                    "must be unique.")
  4679                                                    "must be unique.")
  4680                                                    .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (3)].functionArgument)->name())),
  4680                                                    .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (3)].functionArgument)->name())),
  4681                                                 ReportContext::XQST0039, fromYYLTYPE((yyloc), parseInfo));
  4681                                                 ReportContext::XQST0039, fromYYLTYPE((yyloc), parseInfo));
  4682             }
  4682             }
  6677 
  6677 
  6678             if(func)
  6678             if(func)
  6679                 (yyval.expr) = create(func, (yyloc), parseInfo);
  6679                 (yyval.expr) = create(func, (yyloc), parseInfo);
  6680             else
  6680             else
  6681             {
  6681             {
  6682                 parseInfo->staticContext->error(QtXmlPatterns::tr("No function by name %1 is available.")
  6682                 parseInfo->staticContext->error(QtXmlPatterns::tr("No function with name %1 is available.")
  6683                                                    .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(1) - (4)].qName))),
  6683                                                    .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(1) - (4)].qName))),
  6684                                                 ReportContext::XPST0017, fromYYLTYPE((yyloc), parseInfo));
  6684                                                 ReportContext::XPST0017, fromYYLTYPE((yyloc), parseInfo));
  6685             }
  6685             }
  6686         }
  6686         }
  6687         else /* It's a call to a function created with 'declare function'.*/
  6687         else /* It's a call to a function created with 'declare function'.*/
  6927                                                                    ReportContext::XPST0081>((yyvsp[(7) - (8)].attributeHolders).at(i).first, parseInfo->staticContext,
  6927                                                                    ReportContext::XPST0081>((yyvsp[(7) - (8)].attributeHolders).at(i).first, parseInfo->staticContext,
  6928                                                                                             parseInfo->staticContext->namespaceBindings(),
  6928                                                                                             parseInfo->staticContext->namespaceBindings(),
  6929                                                                                             &ryy, true);
  6929                                                                                             &ryy, true);
  6930                 if(declaredAttributes.contains(att))
  6930                 if(declaredAttributes.contains(att))
  6931                 {
  6931                 {
  6932                     parseInfo->staticContext->error(QtXmlPatterns::tr("An attribute by name %1 has already appeared on this element.")
  6932                     parseInfo->staticContext->error(QtXmlPatterns::tr("An attribute with name %1 has already appeared on this element.")
  6933                                                       .arg(formatKeyword(parseInfo->staticContext->namePool(), att)),
  6933                                                       .arg(formatKeyword(parseInfo->staticContext->namePool(), att)),
  6934                                             ReportContext::XQST0040, fromYYLTYPE((yyloc), parseInfo));
  6934                                             ReportContext::XQST0040, fromYYLTYPE((yyloc), parseInfo));
  6935 
  6935 
  6936                 }
  6936                 }
  6937                 else
  6937                 else