Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XSL displaying unwanted channel information [Thread Next] Re: XSL displaying unwanted channel informationTo: NULL Date: 11/10/2009 11:18:00 AM On Nov 10, 1:10=A0pm, 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? =A0 (It displays: =A0atom:id=
,
> > lastBuildDate, category domain, title, link, managing Editor, and the
> > openSearch variables. =A0Basically - 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]
> > =A0 =A0 // Load the XML source
> > =A0 =A0 $xml =3D new DOMDocument;
> > =A0 =A0 $xml->load('http://spreadsheets.google.com/feeds/list/
> > tqBgup5Bmbdgh-rgyxqh2Pw/od6/public/basic?alt=3Drss');
> > =A0 =A0 $xsl =3D new DOMDocument;
> > =A0 =A0 $xsl->load('calendarparse.xsl');
> > =A0 =A0 // Configure the transformer
> > =A0 =A0 $proc =3D new XSLTProcessor;
> > =A0 =A0 $proc->importStyleSheet($xsl); // attach the xsl rules
> > =A0 =A0 echo $proc->transformToXML($xml);
> > [/code]
>
> > Result File -http://studentorgs.vanderbilt.edu/vsg/atvandy/
> > Source XML -http://spreadsheets.google.com/feeds/list/tqBgup5Bmbdgh-rgy=
xqh2Pw/od6...
> > XSL -http://studentorgs.vanderbilt.edu/vsg/atvandy/calendarparse.xsl
>
> > Thoughts? =A0What am I missing? =A0I can't figure out why it's displayi=
ng
> > information I'm not calling.
>
> Well you have nothing but two templates, one with match=3D"/", one with
> match=3D"item". How do expect the processing ends up with your
> match=3D"item" template? That is because of built-in templates that does
> =A0 =A0<xsl:apply-templates/>
> So that way your match=3D"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=3D"."/> 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
> =A0 <xsl:template match=3D"/">
> =A0 =A0 <xsl:apply-templates select=3D"rss/channel/item"/>
> =A0 <xsl:template>
> or you will need to override the built-in template for text nodes by doin=
g
> =A0 =A0<xsl:template match=3D"text()"/>
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/
Ahhh!!! I had tried select=3D"item" -- but then nothing displayed. I
guess I needed to go up to the top node!
Perfect :) Thanks Martin!
~L
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
