Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 30th, 2005, 09:56 PM
Registered User
 
Join Date: May 2005
Location: , , .
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



Reply With Quote
  #2 (permalink)  
Old June 1st, 2005, 04:47 AM
Authorized User
 
Join Date: Jul 2004
Location: Oxford, , United Kingdom.
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>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:10 AM.


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