OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

an xpath/xsl question: why must arguments be path expressions?




The result of a literal parse of the xpath expression (from WD-xsl-19980818)

 "list[attribute(ordered)='yes']/item[first-of-type()]"

follows below. I'm trying to understand why path expressions are
ultimately specified as the basis for arguments. Which causes things
like "...(ordered)..."
to parse as a location path.

1. Is there a discussion somewhere about how to interpret path
expressions when used as arguments. use cases? examples?

2. Is there another bnf somewhere which permits qnames to appear
directly as primary expressions? This would, for one thing, permit them
to appear directly as arguments.

3. Even an expression such as

 "list[attribute('ordered')='yes']/item[first-of-type()]"

which may be non-sensical, yields a parse on the order of

(|Argument|
 (|Expr|
  (|OrExpr|
   (|AndExpr|
    (|EqualityExpr|
     (|RelationalExpr|
      (|AdditiveExpr|
       (|MultiplicativeExpr|
        (|UnaryExpr|
         (|UnionExpr|
          (|PathExpr|
           (|FilterExpr|
            (|PrimaryExpr|
             (|Literal|
              . "ordered"))))))))))))))

Where, in this case, one could argue that the argument-context dependent
reduction of the filter expression to an "ordered" literal argument
makes sense, to do the same thing to the name test (see below) which
resulted from the qualified name in "...(ordered)..." is somewhat counterintuitive.

4. I found nothing in the bnf which would have permitted a result on the
order of

(|Argument|
 (|QName|
  (|LocalPart|
   . |xml|::|ordered|))

even though I would have thought that this is what one would have
desired: the grammar would appear to prescribe a path expression. 

5. If one changes the bnf in a manner such as the following (wrt the
numbering from REC-xpath-19991116)

// [15]   
   PrimaryExpr ::= Literal | Number | VariableReference | FunctionCall
                 | ( '(' Expr ')' )
// [15.1]
                 | QName

one can at least produce a result such as

(|Argument|
 (|Expr|
  (|OrExpr|
   (|AndExpr|
    (|EqualityExpr|
     (|RelationalExpr|
      (|AdditiveExpr|
       (|MultiplicativeExpr|
        (|UnaryExpr|
         (|UnionExpr|
          (|PathExpr|
           (|FilterExpr|
            (|PrimaryExpr|
             (|QName|
              (|LocalPart|
               . |xml|::|ordered|)))))))))))))))

which is a compromise. Is this what implementors are actually doing?


6. Introducing an option such as the above in the production for primary
expressions makes the grammar ambiguous. I found no disambiguation rules
in the xpath draft which would serves to resolve this. I've read the
lexical disambiguation rules but do not understand them to apply to an
expression such as this one.

How are implementors resolving this ambiguity?.


5. The full parse according to the literally transcribed bnf follows here.

(|LocationPath|
 (|RelativeLocationPath|
  (|Step|
   (|NodeTest|
    (|NameTest|
     (|QName|
      (|LocalPart|
       . |xml|::|list|))))
   (|Predicate|
    (|PredicateExpr|
     (|Expr|
      (|OrExpr|
       (|AndExpr|
        (|EqualityExpr|
         (|RelationalExpr|
          (|AdditiveExpr|
           (|MultiplicativeExpr|
            (|UnaryExpr|
             (|UnionExpr|
              (|PathExpr|
               (|FilterExpr|
                (|PrimaryExpr|
                 (|FunctionCall|
                  (|FunctionName|
                   (|QName|
                    (|LocalPart|
                     . |xml|:|attribute|)))
                  (|ArgumentSequence|
                   (|Argument|
                    (|Expr|
                     (|OrExpr|
                      (|AndExpr|
                       (|EqualityExpr|
                        (|RelationalExpr|
                         (|AdditiveExpr|
                          (|MultiplicativeExpr|
                           (|UnaryExpr|
                            (|UnionExpr|
                             (|PathExpr|
                              (|LocationPath|
                               (|RelativeLocationPath|
                                (|Step|
                                 (|NodeTest|
                                  (|NameTest|
                                   (|QName|
                                    (|LocalPart|
                                     . |xml|::|ordered|))))))))))))))))))))))))))))
         (|eqOp| . |xml|:=)
         (|EqualityExpr|
          (|RelationalExpr|
           (|AdditiveExpr|
            (|MultiplicativeExpr|
             (|UnaryExpr|
              (|UnionExpr|
               (|PathExpr|
                (|FilterExpr|
                 (|PrimaryExpr|
                  (|Literal|
                   . "yes")))))))))))))))))
  (|SingleSlash| . |xml|:/)
  (|RelativeLocationPath|
   (|Step|
    (|NodeTest|
     (|NameTest|
      (|QName|
       (|LocalPart|
        . |xml|::|item|))))
    (|Predicate|
     (|PredicateExpr|
      (|Expr|
       (|OrExpr|
        (|AndExpr|
         (|EqualityExpr|
          (|RelationalExpr|
           (|AdditiveExpr|
            (|MultiplicativeExpr|
             (|UnaryExpr|
              (|UnionExpr|
               (|PathExpr|
                (|FilterExpr|
                 (|PrimaryExpr|
                  (|FunctionCall|
                   (|FunctionName|
                    (|QName|
                     (|LocalPart|
                      . |xml|::|first-of-type|))))))))))))))))))))))