Jump to content
xisto Community
Sign in to follow this  
finaldesign1405241487

Help With Xml+xslt Needed... Im stuck with my exam...

Recommended Posts

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... :D

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

<{POST_SNAPBACK}>


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 Xisto servers? :D

Share this post


Link to post
Share on other sites

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. :D

 

The Xisto-server DOES support XSLT, see here:http://forums.xisto.com/

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! :D

 

GreetingZ

Share this post


Link to post
Share on other sites

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... :D (if you don't understand exactly what I want I'll put a source Code here...)thanks!

Share this post


Link to post
Share on other sites

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 Xisto, at the moment my account does not support XSLT) :D

 

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://forums.xisto.com/no_longer_exists/;

<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! :D

Share this post


Link to post
Share on other sites

Hey ... wow! :lol::D:lol: 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> :lol:

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.