[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] HTML Tags in XML


Subject: Re: [xsl] HTML Tags in XML
From: omprakash.v@xxxxxxxxxxxxx
Date: Thu, 4 May 2006 17:42:32 +0530

Hi,
         You say whatever is inside info will be html. Will it be valid
html. It is html for you but to the parser it is just tags. Things might be
different if your input xml was in a namespace. If the html is well-formed,
you can use the following xslt:

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

             <!--Look in the Results-->
             <xsl:template match="/">
                                        <xsl:apply-templates/>
                                 </xsl:template>

<xsl:template match="planets">
<head>
planets
</head>
<body>
<xsl:apply-templates/>
</body>

</xsl:template>

<xsl:template match="planet">
<h1><xsl:value-of select="Name"/></h1>
<xsl:apply-templates select="following-sibling::*[self::info][1]"/>
</xsl:template>

<xsl:template match="info">
<xsl:apply-templates>
</xsl:template>

<xsl:template match="info//*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

Hope this helps.

cheers,
prakash






                                                                                                                                   
                      "Neelima                                                                                                     
                      Adusumilli"                 To:      xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                         
                      <neelima.adusumilli         cc:      (bcc: omprakash.v/Polaris)                                              
                      @...>                 Subject: [xsl] HTML Tags in XML                                                  
                                                                                                                                   
                      05/04/2006 04:55 PM                                                                                          
                      Please respond to                                                                                            
                      xsl-list                                                                                                     
                                                                                                                                   
                                                                                                                                   




Hi all,
I have an XML file as follows:

<?xml version="1.0"?>
<planets>
   <planet>
      <Name>Mercury</Name>
      <info>
         <table>
            <tr>
              <td>Smallest Planet</td>
              <td>Closest to Sun</td>
            </tr>
         </table>
      </info>
   </planet>

   <planet>
       <Name>Earth</Name>
       <info> This is the planet we all live on </info>
   </planet>
</planets>

There is no particular pattern in info field.  But whatever is given
as the value of info, will be in html.

Is there a way to use XSL and generate the following html code...

<html>
   <head>
      Planets
   </head>
   <body>
      <h1>Mercury</h1>
      <table>
         <tr>
            <td>Smallest Planet</td>
            <td>Closest to Sun</td>
        </tr>
      </table>
      <h1>Earth</h1>
      This is the planet we all live on
   </body>
</html>

Can some body help me with this? I need to get the content/value of
<info> as it is (even though it is html) and put it in the resultant
html file using XSL.

Thanks,
Neelima





POLARIS, THE LEADER IN SPECIALITY APPLICATION DEVELOPMENT :
-------------------------------------------------------------

Polaris has been awarded the Leader in the category of "Speciality Application Development" among the Top 100 global Companies from Cyber Media Publications for the Year 2006.

-------------------------------------------------------------

This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in


Current Thread
Keywords