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, 07:05 AM
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 problem while converting xml to html

Hi
I am a newbie to XSLT.
I have got a xml file
of the kind

Code:
<layout>
    <frameset>
        <frame name="headerFrame" src="" size="200" resize="no"></frame>
        <frame name="menuFrame" src="" size="700" resize="no"></frame>
        .
        .
    </frameset>
</layout>
and i want to convert it to a html using a xsl file
i wrote a xsl:
Code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
 
<xsl:template match="/">
    <html>
    <head><title>Samsung OAMP</title></head>
    <frameset rows="200,700">
    <xsl:for-each select="layout/frameset/frame">
        <frame name="{@name}" src="{@src}" noresize="{@resize}"></frame>         
    </xsl:for-each>
    </frameset>
    </html>
</xsl:template>
</xsl:stylesheet>

problem is i am not succeeding without hardcoding the line
<frameset rows="200,700">
i want the rows/cols and sizes to be selected as in xml file

Any help will be appreciated.
well number of nodes is not large there will be only 4 frames
but might be organized in difft. difft. way


Reply With Quote
  #2 (permalink)  
Old May 30th, 2005, 10:42 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 2.0 you can write

<frameset rows="{string-join(layout/frameset/frame/@size, ',')}">

In 1.0 it's more long-winded:

<frameset>
  <xsl:attribute name="rows">
    <xsl:for-each select="layout/frameset/frame/@size">
      <xsl:value-of select="."/>
      <xsl:if test="position()!=last()">,</xsl:if>
    </xsl:for-each>
  </xsl:attribute>



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old May 30th, 2005, 09:13 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

Hi Michael
i tried it but it didnt work :-s
here is my code
Code:
<frameset>
    <xsl:if test="@split='rows'">
        <xsl:attribute name="rows">
            <xsl:for-each select="layout/frameset/frame/@size">
                <xsl:value-of select="."/>
                <xsl:if test="position()!=last()">,</xsl:if>
            </xsl:for-each>

        </xsl:attribute>
    </xsl:if>
Anyways I have added a split and sizes attribute in <frameset> to become a <frameset split="rows" sizes="200,200,600">
and then i m using
Code:
<xsl:attribute name="rows">
    <xsl:value-of select="@sizes"/>
</xsl:attribute>
which is working.

but in the xml file there may be nested <frameset> tags
can you show me a way how to handle nested tags please
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
Problem in transferring data into html from xml. Somesh C# 0 February 7th, 2007 07:43 AM
Problem in Converting xml to sgml pragneshpandya XML 0 November 27th, 2006 01:52 AM
Converting XML to XML (making element mandatory) boondocksaint20 XSLT 8 April 28th, 2006 10:54 AM
converting self-nested xml to html its_vippy XSLT 1 June 1st, 2005 04:47 AM
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 09:39 PM.


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