XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 13th, 2004, 07:18 AM
tibmeister tibmeister is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 14 tibmeister User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XML/XSL -> HTML problem

Having some small issues. I get an XML file as an on-line feed, and I would like to transform it. Here's an example of what it looks like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<feed ver="2.0">
<head>
<name>My Name</name>
<ident>5485858</name>
</head>
<cc>
<locale>Home</locale>
<date>5/24/04</date>
</cc>
</feed>

This is just an example now
Anyway, I only need the "//feed/head/name" and "//feed/cc/locale" portions of this document, everything else can go to the wayside. Here's what my XSL looks like:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslutput method="html" indent="yes" />

<xsl:template match="feed">
<html><head><title>Current Feed</title></head>
<body><table border='1'><xsl:apply-templates/></table></body></html>
</xsl:template>

<xsl:template match="head/name">
<tr><td><xsl:apply-templates/></td></tr>
</xsl:template>

<xsl:template match="cc/locale">
<tr><td><xsl:apply-templates/></td></tr>
</xsl:template>

</xsl:stylesheet>

This does work, but the remainder of the XMl doc is just thrown into the top of the HTML page as garbage. Is there anyway for it to just not display this?

Thanks

Reply With Quote
  #2  
Old May 13th, 2004, 08:28 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
Just throw in the following template:
Code:
<xsl:template match="/">
     <xsl:apply-templates/>
</xsl:template>


Let me know if that works, I didn't test anything.

Reply With Quote
  #3  
Old May 13th, 2004, 08:46 AM
tibmeister tibmeister is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 14 tibmeister User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for the quick response Matt, unfortunatly it seems to not have made a difference. I'm now also running into the problem of how to do columns in this thing, instead of each element in it's own row, put them in one row with two columns. XSL is not as easy as it's made out to be. Here is what my XSL file looks like now:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslutput method="html" indent="yes" />

<xsl:template match="/">
<html><head><title>Current Feed</title></head>
<body><table border='1'><xsl:apply-templates/></table></body></html>
</xsl:template>

<xsl:template match="head/name">
<tr><td><xsl:apply-templates/></td></tr>
</xsl:template>

<xsl:template match="cc/locale">
<tr><td><xsl:apply-templates/></td></tr>
</xsl:template>

</xsl:stylesheet>

Thank you again,
tibmeister

Reply With Quote
  #4  
Old May 13th, 2004, 08:56 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
This works (tested):
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
<html><head><title>Current Feed</title></head>
<body><table border="1">
<xsl:apply-templates select="feed/head/name"/>
<xsl:apply-templates select="feed/cc/locale"/>
</table></body></html>
</xsl:template>

<xsl:template match="name">
<tr><td><xsl:value-of select="."/></td></tr>
</xsl:template>

<xsl:template match="locale">
<tr><td><xsl:value-of select="."/></td></tr>
</xsl:template>

</xsl:stylesheet>

Reply With Quote
  #5  
Old May 13th, 2004, 09:06 AM
tibmeister tibmeister is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 14 tibmeister User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It was the select part that I couldn't find! Thank you soo much! no onto the next problem (the socond one I mentioned)

Thank you,
tibmeister

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML/XSL -> HTML problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT