freelanceprogrammers.org Forum Index » XML / XSL
dynamic employee lists
Joined: 27 May 2005
Posts: 4
dynamic employee lists
At this point, I`ve only written simple XML and XSL files, so feel
free to point out even the most obvious things.
I have an XML list of department employees.
I want to be able to display different sections of that list. For
example, I`d like to show Name and Phone Number, switch it to Name and
IM Address, switch it to Name and Work Schedule, etc.
I`m able to display the appropriate sections, but only through
multiple copies of the XML file and multiple XSL files. How can I do
it, assuming that I can, using single XML and XSL files?
Rick
Joined: 02 May 2005
Posts: 10
dynamic employee lists
Try putting three loops in a single xsl:template. For
example in pseudo code:
xsl:template
for each employee > output Name and Phone
for each employee > output Name and IM
for each employee > output Name and Schedule
If you want a more detailed example, post an xml
snippet from your employee list.
--- "Rick A. Henkel" <yahoo@...>
wrote:
> At this point, I`ve only written simple XML and XSL
> files, so feel
> free to point out even the most obvious things.
>
> I have an XML list of department employees.
>
> I want to be able to display different sections of
> that list. For
> example, I`d like to show Name and Phone Number,
> switch it to Name and
> IM Address, switch it to Name and Work Schedule,
> etc.
>
> I`m able to display the appropriate sections, but
> only through
> multiple copies of the XML file and multiple XSL
> files. How can I do
> it, assuming that I can, using single XML and XSL
> files?
>
> Rick
>
>
>
>
>
> Yahoo! Groups Links
>
>
> xml-doc-unsubscribe@yahoogroups.com
>
>
>
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Joined: 09 Feb 2005
Posts: 4
dynamic employee lists
Rick,
You don`t say what your output is so I`ll assume HTML. What are you using to
transform the XML and where? Do you transform it on your computer and
deliver HTML? Or are you transorm on the server?
If you`re transforming on the server, you might want to consider passing
xsl:params to the xsl and using them to turn on or off different
xsl:templates.
Let`s say your XML looks like this:
<Person>
<Name>John Doe</Name>
<Phone>555-1212</Phone>
<IMAddress>Anon</IMAddress>
</Person>
You could create an xsl:param named Phone and set the default value to true:
<xsl:param name="Phone" value="true" />
In your phone template, you could test the value of the param and if true,
apply the templates.
<xsl-template match="Phone">
<xsl-if test="$Phone=`true`">
<p><xsl:apply-templates /></p>
</xsl-if>
</xsl:template>
To change the value of the xsl:param dynamically, you can pass it to your
XSL processor in the hyperlink. How you do this depends on your XSL
processor and whether you are using Java, ASP, JavaScript, etc.
For exaple, it could be <a href="process.asp?Phone=false>
The XSLT FAQ has some good intormation about this.
http://www.dpawson.co.uk/xsl/sect2/sect21.html
Mike
-----Original Message-----
From: xml-doc@yahoogroups.com [mailto:xml-doc@yahoogroups.com] On Behalf Of
Rick A. Henkel
Sent: Friday, May 27, 2005 10:22 AM
To: xml-doc@yahoogroups.com
Subject: [xml-doc] dynamic employee lists
At this point, I`ve only written simple XML and XSL files, so feel free to
point out even the most obvious things.
I have an XML list of department employees.
I want to be able to display different sections of that list. For example,
I`d like to show Name and Phone Number, switch it to Name and IM Address,
switch it to Name and Work Schedule, etc.
I`m able to display the appropriate sections, but only through multiple
copies of the XML file and multiple XSL files. How can I do it, assuming
that I can, using single XML and XSL files?
Rick
Yahoo! Groups Links
Joined: 14 Jun 2003
Posts: 12
dynamic employee lists
Too bad you don`t have the list implemented in an LDAP directory
instead. Then, you could do what you wish with your email application
or any number of others.
David
On 5/27/05, Rick A. Henkel <yahoo@...> wrote:
> At this point, I`ve only written simple XML and XSL files, so feel
> free to point out even the most obvious things.
>
> I have an XML list of department employees.
Joined: 02 May 2005
Posts: 10
dynamic employee lists
I don`t know much about LDAP, but what he wants to do
is fairly trivial. I wouldn`t steer him away from it.
--- David Neeley <dbneeley@...> wrote:
> Too bad you don`t have the list implemented in an
> LDAP directory
> instead. Then, you could do what you wish with your
> email application
> or any number of others.
>
> David
>
> On 5/27/05, Rick A. Henkel
> <yahoo@...> wrote:
> > At this point, I`ve only written simple XML and
> XSL files, so feel
> > free to point out even the most obvious things.
> >
> > I have an XML list of department employees.
>
>
>
> Yahoo! Groups Links
>
>
> xml-doc-unsubscribe@yahoogroups.com
>
>
>
>
>
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new Resources site
http://smallbusiness.yahoo.com/resources/
Joined: 14 Jun 2003
Posts: 12
dynamic employee lists
Yes, this example is trivial indeed. LDAP, however, opens up other
benefits such as single sign-on, a repository for passwords, etc. I
wouldn`t do it only for this example, but I would consider if it could
bring other, desirable capabilities to the table.
However, if the IT department won`t implement and support it, it would
be overkill for a department-level activity.
David
On 5/27/05, roger <rweinheimer@...> wrote:
> I don`t know much about LDAP, but what he wants to do
> is fairly trivial. I wouldn`t steer him away from it.
>
> --- David Neeley <dbneeley@...> wrote:
> > Too bad you don`t have the list implemented in an
> > LDAP directory
> > instead. Then, you could do what you wish with your
> > email application
> > or any number of others.
> >
> > David
> >
> > On 5/27/05, Rick A. Henkel
> > <yahoo@...> wrote:
> > > At this point, I`ve only written simple XML and
> > XSL files, so feel
> > > free to point out even the most obvious things.
> > >
> > > I have an XML list of department employees.
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> > xml-doc-unsubscribe@yahoogroups.com
> >
> >
> >
> >
> >
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new Resources site
> http://smallbusiness.yahoo.com/resources/
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
Joined: 17 Jun 2003
Posts: 20
dynamic employee lists
Hi Ricky:
When I was teaching myself XSLT, I used an XML list from an address book as
my test document. I wrote different XSLTs that pulled out the data I
wanted. Other parts of the address info were not displayed in the browser,
though they were in the XML file.
If you have an example of the XML, I`d be happy to look at a snippet (say,
from the start tag of one employee to the end tag) and see if any of my
scraps of XSLT can be modified to match it up.
You`ll need to have some mechanism for folks to switch from showing some
parts to others (applying different XSLT). Or is that is where you are
having the problem (because the XSLT is named in the file and you have to
make a copy of the file and change the XSLT)??
Thank you,
Kay
--------------------------------------
Kay Ethier
Bright Path Solutions
PO Box 14265
Research Triangle Park NC 27709-4265
PHONE: 919.244.8559
http://www.travelthepath.com
mailto:kethier@...
--------------------------------------
**Check out the FrameMaker "main event" of 2005 -- three days of learning
and networking in North Carolina: http://www.travelthepath.com/conf2005.html
(FrameMaker 2005 Chautauqua, November 7-9, 2005)
-----Original Message-----
From: Rick A. Henkel
At this point, I`ve only written simple XML and XSL files, so feel free to
point out even the most obvious things.
I have an XML list of department employees.
I want to be able to display different sections of that list. For example,
I`d like to show Name and Phone Number, switch it to Name and IM Address,
switch it to Name and Work Schedule, etc.
I`m able to display the appropriate sections, but only through multiple
copies of the XML file and multiple XSL files. How can I do it, assuming
that I can, using single XML and XSL files?
Rick
Joined: 02 May 2005
Posts: 10
dynamic employee lists
Here`s how I imagine the xml data that you describe:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="employeeList.xslt"?>
<employees>
<employee>
<name>Mary</name>
<phone>555-5550</phone>
<im>mary550</im>
<schedule>Open</schedule>
</employee>
<employee>
<name>Joe</name>
<phone>555-5551</phone>
<im>joe551</im>
<schedule>Close</schedule>
</employee>
<employee>
<name>Pat</name>
<phone>555-5552</phone>
<im>pat552</im>
<schedule>Watch</schedule>
</employee>
</employees>
Here`s an xslt transform that outputs different html
lists depending on the parameter you supply to it. The
default is a `phone` list:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="listType">phone</xsl:param>
<xsl:output method="html" version="1.0"
encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="doIt">
<xsl:with-param name="type" select="$listType"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="doIt">
<xsl:param name="type"/>
<html>
<head>
<title>Employee <xsl:value-of select="$type"/>
list</title>
</head>
<body>
<h1>Employee <xsl:value-of select="$type"/>
list</h1>
<table>
<tbody>
<tr>
<th>Name</th>
<th><xsl:value-of select="$type"/></th>
</tr>
<xsl:choose>
<xsl:when test="$type=`phone` ">
<xsl:for-each select="//employee">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="phone"/></td>
</tr>
</xsl:for-each>
</xsl:when>
<xsl:when test="$type=`im` ">
<xsl:for-each select="//employee">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="im"/></td>
</tr>
</xsl:for-each>
</xsl:when>
<xsl:when test="$type=`schedule` ">
<xsl:for-each select="//employee">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="schedule"/></td>
</tr>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="//employee">
<tr>
<td colspan="2" align="center"><xsl:value-of
select="name"/></td>
</tr>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Here`s the output for a phone list:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">
<title>Employee phone list</title>
</head>
<body>
<h1>Employee phone list</h1>
<table>
<tbody>
<tr>
<th>Name</th>
<th>phone</th>
</tr>
<tr>
<td>Mary</td>
<td>555-5550</td>
</tr>
<tr>
<td>Joe</td>
<td>555-5551</td>
</tr>
<tr>
<td>Pat</td>
<td>555-5552</td>
</tr>
</tbody>
</table>
</body>
</html>
How you call the transform and pass the parameter is
up to you and beyond the scope of this example. :) You
could skin that cat any number of ways depending on
your production environment.
Regards,
Roger
--- "Rick A. Henkel" <yahoo@...>
wrote:
> At this point, I`ve only written simple XML and XSL
> files, so feel
> free to point out even the most obvious things.
>
> I have an XML list of department employees.
>
> I want to be able to display different sections of
> that list. For
> example, I`d like to show Name and Phone Number,
> switch it to Name and
> IM Address, switch it to Name and Work Schedule,
> etc.
>
> I`m able to display the appropriate sections, but
> only through
> multiple copies of the XML file and multiple XSL
> files. How can I do
> it, assuming that I can, using single XML and XSL
> files?
>
> Rick
>
>
>
>
>
> Yahoo! Groups Links
>
>
> xml-doc-unsubscribe@yahoogroups.com
>
>
>
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Joined: 27 May 2005
Posts: 4
dynamic employee lists
Thanks to everyone for their suggestions.
Rick
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







