Click to See Complete Forum and Search --> : Newbie ALERT!


GavinPearce
03-16-2003, 03:16 AM
Soz for this but I have no xml experience.

Basically I have this page
http://mrfish.ukwd.com/rdf.php?f=5&c=10

which generates a xml output and I want to display it so people can quick on the links etc. How do I do that?

Cheers people!

Alhazred
03-17-2003, 09:43 AM
OK, in order to get a link to be clickable you will need to get the browser to understand that you want the behaviour associated with the <a> tag in HTML, so your links should be <a> tags. You can embed xhtml into XML using namespaces.

In an XML document the following will produce a clickable link

<xhtml:a href="javascript:alert('got here');" xmlns:xhtml="http://www.w3.org/1999/xhtml">Click Me</xhtml:a>

This is just a normal HTML type anchor tag and even though its embedded in an XML document the namespace declaration informs the browser that it should treat it as xhtml content. You can also embedd any other xhtml content in the same way, including javascript (via the <xhtml:script> tag) and it should work pretty much as normal.

Now, there are some other ways to get this sort of thing as well. You can use 'xlink' (but I have not had good luck with it working as well as xhtml tags do).

The other issue is supposing you have an existing XML document and you need to make it work the way you want, but you don't want to or can't modify the document itself. In that case you will need more advanced techniques, like either server-side or client-side transformations using XSLT or something like that.

As far as just plain displaying XML, you simply use CSS to do that. CSS2 has all the required functionality, but again you will have to transform the XML at least enough to include a 'processing instruction' in it which tells the browser what stylesheet to use. If you can edit the XML then something like:

<?xsl-stylesheet href="yourss.css" type="text/css"?>

would clue in the browser to get the stylesheet yourss.css. CSS in XML works pretty much the same as in HTML, but CSS2 does have some features that you will want to learn about in order to have things display well, like the display:block and display:in-line attributes.

Overall if you need to work with XML you probably should look into getting some books on the subject. Michael Kay has written several good ones published by Vrox which are widely available and generally well writen. O'reilly as usual also has some good reference works. For web work you should probably understand CSS1, CSS2, CSS3 (though its not really available much yet) XSLT, XHTML, and understand XML Namespaces.

GavinPearce
03-17-2003, 10:27 AM
Cheers! I owe you one. Thanks!

In that case you will need more advanced techniques, like either server-side or client-side transformations using XSLT or something like that

I'll be looking into that, because that's what I need to do.

Thanks again!