OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML2HTML

[ Lists Home | Date Index | Thread Index ]
  • From: "Wang, Dapeng" <Dapeng.Wang@Dresdner-Bank.com>
  • To: "Xml-Dev (E-Mail)" <xml-dev@ic.ac.uk>
  • Date: Fri, 13 Aug 1999 17:37:01 +0200

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@ic.ac.uk
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@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS