This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Passing external values into xsl stylesheet to select portions of xml file (apache/cocoon)


Hi.... I'm working on processing an xml news feed
supplied by a remote site who's structure is given
below. My setup is apache 1.3.19 running on NT, with
modules for php, mysql. My xml processing is being
handled by 'Cocoon' (version 1.8.2) also from
apache.org. I need to generate a list of headlines
linking to the stories, and need to select just a
single story for output - the storyid tag is the
obvious choice, but how can I insert this into the xsl
on demand? Here's the xml feed structure:

<?xml version="1.0" encoding="iso-8859-1"?>
<feed>
    <story type="breaking_news">
          <storyid>22497</storyid>
          <category><![CDATA[world_news]]></category>
          <date><![CDATA[foo]]></date>
          <time><![CDATA[foo]]></time>
          <revisionid><![CDATA[foo]]></revisionid>
          <headline><![CDATA[foo]]></headline>
          <byline><![CDATA[foo]]></byline>
          <deck><![CDATA[foo]]><deck>
          <body><![CDATA[foo]]><body>
          <picture><![CDATA[foo]]></picture>
         
<picturecaption><![CDATA[foo]]></picturecaption>
          <publisher><![CDATA[foo]]></publisher>
          <copyright><![CDATA[foo]]></copyright>
          <priority>foo</priority>
     </story>

     <story type="breaking_news">
          <storyid>23531</storyid>
          <category><![CDATA[world_news]]></category>
          ........
          ........
     </story>
<feed>



Here's the general idea of my xsl stylesheet:



<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="feed">

<xsl:processing-instruction name="cocoon-format">
type="text/html"
</xsl:processing-instruction>

....
html markup here
....

    <xsl:apply-templates/>

....
more html
..... 

</xsl:template>


<xsl:template match="story[category='business_news']">

....blah blah.... template stuff.....

</xsl:template>

<xsl:template match=...........etc >
.
.
.
.
</template>

<xsl:template match="story">
</xsl:template>

</xsl:stylesheet>


As you can see selecting all the stories by category
is no problem as there's only about 5 categories in
total, which I know beforehand... so I can use:

<xsl:template match="story[category='business_news']">

etc in 5 different stylesheets, and using an empty
story template to eliminate output from all other
story elements:

<xsl:template match="story">
</xsl:template>

I need something like this to get it to send only a
particular story:

<xsl:template match="story[storyid='22546']">

How can I pass a particular value for storyid into the
xsl in real time for when the user clicks a link for
story number 22222 for example???

I've looked at <xsl:variable> ...but these always seem
to be set to a defined value INSIDE the xsl document.

And I've never heard of being able to mix any other
language with xml or xsl like you can embed php
instructions within html.

So how do you pass an EXTERNAL value from a
link/form/php script INTO the xsl?

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]