Menu

Using URL parameters in a document() url

Help
2001-12-10
2012-10-08
  • Mike Youngstrom

    Mike Youngstrom - 2001-12-10

    I am having trouble url paramaters into the document() function in SAXON.  Am I doing something wrong or am I not allowed to pass url parameters into a document function?

    Works!!!!!

    <xsl:variable name="person" select="document('People.xml')"/>

    Does not work!!!!!

    <xsl:variable name="person" select="document('People.xml?id=1234')"/>

    Any thoughts?

    Mike

     
    • Daniel Parker

      Daniel Parker - 2001-12-11

      You can pass whatever the underlying URIResolver can handle.  Saxon's standard URIResolver doesn't recognize parameters passed that way; if you want to do that you need to write your own URIResolver and configure saxon to use it.  However, saxon's standard URIResolver does recognize a fragment identifier, the piece that comes after a # symbol, and interprets it as an ID attribute in the XML document.  So, if your id is an ID attribute, that is, if it is declared in the DTD as being of type ID, you should be able to write

      document('People.xml#1234')

      Regards,
      Daniel Parker
      http://presentingxml.sourceforge.net/

       
    • Michael Kay

      Michael Kay - 2001-12-11

      I don't see any reason why Saxon's URIResolver shouldn't accept URI references with parameters, though I'm not sure I've ever tried it myself. All that Saxon does is (a) if the URI is relative it turns it into an absolute URI using the appropriate base URI, and (b) it then passes it to the Java VM to get the resource. If a URI can't be retrieved, it's basically a Java problem not a Saxon problem. Unless there's some hidden corner of the Java API that I need to invoke to make this work, of course....

      Mike Kay