View previous topic :: View next topic |
Author |
Message |
wyvern Tux's lil' helper
Joined: 04 Apr 2003 Posts: 99 Location: Victoria, B.C.
|
Posted: Mon May 12, 2003 5:47 pm Post subject: Gentoo.org index.xml - How's it done? |
|
|
After reading Daniel Robbin's experiences in setting up gentoo.org to use XML/XSL I was inspired to learn it and find out how to use it in my own web projects. It's been rewarding, but one thing is driving me nuts
How does the gentoo.org index.xml 'import' the news 'nuggets'? The news items are stored in separate .xml files, and the index.xml (which is amazingly short) looks like this:
Code: | <?xml version='1.0'?>
<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
<mainpage id="news">
<title>Gentoo Linux News</title>
<version>Current</version>
<newsitems/>
</mainpage> |
So somehow the tag <newsitems/> causes guide.xsl (the style doc) to 'import' the news items and format them properly. Problem is, I've looked through the guide.xsl and I'm no closer to figuring out the mechanism by which it does this. Is it done on the fly by the web server?
Please tell me (or give me a hint), I'm dying to know! I would love to be able to split my web pages into discrete XML files (would make updating things like nav bars and news sooooo easy).
Wyvern
---
Jan "Wyvern" Van Uytven
Sysadmin, UVic TRIUMF
wyvern@uvic.ca |
|
Back to top |
|
|
SuperTomate Guru
Joined: 02 Jun 2002 Posts: 392 Location: France
|
|
Back to top |
|
|
wyvern Tux's lil' helper
Joined: 04 Apr 2003 Posts: 99 Location: Victoria, B.C.
|
Posted: Mon May 12, 2003 6:57 pm Post subject: |
|
|
I've already read all of those docs (and actually linked to one in my first post). None of them mention this topic.
Wyvern _________________ ---
ex nihilo nihil fit |
|
Back to top |
|
|
SPo0n Tux's lil' helper
Joined: 03 May 2003 Posts: 85 Location: England
|
Posted: Mon May 12, 2003 7:25 pm Post subject: |
|
|
you could use php and the include function (www.php.net/include) |
|
Back to top |
|
|
wyvern Tux's lil' helper
Joined: 04 Apr 2003 Posts: 99 Location: Victoria, B.C.
|
Posted: Mon May 12, 2003 7:43 pm Post subject: |
|
|
I know I could use PHP. There are any number of solutions to this, including using Daniel's useful pytext script. I know there are other ways, but I'm curious as to whether XSLT can do it, and if not, how is gentoo.org doing it?
Call it academic interest if you like _________________ ---
ex nihilo nihil fit |
|
Back to top |
|
|
zhenlin Veteran
Joined: 09 Nov 2002 Posts: 1361
|
Posted: Tue May 13, 2003 11:03 am Post subject: |
|
|
XSLT, plus a few scripts.
<xsl:if test="/mainpage/@id='news'">
<br/><br/>
Older News:<br/>
<xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&=7][position()&20]/text()">
<xsl:variable name="newsuri" select="."/>
<a class="altlink" href="{$newsuri}"><xsl:value-of select="document(.)/news/title"/></a><br/>
</xsl:for-each>
</xsl:if> |
|
Back to top |
|
|
|