This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How to import XML data into an imported XSLT sheet?
Hi,
I'm working for a week to get this done, but nothing seems to work. I hope
someone of you can help me here.
This is what I'm trying to do:
I'm working on a layout that will have a top-navigatiion block, a bottom
navigtion block and in between 3 colums, containing the "left navigation,
main content en a right navigation,
This last 3 colums should be bild in a table.
The top - and bottom navigation will be placed in the xsl stylesheet.
The table will also be placed in the same xsl stylesheet.
I want the content for left-, right navigation and the main content to be
imported for a xml file, because that content will be easy to edit by
people.
And I don't want them to edit the stylesheet.
The problem is, that I can't get this data. I think, the path to this data
in this xml file is wrong.
(Please don't worry about the xml namespace [ <?xml version="1.0"?> ], it
works fine with the program I'm using)
Well, the index.xml (source) lokks lijke this:
<root>
<content file="left.xml"/>
<content file="main.xml"/>
<content file="right.xml"/>
</root>
The xsl that comes with it looks like this:
<?xml version="1.0"?>
<xsl:stylesheet>
<xsl:import href="left_nav.xsl"/>
<xsl:import href="main_win.xsl"/>
<xsl:import href="right_nav.xsl"/>
<xsl:template match="/">
<html><body bgcolor="#fff7d7" text="#000000" link="#000099"
vlink="#2b3856" alink="#ff0000">
<xsl:call-template name="pageheader"/>
<p/><br/>
<table width="610" align="center" border="0">
<tr valign="top">
<td width="150">
<xsl:call-template name="left_nav"/>
</td>
<td width="300">
<xsl:call-template name="main_win"/>
</td>
<td width="150">
<xsl:call-template name="right_nav"/>
</td>
</tr></table>
<p/><br/>
<xsl:call-template name="pagebottom"/>
</body></html>
</xsl:template>
<!-- page header -->
<xsl:template name="pageheader">
<table width="600" border="0" cellspacing="0" align="center">
<tr><td width="200">
Here goed the text
</td>
<td width="400" align="right">
Here goed some more text
</td>
</tr>
</table>
</xsl:template>
<!-- page bottom -->
<xsl:template name="pagebottom">
Well, this look almost the same as the pageheader does. Don't worry
about it.
</xsl:template>
</xsl:stylesheet>
So, I import 3 stylesheets, left-nav, main-win and right-nav.
Hope your're still with me, getting close to the problem.
Let's stick to the left-nav xsl file.
It looks like this, (removed the fancy stuff)
<?xml version="1.0"?>
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:template select="document('left.xml',@file)//resource/test">
<xsl:apply-templates/>
</xsl:template>
</xsl:template>
<xsl:template name="left_nav">
<table width="100%" bgcolor="#c7a086" cellpadding="0" cellspacing="0">
<tr><td width="100%">
SubNavigatie
</td></tr>
<tr><td bgcolor="#0000ff">
<xsl:apply-templates/>
</td></tr></table>
</xsl:template>
</xsl:stylesheet>
Well, putting text in this table will work, but I think something is wrong
in the path to the left.xsl file.
This file looks like this:
<resource>
<test>this is a test</test>
<ref>
<title>Go toYahoo!</title>
</ref>
<ref>
<title>Go to Altavista</title>
</ref>
<ref>
<title>Go to Track</title>
</ref>
<ref>
<title>Go to Zoek.nl</title>
</ref>
<ref>
<title>Go to Astalavista</title>
</ref>
</resource>
Well, hope somebody can help me here. I'm getting crazy...
Greetings,
Cyril Moerkoert
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list