Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XSL displaying unwanted channel information

0 views
Skip to first unread message

Lacy

unread,
Nov 10, 2009, 1:58:19 PM11/10/09
to
I'm using XSL to scrape and display data from a google spreadsheet.

Working great except for one thing - it displays the channel info even
though I'm not calling that info anywhere? (It displays: atom:id,
lastBuildDate, category domain, title, link, managing Editor, and the
openSearch variables. Basically - everything within the main channel
that has a value. )

It displays it unformatted - just a straight block of text with no
spaces.

Using this to process:
[code]
// Load the XML source
$xml = new DOMDocument;
$xml->load('http://spreadsheets.google.com/feeds/list/
tqBgup5Bmbdgh-rgyxqh2Pw/od6/public/basic?alt=rss');
$xsl = new DOMDocument;
$xsl->load('calendarparse.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml);
[/code]

Result File - http://studentorgs.vanderbilt.edu/vsg/atvandy/
Source XML - http://spreadsheets.google.com/feeds/list/tqBgup5Bmbdgh-rgyxqh2Pw/od6/public/basic?alt=rss
XSL - http://studentorgs.vanderbilt.edu/vsg/atvandy/calendarparse.xsl

Thoughts? What am I missing? I can't figure out why it's displaying
information I'm not calling.

Martin Honnen

unread,
Nov 10, 2009, 2:10:15 PM11/10/09
to

Well you have nothing but two templates, one with match="/", one with
match="item". How do expect the processing ends up with your
match="item" template? That is because of built-in templates that does
<xsl:apply-templates/>
So that way your match="item" template is applied but that way also
other nodes are processed and the built-in templates for text nodes does
<xsl:value-of select="."/> so that is why you see all those text values
in your output.
As you don't want that you will either need to ensure that you process
only 'item' elements by doing
<xsl:template match="/">
<xsl:apply-templates select="rss/channel/item"/>
<xsl:template>
or you will need to override the built-in template for text nodes by doing
<xsl:template match="text()"/>


--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

Lacy

unread,
Nov 10, 2009, 2:18:16 PM11/10/09
to
On Nov 10, 1:10 pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> Lacy wrote:
> > I'm using XSL to scrape and display data from a google spreadsheet.
>
> > Working great except for one thing - it displays the channel info even
> > though I'm not calling that info anywhere?   (It displays:  atom:id,
> > lastBuildDate, category domain, title, link, managing Editor, and the
> > openSearch variables.  Basically - everything within the main channel
> > that has a value. )
>
> > It displays it unformatted - just a straight block of text with no
> > spaces.
>
> > Using this to process:
> > [code]
> >     // Load the XML source
> >     $xml = new DOMDocument;
> >     $xml->load('http://spreadsheets.google.com/feeds/list/
> > tqBgup5Bmbdgh-rgyxqh2Pw/od6/public/basic?alt=rss');
> >     $xsl = new DOMDocument;
> >     $xsl->load('calendarparse.xsl');
> >     // Configure the transformer
> >     $proc = new XSLTProcessor;
> >     $proc->importStyleSheet($xsl); // attach the xsl rules
> >     echo $proc->transformToXML($xml);
> > [/code]
>
> > Result File -http://studentorgs.vanderbilt.edu/vsg/atvandy/
> > Source XML -http://spreadsheets.google.com/feeds/list/tqBgup5Bmbdgh-rgyxqh2Pw/od6...
> > XSL -http://studentorgs.vanderbilt.edu/vsg/atvandy/calendarparse.xsl

>
> > Thoughts?  What am I missing?  I can't figure out why it's displaying
> > information I'm not calling.
>
> Well you have nothing but two templates, one with match="/", one with
> match="item". How do expect the processing ends up with your
> match="item" template? That is because of built-in templates that does
>    <xsl:apply-templates/>
> So that way your match="item" template is applied but that way also
> other nodes are processed and the built-in templates for text nodes does
> <xsl:value-of select="."/> so that is why you see all those text values
> in your output.
> As you don't want that you will either need to ensure that you process
> only 'item' elements by doing
>   <xsl:template match="/">
>     <xsl:apply-templates select="rss/channel/item"/>
>   <xsl:template>
> or you will need to override the built-in template for text nodes by doing
>    <xsl:template match="text()"/>
>
> --
>
>         Martin Honnen --- MVP XML
>        http://msmvps.com/blogs/martin_honnen/


Ahhh!!! I had tried select="item" -- but then nothing displayed. I
guess I needed to go up to the top node!

Perfect :) Thanks Martin!

~L


0 new messages