Can I pass a querystring to an XML SYSTEM uri?

Discussion in 'XML' started by John Wilkin, Aug 4, 2005.

  1. John Wilkin

    John Wilkin Guest

    I'm using an xsl stylesheet to transform an xml source from a remote
    URL. I'm using the xslt.pl processor available from
    "http://www.dopscripts.com/doc/description.html". The remote URL is
    placed in the prologue/prolog (US English spellings have never come
    naturally to me) of the xsl document as follows:

    <?xml version="1.0"?>
    <!DOCTYPE my-news [<!ENTITY news SYSTEM "http://path.to/xmlfile.xml">]>
    <xsl:stylesheet version="1.0">
    <xsl:variable name="news">&news;</xsl:variable>
    <xsl:template match="/">
    <xsl:for-each select="$news">

    etc

    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>


    Now say the url of the XML source is
    "http://path.to/xmlfile.xml?id=*id*" where *id* is a querystring
    parameter, is there any way of passing this value to the SYSTEM uri?

    I know there are methods of passing external parameters into xsl, but as
    this question is about what happens before the xsl begins this is more
    of a general xml question than a specific xsl question
     
    John Wilkin, Aug 4, 2005
    #1
    1. Advertising

  2. John Wilkin

    pantagruel Guest

    nope.

    DTDs have no knowledge of querystrings, therefore you cannot refer to a
    querystring from a DTD. Could be chaotic if you could. Of course the
    location for your dtd can be a relative uri.

    So either you would have to alter the xml programmatically before
    sending it onward to put in the right value, or set it up in such a way
    that you do not need to do this.
     
    pantagruel, Aug 6, 2005
    #2
    1. Advertising

  3. In article <>,
    pantagruel <> wrote:

    >DTDs have no knowledge of querystrings, therefore you cannot refer to a
    >querystring from a DTD.


    DTDs have no knowledge of querystrings, so they have no way of
    preventing you from using one. You can perfectly well have

    <!DOCTYPE foo SYSTEM "http://example.org/my.cgi?whatever">

    or something similar for an entity declaration, and quite likely for
    the URI you pass to your XML processor in the first place.

    What you can't do of course is control *what* query is used in a
    SYSTEM id, except by changing the file itself.

    Fragment identifiers are quite another matter, and are prohibited
    in system ids.

    -- Richard
     
    Richard Tobin, Aug 6, 2005
    #3
  4. John Wilkin

    pantagruel Guest

    My impression was that he wanted to do

    " http://path.to/xmlfile.xml?id= *id*"" where when he said id was a
    querystring parameter he meant that id was a querystring parameter
    being passed in the querystring for his application.

    as in
    http://mysite.com/application?id=howdy
    then his dtd will resolve to
    "http://path.to/xmlfile.xml?id=howdy"

    this was what I was trying to convey by saying 'refer to a querystring'
    as opposed to 'writing a querystring'.
     
    pantagruel, Aug 7, 2005
    #4
  5. John Wilkin

    John Wilkin Guest

    Thanks chaps

    You've both answered my question - no need to argue :)

    I wanted to know if there was something I could use in that context which
    was analogous to asp.net's Request.QueryString["id"]. Obviously I can't,
    I'll see what I can do in the perl layer

    Cheers

    John
     
    John Wilkin, Aug 8, 2005
    #5
  6. John Wilkin wrote:
    > Thanks chaps
    >
    > You've both answered my question - no need to argue :)
    >
    > I wanted to know if there was something I could use in that context which
    > was analogous to asp.net's Request.QueryString["id"]. Obviously I can't,
    > I'll see what I can do in the perl layer
    >
    > Cheers
    >
    > John
    >
    >


    hi,

    i'm sure you'll find something usefull with the XSLT's document() function :

    try this :

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0">
    <xsl:param name="id"/>
    <xsl:variable name="news"
    select="document(concat('http://path.to/xmlfile.xml?id=', $id)"/>
    <xsl:template match="/">
    <xsl:for-each select="$news">
    --
    Cordialement,

    ///
    (. .)
    -----ooO--(_)--Ooo-----
    | Philippe Poulard |
    -----------------------
     
    Philippe Poulard, Aug 8, 2005
    #6
  7. John Wilkin

    John Wilkin Guest

    Philippe Poulard wrote:

    > hi,
    >
    > i'm sure you'll find something usefull with the XSLT's document() function :
    >
    > try this :
    >
    > <?xml version="1.0"?>
    > <xsl:stylesheet version="1.0">
    > <xsl:param name="id"/>
    > <xsl:variable name="news"
    > select="document(concat('http://path.to/xmlfile.xml?id=', $id)"/>
    > <xsl:template match="/">
    > <xsl:for-each select="$news">
    > --
    > Cordialement,
    >
    > ///
    > (. .)
    > -----ooO--(_)--Ooo-----
    > | Philippe Poulard |
    > -----------------------


    Thanks for the tip, I didn't know about the document() function. Unfortunately
    the xsltp.pl processor doesn't seem to either, but this could come in very
    useful if I try to do anything similar using client side transformations.

    One day all browsers will support xslt and life will be much easier

    Merci beaucoup

    John
     
    John Wilkin, Aug 9, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Harris
    Replies:
    0
    Views:
    6,381
    Simon Harris
    May 10, 2005
  2. Stanimir Stamenkov
    Replies:
    1
    Views:
    2,475
    Stanimir Stamenkov
    Aug 17, 2005
  3. Pavel
    Replies:
    2
    Views:
    1,651
    Peter Flynn
    Aug 4, 2004
  4. etheriau
    Replies:
    1
    Views:
    668
    Pavel
    Aug 23, 2004
  5. Joe Curry

    Invalid URI: The format of the URI could not be determined.

    Joe Curry, Oct 8, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    344
    Joe Curry
    Oct 8, 2003
Loading...

Share This Page