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

XML2HTML

  • From: "Wang, Dapeng" <Dapeng.Wang@D...>
  • To: "Xml-Dev (E-Mail)" <xml-dev@i...>
  • Date: Fri, 13 Aug 1999 17:37:01 +0200

xml2html
Hi,

I'm trying to transform XML to HTML with different layouts using different
XSLs. The idea is to seperate date content from the date representation. But
I'm not sure which kind of information belong to content and which to
representation. For example a simple XML 
<LINKS>
	<LINK HREF="first.html">First</LINK>
		<LINK HREF="second.html">Second</LINK>
</LINKS>	

The first XSL which uses the href information:
  <xsl:template match="LINKS">
	<TABLE>
  	<xsl:apply-templates/>
	</TABLE>
  </xsl:template>  

  <xsl:template match="LINK">
	    <TR><TD ALIGN="CENTER" VALIGN="MIDDLE"> <FONT
FACE="Helvetica,Arial" SIZE="2"><A
HREF="{@HREF}"><xsl:apply-templates/></A></FONT></TD></TR>  
  </xsl:template>  

The second XSL leaves the href information unused and just prints out the
text

  <xsl:template match="LINKS">
	<TABLE>
  	<xsl:apply-templates/>
	</TABLE>
  </xsl:template>  

  <xsl:template match="LINK">
	    <TR><TD ALIGN="CENTER" VALIGN="MIDDLE"> <FONT
FACE="Helvetica,Arial" SIZE="2"><xsl:apply-templates/></FONT></TD></TR>  
  </xsl:template>  

Everything works fine until now. But what if I want to use a image instead
of the text ina third layout.
I have two possibilities.

1. Write the whole stuff in XSL. e.g 
  <xsl:template match="LINKS">
	here comes the whole HTML with images. All hard coded.
	<a href="first.html"><img src="first.gif"/></a><br/>
	<a href="second.html"><img src="second.gif"/></a><br/>
  </xsl:template>  

2. Extend the XML to include the image attribute.
<LINKS>
	<LINK HREF="first.html" IMAGE="first.gif">First</LINK>
	<LINK HREF="second.html" IMAGE="second.gif">Second</LINK>
</LINKS>	

and change the XSL to 
  <xsl:template match="LINK">
	    <TR><TD ALIGN="CENTER" VALIGN="MIDDLE"> <FONT
FACE="Helvetica,Arial" SIZE="2"><img src="{@IMAGE}"/></FONT></TD></TR>  
  </xsl:template>  

Of course, the second approach allows to handle the layouts in a generic
way, which is quote suitable for further changes.(e.g. add one more LINK
etc.) But the XML document must also be very generic to ensure the fact,
that it delivers the values for all possible uses. E.g. if I want to call a
script function onClick, I have to then specify it it the XML too, or the
image height and image width). This will end in a very complex XML with a
lot of information for all possible cases, but the information will not be
used for most cases. I'm also not sure whether the information like image
height and image width is layout specific or real data content.

I'm glad to hear any opinion and suggestions.

Dapeng Wang



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.