473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

New to XML - to use urls and img tags in xml?

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.

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.

I'm very new to XML and google hasn't really turned up anything
useful.

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>

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.

Thanks in advance.
Jul 20 '05 #1
4 1256
Frank Stallone wrote:
<span datasrc="#xmltext" datafld="article"></span>


Short answer:
Transform it with XSLT on the server, not with that weird, non-standard,
badly supported stuff on the client.

Long answer:
http://groups-beta.google.com/group/...7096edf920d707

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #2
Thanks.

I had avoided XSLT because that was just something else to learn and
would delay me and I assumed since the code I was using was from
W3schools that it should be compatible across the board but I guess
not and I'll have to do it the proper way.

On Tue, 22 Mar 2005 21:54:42 +0000, David Dorward <do*****@yahoo.com>
wrote:
Frank Stallone wrote:
<span datasrc="#xmltext" datafld="article"></span>


Short answer:
Transform it with XSLT on the server, not with that weird, non-standard,
badly supported stuff on the client.

Long answer:
http://groups-beta.google.com/group/...7096edf920d707


Jul 20 '05 #3
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"

Jul 20 '05 #4
It was somewhere outside Barstow when Frank Stallone
<fa*********@lollerskates.com> wrote:
since the code I was using was from
W3schools that it should be compatible across the board


W3schools has no connection to the W3C

W3schools is a poor and frequently inaccurate tutorial.
Don't use DSO (datasrc etc.) It doesn't work, it never worked
widespread.

Don't use CSS, it's very restrictive.

Don't use XSLT on the client - doesn't work on every browser.

_Do_ use XSLT on the server.

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Ritter | last post by:
Hi, I know it could maybe be done with preg_match_all but I dont have any Idea how to do that. Anyone knows how can I extract all URLs inside the IMG Tags? (<img src="???">) Thanks a lot,...
0
by: Fuzzyman | last post by:
I am trying to parse an HTML page an only modify URLs within tags - e.g. inside IMG, A, SCRIPT, FRAME tags etc... I have built one that works fine using the HTMLParser.HTMLParser and it works...
16
by: Stoic | last post by:
Hi, I'm relatively new to CSS. I'm trying to get all the urls in a group of text bracketed by <p></p> tags to be underlined and everywhere else to NOT be underlined. As of now my code is like...
26
by: Howard Brazee | last post by:
I would like to click on a URL of a html document that will open several URLs at once for me. Does someone have an example of a html document that will do this?
1
by: DM | last post by:
I'm working on a site with more than 1700 HTML files. We'll be moving files around on this site a lot because we're reorganizing it. I'm thinking of writing a script that will convert all URLs in...
10
by: tom | last post by:
hi group, i desperately need a function that will transform relative URLs to absolute URLs in the SRC part of <img> tags. ie: function makeAbsolute($html,$basehref) { //if regex match =...
10
by: Mike.Duffy | last post by:
What is the default directory in the client file system that is used for file urls? From performing a few experiments, it is clear that an unqualified reference from another file url is always...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
3
by: Vlad | last post by:
Hi! My task: Take HTML -convert into plain text. Sub-task: 1. Find all urls within HTML (<a href="http://www.abc.com">More about baby bears</a>). 2. And convert them into plain text: More...
3
by: WebCM | last post by:
How to apply nice URL-s into CMS? 1. Should we use nice urls for every page? 2. Do we need to put a FULL path into <a href="">? 3. What is faster and better? a) 10 rules in .htaccess...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.