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 November 19th, 2007, 03:12 AM
Registered User
 
Join Date: Nov 2007
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.

 
Old November 19th, 2007, 05:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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
 
Old November 19th, 2007, 07:34 AM
Registered User
 
Join Date: Nov 2007
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'?>











 
Old November 19th, 2007, 07:53 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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
 
Old November 20th, 2007, 01:42 AM
Registered User
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






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





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