xsl-list
[Top] [All Lists]

[xsl] Dynamic creation of Frame view from XML using XSLT Regex match!

2007-09-09 10:42:24
Hi All,

Following is the brief problem description:
-------------------------------------------

i) Need to create a normal Frame based html view (left
index frame + right content frame) 

ii) The main content (right frame) is generated by
rendering a XML document using xsl transformation

iii) At the same time the left frame should be
populated based on certain TAG name matches from the
same XML document which in turn would be hyperlinks to
the main content frame

For eg) the html should look like:
-----------------------------------
======================================
T_SYS | T_SYS                         
T_MB  | --html table for t_sys here
      | --
      | --
      | T_MB
      | --html table for t_mb here
======================================


The format of the XML document is:
----------------------------------
<XMLDOC>

<T_SYS>

   <T_SYS_ROW>
   <acol> aval </acol>
   <bcol> bval </bcol>
   <T_SYS_ROW>

   <T_SYS_ROW>
   <acol> aval </acol>
   <bcol> bval </bcol>
   </T_SYS_ROW>

</T_SYS>

<T_MB>

   <T_MB_ROW>
   <acol> aval </acol>
   <bcol> bval </bcol>
   </T_MB_ROW>

   <T_MB_ROW>
   <acol> aval </acol>
   <bcol> bval </bcol>
   </T_MB_ROW>

</T_MB>

</XMLDOC>

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

The XSL currently applied (for content rendering) is:
--------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
 xmlns="http://www.w3.org/1999/xhtml";
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

   <xsl:output method="xml" version="1.0"
encoding="utf-8" indent="yes"
     doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
      
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

<xsl:template match="/*">
   <html>
      <head>
          <title><xsl:value-of
select="name()"/></title>
              <style type="text/css">
        table { font-family: Arial, sans-serif; }
        th { font-size: 75%; background: #4D5D97;
color: #FFFFFF; }
        td { vertical-align: top; }
        .odd { background: #E3E4FA; }
        .evn { background: #E7ECF0; }
              </style>
        </head>
         <body>
<xsl:for-each select="/*/*">
        <h1><xsl:value-of select="name()"/></h1>
         <xsl:apply-templates select="."
mode="table"/>
</xsl:for-each>
        </body>
  </html>
 </xsl:template>

<xsl:template match="*" mode="table">
<table border="0">
<tr>
<xsl:apply-templates
select="*[1]/descendant::*[not(*)]" mode="th"/>
</tr>
<xsl:apply-templates select="*" mode="tr"/>
</table>
</xsl:template>

<xsl:template match="*" mode="th">
   <th><xsl:value-of select="name()"/></th>
</xsl:template>

 <xsl:template match="*" mode="tr">
   <xsl:variable name="class">
      <xsl:choose>
          <xsl:when test="(position() mod 2 =
1)">odd</xsl:when>
              <xsl:otherwise>evn</xsl:otherwise>
                 </xsl:choose>
                   </xsl:variable>
                        <tr class="{$class}">
                        <xsl:apply-templates
select="descendant::*[not(*)]" mode="td"/>
                          </tr>
</xsl:template>

<xsl:template match="*" mode="td">
  <td><xsl:value-of select="."/></td>
</xsl:template>


</xsl:stylesheet>

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

Kindly let me know how to achieve the final output.

thanks
Sreejith



       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--