471,357 Members | 1,130 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Can I pass a querystring to an XML SYSTEM uri?

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

Aug 4 '05 #1
6 2524
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.

Aug 6 '05 #2
In article <11**********************@g49g2000cwa.googlegroups .com>,
pantagruel <br*@itnisk.com> 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
Aug 6 '05 #3
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'.

Aug 7 '05 #4
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
Aug 8 '05 #5
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 |
-----------------------
Aug 8 '05 #6


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
Aug 9 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by DC Gringo | last post: by
3 posts views Thread by Naseem | last post: by
3 posts views Thread by Sharon | last post: by
1 post views Thread by =?Utf-8?B?ZG90TmV0RGF2ZQ==?= | last post: by
2 posts views Thread by =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.