Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Help With Xml+xslt Needed..., Im stuck with my exam...
finaldesign
post May 30 2005, 04:22 PM
Post #1


[+] Graphic Designer [+]
Group Icon

Group: Members
Posts: 614
Joined: 6-April 05
From: Croatia
Member No.: 3,666



Well, because of my work at design office, I stuck with my exam at colledge. It's an exam of XML. I must make an XML+XSLT compatible web site with 4 pages minimum, of description of how I did it. Now, I do not know much of XML, so if anyone here have some tutorials, ebooks, links that would help me, I would be eternaly gratefull... rolleyes.gif
Go to the top of the page
 
+Quote Post
hazeshow
post May 31 2005, 05:15 PM
Post #2


Premium Member
Group Icon

Group: Members
Posts: 230
Joined: 15-May 05
From: your sister
Member No.: 5,102



Hi,

perhaps this will help you: http://www.xml.com/pub/a/98/10/guide0.html

If you make a website using XML and XSLT you have to decide where and how the transformation into HTML is done, on the server or in the user's browser. MS Internet Explorer has an own XML-parser and an own way to treat XML/XSLT. Let's say you have am XML-file 'cool.xml' and you want to throw it against the stylesheet 'hot.xsl'. Internet Explorer will show the HTML-result with the following simple code included in an HTML-file:

<XML id="source" src="cool.xml"></XML>
<XML id="style" src="hot.xsl"></XML>

<script FOR="window" EVENT="onload">
xslTarget.innerHTML = source.transformNode(style.XMLDocument);
</SCRIPT>

<DIV id="xslTarget"></DIV>


In this case the transformation takes place in the user's browser and only works with Internet Explorer version 5.5 or higher. I once found this on Microsoft's website, and I think it's pretty cool but as far as I know it does not work with other browsers than IE.

If you want to let the transformation take place on the server, you need a server-sided script language like PHP. You can (if you can - I can't) write your own XML-parser in PHP or use the xslt_create()-function. For this XSLT-support has to be enabled (Sablotron).

Good luck and fun with your exam!

GreetingZ
Go to the top of the page
 
+Quote Post
finaldesign
post Jun 1 2005, 07:09 AM
Post #3


[+] Graphic Designer [+]
Group Icon

Group: Members
Posts: 614
Joined: 6-April 05
From: Croatia
Member No.: 3,666



QUOTE(hazeshow @ May 31 2005, 07:15 PM)
If you want to let the transformation take place on the server, you need a server-sided script language like PHP. You can (if you can - I can't) write your own XML-parser in PHP or use the xslt_create()-function. For this XSLT-support has to be enabled (Sablotron).

Good luck and fun with your exam!

GreetingZ
*



Thanks for the reply man, so it means that if I want transformation on the server side, I need to write XML-Parser... Isn't that already written by someone...? Do you know maybe is XSLT-support enabled on astahost servers? huh.gif
Go to the top of the page
 
+Quote Post
hazeshow
post Jun 1 2005, 02:06 PM
Post #4


Premium Member
Group Icon

Group: Members
Posts: 230
Joined: 15-May 05
From: your sister
Member No.: 5,102



Yes sure, XML-parser-scripts already exist, but I always found it too hard to implement them in my code. Might be easy for programming natures - but not for me. smile.gif

The astahost-server DOES support XSLT, see here:http://www.astahost.com/phpinfo.php
But it seems that for the user's website accounts the XSLT support first has to be implemented. I asked for it in the forum and one hour later I had my Sablotron.

As I said, I use the xslt_create()-function, it goes like this:

<?php
$xh = xslt_create();
if ($result = xslt_process($xh, 'cool.xml', 'hot.xsl')) {
echo $result;
xslt_free($xh);
}
else {
echo "<p>";
echo xslt_error($xh);
echo xslt_errno($xh);
echo "</p>";
xslt_free($xh);
}
?>


I'm telling you one thing .... this is sooo cool! cool.gif

GreetingZ
Go to the top of the page
 
+Quote Post
finaldesign
post Jun 2 2005, 09:59 AM
Post #5


[+] Graphic Designer [+]
Group Icon

Group: Members
Posts: 614
Joined: 6-April 05
From: Croatia
Member No.: 3,666



hey I still need some help with this... Ok I've managed to understand something, and make some xml files... but I dont understand if I make an XML document, then make one XSLT document so I can display properly and nice that XML...Now how can I use CSS in that XSLT document, and apply that CSS on XSLT elements... huh.gif

(if you don't understand exactly what I want I'll put a source Code here...)

thanks!
Go to the top of the page
 
+Quote Post
hazeshow
post Jun 2 2005, 01:28 PM
Post #6


Premium Member
Group Icon

Group: Members
Posts: 230
Joined: 15-May 05
From: your sister
Member No.: 5,102



Yes, that's it exactly! You create an XSL-document for displaying your XML-file in HTML. Your XSL-file IS the stylesheet, you could only use CSS INSTEAD of CSS.

Here's an example: You need three files: simple.php, simple.xml and simple.xsl. And you need a Server with XSLT-support. (By the way ... they must have rebooted the machines here at astahost, at the moment my account does not support XSLT) sad.gif

Ok, here comes the Belgian Waffels example:

simple.php

<?php
$xh = xslt_create();
if ($result = xslt_process($xh, 'simple.xml', 'simple.xsl')) {
echo $result;
xslt_free($xh);
}
else {
echo "<p>";
echo xslt_error($xh);
echo xslt_errno($xh);
echo "</p>";
xslt_free($xh);
}
?>



simple.xml

<?xml version='1.0'?>

<breakfast-menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles
with plenty of real maple syrup.</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles covered with
strawberries and whipped cream.</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>Light Belgian waffles covered
with an assortment of fresh berries
and whipped cream.</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>Thick slices made from our homemade
sourdough bread.</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage, toast,
and our ever-popular hash browns.</description>
<calories>950</calories>



simple.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt;
background-color:#EEEEEE">
<xsl:for-each select="breakfast-menu/food">
<DIV STYLE="background-color:teal; color:white; padding:4px">
<SPAN STYLE="font-weight:bold; color:white"><xsl:value-of select="name"/></SPAN>
- <xsl:value-of select="price"/>
</DIV>
<DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt">
<xsl:value-of select="description"/>
<SPAN STYLE="font-style:italic">
(<xsl:value-of select="calories"/> calories per serving)
</SPAN>
</DIV>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>


Try it out and play with it! Good luck! smile.gif
Go to the top of the page
 
+Quote Post
finaldesign
post Jun 2 2005, 02:02 PM
Post #7


[+] Graphic Designer [+]
Group Icon

Group: Members
Posts: 614
Joined: 6-April 05
From: Croatia
Member No.: 3,666



ohmy.gif thanks man! I'll try it that way... I hope I'll make what I want... wink.gif
Go to the top of the page
 
+Quote Post
finaldesign
post Jun 20 2005, 07:25 AM
Post #8


[+] Graphic Designer [+]
Group Icon

Group: Members
Posts: 614
Joined: 6-April 05
From: Croatia
Member No.: 3,666



hey I passed that exam, tongue.gif you can see what I did at this link:

My First XML cool.gif
Go to the top of the page
 
+Quote Post
hazeshow
post Jun 20 2005, 08:36 AM
Post #9


Premium Member
Group Icon

Group: Members
Posts: 230
Joined: 15-May 05
From: your sister
Member No.: 5,102



Hey ... wow! blink.gif ohmy.gif rolleyes.gif That XSLT-file must have been hard work! The xsl:for-each select and xsl:value-of select can drive someone crazy ...
Looks really good!

<congratulation>MY CONGRATULATIONS!</congratulation> smile.gif
Go to the top of the page
 
+Quote Post
finaldesign
post Jun 21 2005, 08:51 AM
Post #10


[+] Graphic Designer [+]
Group Icon

Group: Members
Posts: 614
Joined: 6-April 05
From: Croatia
Member No.: 3,666



yeah, well, after few hours of surfing and reading on other forums, I found a solution, In fact it's simple, just what you need to to is follow simple XML rules... I have them written in script of that Exam I took, so if anyone wants to know and learn more, just PM me...
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Netscapenav Display Problem << Guru Help Needed(2)
  2. Php: How To Make A Menu With Images ?(6)
  3. Css Vs Xslt Vs Smarty Vs Other : What To Use ?(3)
  4. Help Needed With Html, Css And Frames(10)
  5. Help Choose A New Banner For Me Please(11)


 



- Lo-Fi Version Time is now: 23rd November 2008 - 06:44 PM