473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

variable/template question

Hello,

I need to write html "templates" for a web application. Basically I am
displaying items on a website where I may or may not have 3 pieces of
information, that being: color, size and mft. What I would like to
code is if I have the color of the item, to go ahead and display the
word Color and bring in the Color variable. If the item doesn't have
color, don't display the word Color. The same being for the remainder
of the variables. Is this possible or do I need to create multiple
templates for the variables...ie one template that just has color, one
template that has color and size, etc? (I have the variable names
coming in fine, the problem is the label --if the variable doesn't
apply to this item, I don't want to display the label )

<tr>
<td>Color:</td>
<td><VariableNameForColor></td>
</tr>
<tr>
<td>Size:</td>
<td><VariableNameForSize></td>
</tr>
<tr>
<td>Manufacturer:</td>
<td><VariableNameForMft></td>
</tr>

Aug 7 '06 #1
4 1355

ga*******@yahoo.com wrote:
I need to write html "templates" for a web application.
You'll probably find XSLT to be less work to learn than even a simple
templating system would be to write.

Aug 8 '06 #2
Andy Dingley wrote:
ga*******@yahoo.com wrote:
>I need to write html "templates" for a web application.

You'll probably find XSLT to be less work to learn than even a simple
templating system would be to write.
I'd say that depends on what you mean by "simple". If you aren't
familiar with declarative programming, XSLT seems pretty weird. It took
me a long time to get to the point where I could get XSLT templates to
produce the desired output without many cycles of trial and error.

XSLT 2.0 is significantly more complex than XSLT 1.0, and presents a
steeper learning curve.

--
Jack.
http://www.jackpot.uk.net/
Aug 8 '06 #3

Jack wrote:
XSLT seems pretty weird.
I doubt I'm the only one who found XPath by far the hardest part of
XSLT to learn.

Nor is XSLT necessarily declarative. You can (and most people do) write
it in an almost entirely procedural manner. If what you're trying to
do is to replace a "templating" system, then this procedural model
works fine.

XSLT 2.0 is significantly more complex than XSLT 1.0, and presents a
steeper learning curve.
I'd say that XSLT 2 is more complex than XSLT 1, but that XPath is
still the hardest part of either. It's also 7 years on and there are a
lot more books and guides around.

Aug 8 '06 #4
Andy Dingley wrote:
Jack wrote:
>XSLT seems pretty weird.

I doubt I'm the only one who found XPath by far the hardest part of
XSLT to learn.
Agreed - XPath is horrible (IMO).
>
Nor is XSLT necessarily declarative. You can (and most people do)
write it in an almost entirely procedural manner. If what you're
trying to do is to replace a "templating" system, then this
procedural model works fine.
My own view is that trying to use XSLT as a procedural language is the
cause of many problems - because you can't write a stylesheet in an
"almost entirely procedural" way. Things get easier the less you rely on
the procedural hacks.
--
Jack.
http://www.jackpot.uk.net/
Aug 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sylvain.loiseau | last post by:
Hello Given a node set, I try to compute the total of the string-length value of each node. For instance, with : <xsl:for-each select="//q"> <!-- the length of each node is compute with:...
2
by: littlefitzer | last post by:
Hi, Say for example I want to use the following line in my XSL: <xsl:call-template name="buildText"/> I know I have to have a template defined named buildText. My question is: Is there a way...
2
by: Norman Barker | last post by:
Hi, I have the following template <xsl:template match="midas:Request"> <xsl:variable name="var1" select="string(./midas:DataDescriptorGUID/@GUID)"/> <test> <result1><xsl:copy-of...
3
by: PatrickRThomas | last post by:
his question has probably been asked a million times, but I can't get this to work. I'm trying to create a global variable that contains some HTML so that I can reference it from multiple...
3
by: Steve Brown | last post by:
Hello all, Is there a way to determine a variable's type at run-time? The reason I'm asking is that i have code that looks like this: template <class T> Object::Object(int TypeCode, T* data)...
1
by: Hose B | last post by:
HI all, I have a legacy app in which users can pick various page templates. There is a template preview dialog. It works such that they view a list of icons in an asp page that represent each...
2
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being...
13
by: Justcallmedrago | last post by:
How would you declare and assign a variable inside a function THAT HAS THE NAME OF A PARAMETER YOU PASSED example: when you call createvariable("myvariable") it will declare the variable...
4
by: David Sanders | last post by:
Hi, I have a class depending on a template parameter: template<int n> class MyClass { }; I want the template parameter to be chosen according to a variable, e.g.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.