Menu

base-uri() returns incorrect Base URI

Help
2011-08-16
2012-10-08
  • Nick Van den Bleeken

    We are using Saxon's XPath API directly (XPathEvaluator).

    It appears that the expression base-uri() is compiled as base-
    uri(ItemChecker(.)) and therefore doesn't returns the base URI of the static
    context but the base URI of the current context item.

    According to the spec :

    fn:base-uri() as xs:string

    Summary: This version of the function returns the value of the base-uri
    property from the static context using the preceding rules. The static context
    is discussed in Section 2.1.1 Static Context.

    I would have expected the result of base-uri() to be the base URI that was
    provided to the saxon StaticQueryContext object associated with the queries
    XPathEvaluator. What is the error in my reasoning? We need access to the base
    URI provided to the StaticQueryContext, could this be accessed in any other
    way?

    Kind regards,

    Nick Van den Bleeken

    1: http://www.w3.org/TR/2003/WD-xpath-functions-20031112/#func-base-
    uri

     
  • Michael Kay

    Michael Kay - 2011-08-16

    Your link is to a 2003 working draft of the XPath functions and operators
    specification. Please consult the final recommendation at
    http://www.w3.org/TR/xpath-functions/#func-base-uri.

    To get the base URI from the static context, you need to use the function
    static-base-uri().

     
  • Nick Van den Bleeken

    Thank you for the reply, sorry that I wasn't looking at the latest version of
    the spec.

    Having two differently named functions is much clearer, because it makes sense
    to have the current item as the default value if the argument is provided
    (most of the time you need this behavior anyway).