DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Please, Could you tell me what' wrong in it?

  1. #1
    Rajesh Guest

    Please, Could you tell me what' wrong in it?


    Hi,

    I am a beginner for XML. I tried to attach XSL to XML documents. could you
    tell me what is wroing in the following example.
    -------------------------------------------------------------
    This is XML document.
    -------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type = "text/xsl" href="c:\rajesh\xml\xsl\XSL1Email.xsl"?>

    <E_Mail xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Rajesh\XML\XSD\XSD1Email.xsd">
    <To>Tom</To>
    <From>Rajesh Patel</From>
    <Subject>No subject</Subject>
    <Message>This is practice of XML</Message>
    </E_Mail>
    -------------------------------------------------------------
    This is XSL document.
    -------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/wd-xsl">
    <table border="2" bgcolor="yellow">
    <tbody>
    <tr>
    <th>Email</th>
    </tr>
    <xsl:for-each select="E_mail">
    <tr>
    <td><xsl:value-of select="To"/></td>
    </tr>
    <tr>
    <td><xsl:value-of select="From"/></td>
    </tr>
    <tr>
    <td><xsl:value-of select="Subject"/></td>
    </tr>
    <tr>
    <td><xsl:value-of select="Message"/></td>
    </tr>
    </xsl:for-each>
    </tbody>
    </table>
    </xsl:stylesheet>
    -------------------------------------------------------------

    I would like to get result like

    EMail
    Tom
    Rajesh Patel
    No Subject
    This is practice of XML


    Thanks for helping me.

    Rajesh Patel

  2. #2
    David Tjandra Guest

    Re: Please, Could you tell me what' wrong in it?

    Dear Rajesh,

    Try this xsl code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/" >
    <table border="2" bgcolor="yellow">
    <tbody>
    <tr><th>Email</th></tr>
    <xsl:for-each select="*">
    <tr>
    <td><xsl:value-of select="To"/></td>
    </tr>
    <tr>
    <td><xsl:value-of select="./From"/></td>
    </tr>
    <tr>
    <td><xsl:value-of select="./Subject"/></td>
    </tr>
    <tr>
    <td><xsl:value-of select="./Message"/></td>
    </tr>
    </xsl:for-each>
    </tbody>
    </table>
    </xsl:template >
    </xsl:stylesheet>

    Regards,
    David Tjandra

    "Rajesh" <rajeshp@nexustelecom.com> wrote in message
    news:3d7e0bdc$1@10.1.10.29...
    >
    > Hi,
    >
    > I am a beginner for XML. I tried to attach XSL to XML documents. could you
    > tell me what is wroing in the following example.
    > -------------------------------------------------------------
    > This is XML document.
    > -------------------------------------------------------------
    > <?xml version="1.0" encoding="UTF-8"?>
    > <?xml-stylesheet type = "text/xsl"

    href="c:\rajesh\xml\xsl\XSL1Email.xsl"?>
    >
    > <E_Mail xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:noNamespaceSchemaLocation="C:\Rajesh\XML\XSD\XSD1Email.xsd">
    > <To>Tom</To>
    > <From>Rajesh Patel</From>
    > <Subject>No subject</Subject>
    > <Message>This is practice of XML</Message>
    > </E_Mail>
    > -------------------------------------------------------------
    > This is XSL document.
    > -------------------------------------------------------------
    > <?xml version="1.0" encoding="UTF-8"?>
    > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/wd-xsl">
    > <table border="2" bgcolor="yellow">
    > <tbody>
    > <tr>
    > <th>Email</th>
    > </tr>
    > <xsl:for-each select="E_mail">
    > <tr>
    > <td><xsl:value-of select="To"/></td>
    > </tr>
    > <tr>
    > <td><xsl:value-of select="From"/></td>
    > </tr>
    > <tr>
    > <td><xsl:value-of select="Subject"/></td>
    > </tr>
    > <tr>
    > <td><xsl:value-of select="Message"/></td>
    > </tr>
    > </xsl:for-each>
    > </tbody>
    > </table>
    > </xsl:stylesheet>
    > -------------------------------------------------------------
    >
    > I would like to get result like
    >
    > EMail
    > Tom
    > Rajesh Patel
    > No Subject
    > This is practice of XML
    >
    >
    > Thanks for helping me.
    >
    > Rajesh Patel




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center