Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Xml Transformation

Posted on 2003-10-27
3
Medium Priority
?
259 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

609 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