Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSL displaying unwanted channel information

From: Lacy <lacymarie@-----.--->
To: 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




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent