Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 05-08-2007, 01:05 PM   #1 (permalink)
Registered User
 
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista


Want help with XML and XSL

I am doing a table which displays the content of an XML document using XSL. The code is supposed to iterate throught the XML document and display all the XML data. I only get the first "record" from the XML file displayed in the table. Maybe the IE browser I am using doesn't support XSL?... But I get the same result with Firefox! I am not sure what version IE is-how can I find out? Also, what HTML code do I need to set the works in motion? Many thanks to any one who can help me!!
BrentC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 05-08-2007, 07:53 PM   #2 (permalink)
Registered User
 
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista


Re: Want help with XML and XSL

OK...I have the following XML code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="clients.xsl"?>

<body>
<clientstatus>
<client>
<name>Brent</name>
<team>A</team>
<bathroom>Week 2</bathroom>
<otherchores>Yard Work</otherchores>
</client>

I then have the following XSL code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "InternalNote.dtd">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="clientstatus">

<html>
.
.
.
some Javascript to open the XML file...It works!

now the following XSL code...

<UL>
<xsl:for-each select="client">
<li><xsl:value-of select="name"/></li>
<xsl:for-each>
</UL>


I get only the table headers but no XML info . I have tried various ways to do it, but to no avail.

Question: Do I have to put the XSL in a .xsl file and load it in a .html file or what? I tried that too...

Many thanks for your help

BrentC
BrentC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-09-2007, 06:04 PM   #3 (permalink)
Registered User
 
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista


Re: Want help with XML and XSL

Now...I'm going back to plain html with styles and javascript. Thanks

BrentC
BrentC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-10-2007, 01:13 AM   #4 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 139
OS: xp


Re: Want help with XML and XSL

Hi BrentC

Sorry to see you've given up on it. But for what it's worth here's a few pointers. Personally I'd stick with it, xml/xsl is so much more powerful than just using CSS alone.

Firefox has support for XML and XSLT from version 1.0.2.
Internet Explorer supports XML, Namespaces, CSS, XSLT, and XPath from version 6.
To get version of IE - Help/About Internet Explorer

Here's how your xml should be (clients.xml)

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="clients.xsl"?>

<clientstatus>
<client>
<name>Brent</name>
<team>A</team>
<bathroom>Week 2</bathroom>
<otherchores>Yard Work</otherchores>
</client>
<client>
<name>John</name>
<team>B</team>
<bathroom>Week 3</bathroom>
<otherchores>Milking the hamster</otherchores>
</client>
</clientstatus>

No <body> in there as I'm assuming you mean that as an html body. That belongs in your xsl.

and for clients.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="clientstatus">
<html>
<body>
<UL>
<xsl:apply-templates />
</UL>
</body>
</html>
</xsl:template>

<xsl:template match="client">
<li><xsl:value-of select="name"/></li>
</xsl:template>

</xsl:stylesheet>

While you're experimenting/learning/debugging with xsl I'd advise you forget loading with Java etc. It's not neccessary. Just 'hard wire' the transform you want to use straight into your xml. That way you don't have to trap and report errors. IE will do it for you. Just double click your xml file and IE will load it and apply the transform and display your (x)html.

Cheers
__________________
Bang head on keyboard to continue...
stirling is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-10-2007, 06:20 PM   #5 (permalink)
Registered User
 
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista


Re: Want help with XML and XSL

I'm not sure what you mean by a transform... I tried a Java transform in the html file like this...

document.write(xml.transformNode(xsl))

but you said not to use it so what do i emplement?

Thanks again,

BrentC
BrentC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-11-2007, 02:24 AM   #6 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 139
OS: xp


Re: Want help with XML and XSL

As you know, when you load an HTML file into IE, it displays it according to the rules of html.

And as you also know when you put a line like <link rel="stylesheet" type="text/css" href="mystyle.css" /> in your HTML you're telling IE to apply an external CSS document to the HTML and display the resultant "transform" (or in better English, the "transformation").

Similarly you can load an XML file into IE just as you would an HTML file. The only problem is that IE can only do two things with an XML document. It can check that it's "good" and it can pretty print it. (try it with any old xml file).

However just as with CSS if you "link" to an XSL file with a line like <?xml-stylesheet type="text/xsl" href="clients.xsl"?> then IE will apply the XSL to the XML. (i.e. all the code is in there for you courtesy Mr. Gates - no java required)

And here's the good bit in a case like you're doing. If you write the XSL such that it "transforms" the XML into HTML (actually it's XHTML) then IE will display it just as you want.

The real killer though is that you get pretty good error reporting from IE so you can concentrate on getting you're XML and XSL as you want it without frigging about with java error handling yourself.

Once you've got the hang of XML and XSL, then you can start doing the fancy stuff in java.

Just a quick note: HTML can be and usually is badly written and it will still work in IE. you know the sort of stuff, missing closing tags etc. That's cos Bill knows most web programmers wern't allowed to hand out the scissors at school (mind you - he shouldn't have been allowed to either). XML HAS TO BE CORRECT or IE (and every other xml enabled app) will kick it out - it's the law.
__________________
Bang head on keyboard to continue...
stirling is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-11-2007, 05:58 PM   #7 (permalink)
Registered User
 
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista


Re: Want help with XML and XSL

Thanks Stirling for your patience..I put the following code you gave me in the .xsl file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="clientstatus">
<html>
<body>
<UL>
<xsl:apply-templates />
</UL>
</body>
</html>
</xsl:template>

<xsl:template match="client">
<li><xsl:value-of select="name"/></li>
</xsl:template>

</xsl:stylesheet>

I then clicked on the XML file and IE said it couldn't load the XML file...I couldn't find what version of IE I'm using but I am using Windows ME...could that be the problem??

BrentC
BrentC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-12-2007, 05:47 PM   #8 (permalink)
Registered User
 
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista


Re: Want help with XML and XSL

Hey Stirling...I GOT IT !!! Thank you so much. I might need in future so stick around..

Bye for now

BrentC
BrentC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-14-2007, 02:48 AM   #9 (permalink)
Registered User
 
Join Date: Jan 2007
Posts: 139
OS: xp


Re: Want help with XML and XSL

no problem
__________________
Bang head on keyboard to continue...
stirling is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 01:55 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85