p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XSLT
I forgot my password Register Now
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 19th, 2007, 03:12 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default get error while tranform blank xml

I am getting error while tranforming xml by XSLT when xml file having rowset with no rows.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old November 19th, 2007, 05:32 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

And I suppose you expect me to tell you that your mistake is a missing closing bracket on line 126 of your stylesheet.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old November 19th, 2007, 07:34 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

my xml source is like :

 <?xml version="1.0" encoding="WINDOWS-1252" ?>
- <page>
  <rowset />
  </page>

and XSL is like :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>

<xsl:key name="cd-by-network" match="ROW" use="NETWORK_NAME" />
<xsl:key name="cd-by-show" match="ROW" use="BASIS_NUMBER" />
<xsl:key name="cd-by-seg" match="ROW" use="SEG" />
<xsl:template match="ROWSET/ROW">
<xsl:for-each select="current()[generate-id()=generate-id(key('cd-by-network',NETWORK_NAME)[1])]">
   <ws_structure_import network_name="{NETWORK_NAME}" broadcast_Date="{BROADCAST_DATE}" schedule_name="{SCHEDULE_NAME}" >
   <xsl:for-each select="key('cd-by-network', NETWORK_NAME)">

      <xsl:for-each select="current()[generate-id()=generate-id(key('cd-by-show',BASIS_NUMBER)[1])]">

        <show basis_number="{BASIS_NUMBER}" program_title="{PROGRAM_TITLE}" start_time="{START_TIME}">
            <xsl:for-each select="key('cd-by-show', BASIS_NUMBER)">

              <xsl:for-each select="current()[generate-id()=generate-id(key('cd-by-seg',SEG)[1])]">

               <segment sort_col="{SORT_COL}" segment_no="{SEGMENT_NO}">
                  <xsl:for-each select="key('cd-by-seg', SEG)">
                    <avail pos_in_seg="{POS_IN_SEG}" record_type="{RECORD_TYPE}" avail_type="{AVAIL_TYPE}" duration="{DURATION}" />
                </xsl:for-each>
               </segment>
            </xsl:for-each>
        </xsl:for-each>
       </show>
     </xsl:for-each>
    </xsl:for-each>
   </ws_structure_import>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>


   Suppose I am having rows under rowset then I get proper result. But in case of zero rows getting following error:



The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


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

Invalid at the top level of the document. Error processing resource 'http://localhost:8080/ASM/getFormat.xsql?bdate=2007111...

<?xml version = '1.0'?>











Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old November 19th, 2007, 07:53 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

When you use XSLT to generate XML, there is no guarantee that the resulting XML will be well-formed, that is, that it will have a single element node as the document element. You can generate XML with no top-level elements or with multiple top-level elements. If you do that (as you have done) then IE will not be able to display it. It's best always to generate well-formed XML, which you can do by adding the template rule:

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

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old November 20th, 2007, 01:42 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot Michael .............
its working now.......

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in loading XML. nikhil_vaghela XML 3 May 15th, 2008 09:19 AM
XML validation error alz6z XML 1 May 3rd, 2007 12:06 PM
XML document error jaffir BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 26th, 2005 01:21 PM
XML error roopa4all BOOK: ASP.NET Website Programming Problem-Design-Solution 1 December 26th, 2004 05:03 PM
xml validation error kreddy XML 0 August 20th, 2003 01:16 AM



All times are GMT -4. The time now is 01:03 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc