[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: basic xml help

Subject: Re: basic xml help
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Mon, 08 Aug 2005 16:47:26 +0200
basic xml format
Hi,

Tempore 16:08:22, die 08/08/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Steven Hughes <shughes@xxxxxxxxxxxxxxxxx>:

I am trying to convert a simple html page with css to an xml page with xsl.

The page is very simple, it just has a few images and some anchor tags and about
6 different sections that the anchors refer to.  It seems so simple that I
should be able to figure it out, alas I need some help.

I did not really understand the goals you are trying to achieve. Why don't you stick with XHTML? That ought to be much more usable than this home-made XML document. It's bad practice to keep inventing new element names (a1,b1,...) in your XML. But if you insist on using your own XML, try to separate content, style and accessibility

All those headerlinks and '<link><a href="#top" >back to top</a></link>' belong in the XSL.

Here you have a basic stylesheet that tries to make something useful out of the provided XML

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="acadguide">
<html>
<head>
<title><xsl:value-of select="title"/></title>
</head>
<body>
	<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="figures/*">
<a href="{full_src}" title="Click to enlarge this image">
	<img src="{thumb_src}" title="{caption}"/>
</a>
</xsl:template>

<xsl:template match="link[href]">
<a href="{href}">
	<xsl:value-of select="label"/>
</a>
</xsl:template>

<xsl:template match="a">
<xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="section">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="title">
<h1><xsl:apply-templates/></h1>
</xsl:template>

<xsl:template match="section/title">
<h1><a>
	<xsl:attribute name="name">
		<xsl:text>section_</xsl:text><xsl:number count="section" format="001"/>
	</xsl:attribute>
	<xsl:apply-templates/>
</a></h1>
</xsl:template>

<xsl:template match="subtitle">
<h2><xsl:apply-templates/></h2>
</xsl:template>

</xsl:stylesheet>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Vincit omnia simplicitas
Keep it simple

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.