Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2005, 09:56 PM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to its_vippy
Default converting self-nested xml to html

Hi
My xml file is
Code:
<layout>
    <frameset split="rows" sizes="200,200,600">
        <frame name="headerFrame" size="200" src="" resize="false"></frame>
        <frame name="menuFrame" size="200" src=""  resize="false"></frame>
        <frame name="downFrame" size="600" src=""  resize="false"></frame>
    </frameset>
</layout>
and i m using a xsl to convert it to html frameset which is :
Code:
<xsl:template match="/">
    <html>
    <head><title>Samsung OAMP</title></head>

        <xsl:apply-templates select="/layout/frameset" />

    </html>
</xsl:template>
<xsl:template match="frameset">
<frameset>
    <xsl:if test="@split='rows'">
        <xsl:attribute name="rows">
            <xsl:value-of select="@sizes"/>
        </xsl:attribute>
    </xsl:if>
    <xsl:if test="@split='cols'">
        <xsl:attribute name="cols">
            <xsl:value-of select="@sizes"/>
        </xsl:attribute>
    </xsl:if>
        <xsl:for-each select="frame">
            <frame name="{@name}" src="{@src}" noresize="{@resize}"></frame>         
        </xsl:for-each>
    </frameset>
</xsl:template>
the problem is if i change xml file to have <frameset> within another <frameset>like
Code:
<frameset>
<frame></frame>
<frame></frame>
<frameset></frameset>
</frameset>
what changes should i make in xml file
Any help is appreciated



 
Old June 1st, 2005, 04:47 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try the following:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/">
      <html>
         <head>
            <title>Samsung OAMP</title>
         </head>

         <xsl:apply-templates select="/layout/frameset" />
      </html>
   </xsl:template>

   <xsl:template match="frameset">
      <frameset>
         <xsl:if test="@split='rows'">
            <xsl:attribute name="rows">
               <xsl:value-of select="@sizes" />
            </xsl:attribute>
         </xsl:if>

         <xsl:if test="@split='cols'">
            <xsl:attribute name="cols">
               <xsl:value-of select="@sizes" />
            </xsl:attribute>
         </xsl:if>

         <xsl:apply-templates />
      </frameset>
   </xsl:template>

   <xsl:template match="frame">
        <frame name="{@name}" src="{@src}" noresize="{@resize}">
            <xsl:apply-templates />
        </frame>
   </xsl:template>

</xsl:stylesheet>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting PDF to HTML sunil.konduri C# 2005 1 July 11th, 2008 07:34 AM
Converting Source Xml into Target Xml Using XSL. alapati.sasi XSLT 3 May 14th, 2007 10:54 AM
Converting XML to XML (making element mandatory) boondocksaint20 XSLT 8 April 28th, 2006 10:54 AM
problem while converting xml to html its_vippy XSLT 2 May 30th, 2005 09:13 PM
Converting an XML File into a HTML File ewan XSLT 2 October 4th, 2004 09:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.