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 | 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 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.

Reply With Quote
  #2 (permalink)  
Old November 19th, 2007, 05:32 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

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
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'?>











Reply With Quote
  #4 (permalink)  
Old November 19th, 2007, 07:53 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

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
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.......

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
Error in loading XML. nikhil_vaghela XML 3 May 15th, 2008 08:19 AM
XML validation error alz6z XML 1 May 3rd, 2007 11:06 AM
XML document error jaffir BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 26th, 2005 12: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 12:16 AM



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


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