Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link and show details of one node

Status
Not open for further replies.

djwiktor

Vendor
Jul 8, 2005
2
PL
This is my first try at xml/xsl. I have an xml file with hundreds of job offers from another portal that I'd like to put on my site.

I need two things. First, list all data in rows (employer, post, province). Second, link posts and let visitors read full description of a particular job offer.

So far, I've done the following:

#sample of xml source file

<?xml version="1.0" encoding="iso-8859-2"?>
<ADVERTISEMENTS creation_date="2005-06-27">
<ADVERTISEMENT start_date="2005-06-27" end_date="2005-07-02" update_date="2005-06-27" id="91728"><EMPLOYER>Personality Doradztwo Personalne</EMPLOYER>
<POST>HR Manager / Specjalista ds. HR </POST>
<WORKPLACE>
<PROVINCE>mazowieckie</PROVINCE>
</WORKPLACE>
</ADVERTISEMENT></ADVERTISEMENTS>

#my xsl file
#It displays data as required, but I have trouble with retrieving "id" variable from xml file and putting it into hyperlink

<?xml version="1.0" encoding="iso-8859-2"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:template match="/">
<html>
<body>
<h2>Job offers</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Employer</th>
<th align="left">Post</th>
<th align="left">Province</th>
</tr>
<xsl:for-each select="ADVERTISEMENTS/ADVERTISEMENT">
<tr>
<td><xsl:value-of select="EMPLOYER"/></td>
<td>
<a href="maintwo.php?id={id}">
<xsl:value-of select="POST"/></a></td>
<td><xsl:value-of select="WORKPLACE/PROVINCE"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

#xml and xsl file are loaded into main.php file to suit my web site, like this:

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<title>Job offers</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("jobs.xml")// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("template1.xsl")// Transform
document.write(xml.transformNode(xsl))</script>
</body>
</html>

# I only wonder why IE is the only browser that displays the results. Firefox, NN and Opera don't.

#Finally, I need to find out a way to display detailed description of particular job offer. And I have no idea how to do this, whether I should do this in a different file (as you can see, I'm trying to link to maintwo.php) or maybe I could just use different template and stick to the same php file.

Hoping someone can give me good tips how to cope with these problems.

Wiktor
 
ActiveXObjects are microsoft only, thus will only work in IE. To do client-side XSLT in Firefox, see:


However, if you are using PHP why not do the transformation server-side? This will make your pages cross-browser compatible and quicker loading:


Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
I am attempting to do something *extremely* similar, except that I am using C# to pass in the ID into the link, and then onto another page where only that particular node in the XML and its contents are displayed. I am also using XSLT on the second page to format the results.

Does anyone know if this is possible or not? Here's something of an example in order to illustrate what's going on. I'm completely stuck on trying to get it to display the appropriate info on the second page:

<!-- xml -->
<parent_node>
<title>Lots of stuff</title>
<child_node1 id="myfoo1">
<child_node1_child1>
stuff
<child_node1_child1_child1>more stuff</child_node1_child1_child1>
</child_node1_child1>
</child_node1>
<child_node2 id="myfoo2">
etc...
</child_node2>
</parent_node>

<!-- first page linking to the child nodes -->
<a href="mypage?id=myfoo1">stuff</a>

<!-- second page which only shows myfoo1 and identifying information on top -->
(title)Lots of stuff
(child_node1_child1)stuff
(child_node1_child1_child1)more stuff


Thanks in advance! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top