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 July 15th, 2004, 10:57 AM
Leetanker Leetanker is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 Leetanker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Trouble with something that seems so simple.

Please, could anyone explain to my brickheaded self what i'm doing wrong? Yes, i'm a newbie to xml. Heres my XML file:

<Results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xyz">
- <KeywordsRatingSet keywords="superbikes">
<Market>us</Market>
</KeywordsRatingSet>
- <ResultSet id="relatedSearchResults" numResults="20">
- <Category type="related">
<Search num="1">Superbike</Search>
<Search num="2">Used bike</Search>
<Search num="3">Sport bike</Search>
<Search num="4">Used dirt bike</Search>
<Search num="5">Dirt bike accessory</Search>
<Search num="6">Motor bike</Search>
<Search num="7">Dirt bike gear</Search>
<Search num="8">Performance bicycle</Search>
<Search num="9">Sportbikes</Search>
<Search num="10">World superbike</Search>
<Search num="11">Electric bicycle</Search>
<Search num="12">Bike race</Search>
<Search num="13">Used dirt bike for sale</Search>
<Search num="14">Sport bike part</Search>
<Search num="15">Sport bike picture</Search>
<Search num="16">Sport bike video</Search>
<Search num="17">Yamaha dirt bike</Search>
<Search num="18">Honda dirt bike</Search>
<Search num="19">Dirt bike part</Search>
<Search num="20">Sport bike accessory</Search>
</Category>
</ResultSet>
</Results>

And my XSLT file follows:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" />
<xsl:template match="/">
<xsl:apply-templates select="Results/ResultSet" />
</xsl:template>
<xsl:template match="Category">
<xsl:value-of select="Search" />
</xsl:template>
</xsl:stylesheet>

I never seem to get anything returned. I figure ive got my XSLT formatted incorrectly. Anyone straighten me out?

Reply With Quote
  #2  
Old July 16th, 2004, 04:43 AM
Miska's Avatar
Miska Miska is offline
Madden Maniac
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2001
Location: Finland
Posts: 519 Miska User rank is Lance Corporal (50 - 100 Reputation Level)Miska User rank is Lance Corporal (50 - 100 Reputation Level)Miska User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 47 m 50 sec
Reputation Power: 8
OK, so you are not cycling through the "search" -tags. Maybe this is what you are after:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<xsl:apply-templates select="Results/ResultSet" />
</xsl:template>
<xsl:template match="Category">
<xsl:for-each select="Search">
<xsl:value-of select="node()" /><br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Reply With Quote
  #3  
Old July 16th, 2004, 04:56 AM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 305 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 7 h 17 m 54 sec
Reputation Power: 7
One way is as follows:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />

<xsl:template match="/">
    <xsl:apply-templates select="/Results/ResultSet" />
</xsl:template>

<xsl:template match="/Results/ResultSet"> 
         <xsl:value-of select="Category" />
</xsl:template>

</xsl:stylesheet>


Another (and better) way is:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />

<xsl:template match="/">
    <xsl:apply-templates select="/Results/ResultSet" />
</xsl:template>

<xsl:template match="/Results/ResultSet"> 
    <xsl:for-each select="Category/Search"> 
        <xsl:value-of select="." />
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Reply With Quote
  #4  
Old July 16th, 2004, 09:06 AM
Leetanker Leetanker is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 Leetanker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Closer to a solution...

Thanks for the assistance guys, but I realized last nite that my problem was not with my XSLT stylesheet. There is a namespace involved with the original XML file, and upon removal of that namespace, all of my transforms work. Im gonna post a separate thread addressing this problem.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Trouble with something that seems so simple.


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 5 hosted by Hostway
Stay green...Green IT