Can I pass a querystring to an XML SYSTEM uri?

J

John Wilkin

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
 
P

pantagruel

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.
 
R

Richard Tobin

pantagruel said:
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
 
J

John Wilkin

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
 
P

Philippe Poulard

John said:
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 |
-----------------------
 
J

John Wilkin

Philippe said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top