This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > April 2006 > XML to Table-with-show/hide facility using XSLT





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author XML to Table-with-show/hide facility using XSLT
Scamjunk

2006-04-15, 6:42 am

Hi,

I was wondering whether it is better to have a "<tag>value</tag>"
format or a <elem field="tag" value="value"/>" format if I want to
later have XPqth and XQuery work on the XML as well as give the XML in
table format with a show/hide facility for display purpose for users.
Your suggestions are most valuable.

Thanks for you help.

Scam.

Martin Honnen

2006-04-15, 6:56 pm



Scamjunk wrote:

> I was wondering whether it is better to have a "<tag>value</tag>"
> format or a <elem field="tag" value="value"/>" format if I want to
> later have XPqth and XQuery work on the XML as well as give the XML in
> table format with a show/hide facility for display purpose for users.
> Your suggestions are most valuable.


It depends on how you want to render/style your XML. It is possible to
style XML documents with CSS and then you definitely need elements with
content as CSS does not really allow you to have attribute values
rendered and styled. So with CSS you can do e.g.
element-name {
display: block;
color: darkblue;
background-color: lightblue;
}
to style element contents.

On the other hand if you want to use XSLT to transform the input XML to
HTML (which you then style with CSS) then it does not matter whether you
have some values in attributes or as element contents, you will be able
to use XSLT/XPath on both to transform to a suitable HTML structure with
CSS presentation and perhaps client-side script to hide/show parts.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Peter Flynn

2006-04-15, 6:56 pm

Scamjunk wrote:
> Hi,
>
> I was wondering whether it is better to have a "<tag>value</tag>"
> format or a <elem field="tag" value="value"/>" format


FAQ: http://xml.silmaril.ie/developers/attributes/

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Scamjunk

2006-04-17, 3:48 am

Thanks for the response. I agree that it is very difficult to state
which format is better without knowing what I am trying to do.

The XPath/XQuery part is going to extensive, to say the least. The
display has to be in table format (the grid outlook of XMLSpy, if u
have seen it). I got a Javascript that does a collapse/expand facility,
but don't know how to fit it in with XSLT. The script works fine in
HTML, but when I try to use it to generate the HTML, it is not
recognising the Javascript.

I am giving here a part of the XSLT:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<xsl:for-each select="/Root/table">
<head>
<script language="JavaScript" src="collapse.js"/>
<style type="text/css">
/<![CDATA[/
body {
font-family:arial, sans-serif;
font-size:76%;
}
/*]]>*/
</style>
</head>
<table class="collapse" border="1">
<xsl:call-template name="General"/>
</table>
</xsl:for-each>
</html>
</xsl:template>
</xsl:stylesheet>

Any ideas why? And if it can be recognised only through the HTML, how
do I make it to be part of the HTML as is? I have no idea about this.
Am a complete stranger to XSLT. Please pardon my ignorance.

Thanks a million,

regards,
Scam

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews