?
Solved

Xml Transformation

Posted on 2003-10-27
3
Medium Priority
?
258 Views
Last Modified: 2010-04-06
hi,
i want to transform the xml document to html using xsl stylesheets...
but i could not get the data from xml doc properly..
pls let me know wht to be added in my code...

here is my xml dox named myxml.xml...
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="my.xsl"?>
<catalog>
<item name="Wondernut chrome" finish="chrome" locking="yes" quantity="4">
<description>Add a touch of security and style  with these lugnuts</description>
<threadsizelist>
   <threadsize>3/8-24</threadsize>
   <threadsize>7/16-20</threadsize>
   <threadsize>10mm*1.25</threadsize>
   <threadsize>12mm*1.25</threadsize>
</threadsizelist>

<wheelcompatibilty>
    <make>Aardwheels</make>
    <make>Chromeover</make>      
</wheelcompatibilty>

<wheelcompatibilty>
    <make>ZooSpokes</make>
   
</wheelcompatibilty>

<carcompatibilty make="ABC motarworks" year="all"></carcompatibilty>
<carcompatibilty mKE="yOGEU" year="1987-1988"></carcompatibilty>

<Keywordlist>
   <keyword>lugnut</keyword>
   <keyword>lug nuts</keyword>
   <keyword>siler</keyword>
   <keyword>shiny</keyword>

</Keywordlist>
<price amount="20" currency="$US" tax="0%"></price>
<shipping cost="5" currency="$US" surcharges=""></shipping>

</item>
</catalog>

And my xsl stylesheet is...

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:output method="xml"/>
<xsl:template match="/">

<html>
 <head><title>Lydia's Lugnuts</title></head>

<BODY>
 
 <Table border="1">
   <tr>
    <td valign="top">
           <p>Lydia's Lugnuts current offerings:</p>
      <A href="locking.html">MoreLocking Nuts</A><BR/>
      <A href="exotic.html"> exotic Nuts</A><BR/>
      <A href="basic.html">Basic Nuts</A><BR/>
   </td>

   <td>
      <xsl:for-each select="">
            <p><xsl:value-of select="."/></p>
      </xsl:for-each>
   </td>
  </tr>
</Table>


Copywright Lydia's Lugnuts

</BODY>
</html>
</xsl:template>
</xsl:stylesheet>...


pls help me how to transform the xml doc into html...
Thanks in Advance
Archana
0
Comment
Question by:archanamanju
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
ericsDev earned 100 total points
ID: 9669225
try this XSL, works here with the XML you posted:

XSL : play3.xsl
----------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="catalog">
            <html>
                  <head>
                        <title>Lydia's Lugnuts</title>
                  </head>
                  <BODY>
                        <Table border="1">
                              <tr>
                                    <td valign="top">
                                          <p>Lydia's Lugnuts current offerings:</p>
                                          <A href="locking.html">MoreLocking Nuts</A>
                                          <BR/>
                                          <A href="exotic.html"> exotic Nuts</A>
                                          <BR/>
                                          <A href="basic.html">Basic Nuts</A>
                                          <BR/>
                                    </td>
                                    <td>
                                          <xsl:for-each select="item">
                              Name: <xsl:value-of select="@name"/>
                                                <br/>
                              Finish: <xsl:value-of select="@finish"/>
                                                <br/>
                              Locking: <xsl:value-of select="@locking"/>
                                                <br/>
                              Quantity: <xsl:value-of select="@quantity"/>
                                                <br/>
                              -----------------------------<br/>
                              Price Info:<br/>
                              Price: <xsl:value-of select="price/@amount"/>
                                                <br/>
                              Currency: <xsl:value-of select="price/@currency"/>
                                                <br/>
                              Tax: <xsl:value-of select="price/@tax"/>
                                                <br/>
                              -----------------------------<br/>
                              Shipping  Info:<br/>
                              Cost: <xsl:value-of select="shipping/@cost"/>
                                                <br/>
                              Currency: <xsl:value-of select="shipping/@currency"/>
                                                <br/>
                              Surcharges: <xsl:value-of select="shipping/@surcharges"/>
                                                <br/>
                              -----------------------------<br/>
                              Description:<br/>
                                                <xsl:value-of select="description"/>
                                                <br/>
                              -----------------------------<br/>
                              Thread Sizes:<br/>
                                                <xsl:for-each select="threadsizelist/threadsize">
                                                      <xsl:value-of select="."/>
                                                      <br/>
                                                </xsl:for-each>
                              -----------------------------<br/>
                              Wheel Compatibility:<br/>
                                                <xsl:for-each select="wheelcompatibilty">
                                                      <xsl:for-each select="make">
                                          Make: <xsl:value-of select="."/>
                                                            <br/>
                                                      </xsl:for-each>
                                                </xsl:for-each>
                              -----------------------------<br/>
                              Car Compatibility:<br/>
                                                <xsl:for-each select="carcompatibilty">
                                    Make: <xsl:value-of select="@make"/>
                                                      <br/>
                                    Year: <xsl:value-of select="@year"/>
                                                      <br/>
                                                </xsl:for-each>
                              -----------------------------<br/>
                              Keyword List:<br/>
                                                <xsl:for-each select="Keywordlist/keyword">
                                                      <xsl:value-of select="."/>
                                                      <br/>
                                                </xsl:for-each>
                                          </xsl:for-each>
                                    </td>
                              </tr>
                        </Table>
                  </BODY>
            </html>
      </xsl:template>
</xsl:stylesheet>
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question