Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to include a html file into a xsl file

    Hi,

    I have transform the xml file to pure html so I general include statements won't work in html so I need to include html file via <xsl:value-of select"document('index.html')" /> but I'm getting error as Can not load requested doc: Connection refused. The file is the root even then I'm getting the same error. If I specify the path, then to I'm getting same error.
    So can any of you please tell me what's wrong and what is the solution.

    Thanks in advance.

    Regards,
    Rashmi

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,090
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Your value-of select must be a valid XML element of a specified node-set.

    Post your XML document and also your XSL, with a description of exactly what you're trying to accomplish.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    I was getting "connection refused" error because the html file created was not valid. I'm using redirect:write of xalan processor to write into a file. First I'm creating a html file and after in later part I want to include that html file into an onther html file. Since html file created is not well formed so I'm getting error. Here is the code where I'm writting into a html file, you see that all tags are closed but still when html is created all tags are not closed.
    Code:
    <!-- Generate the indexlink.htm file in this node -->
      <xsl:variable name="indexlink" select="'indexlink.htm'"/>
      <redirect:write select="$indexlink"> 
    
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                <td align="left" bgcolor="#003366" width="5">
                <xsl:if test="$online='T'">
                    <img src="/img/s.gif" width="5" height="1" alt="" />
                    </xsl:if>
                     <xsl:if test="$online='F'">
    		              <img  width="5" height="1" alt="" >
    		                <xsl:attribute name="src">
    						  <xsl:call-template name="getRelativeUrl">
    						    <xsl:with-param name="path">img/s.gif</xsl:with-param>
    						  </xsl:call-template>
    						 </xsl:attribute>	</img>		                
                    </xsl:if>
                    </td>
                    <td bgcolor="#003366">
                        <h2><span style="color:#FFFFFF;font-weight:bold">
                            Alphabetical index
                        </span></h2>
                    </td>
                </tr>
                <tr>
                    <td align="left" bgcolor="#DCDCDC" width="5">
                    <xsl:if test="$online='T'">
                                <img src="/img/s.gif" width="5" height="1" alt="" />
    		          </xsl:if>
    		                 <xsl:if test="$online='F'">
    				              <img  width="5" height="1" alt="" >
    				                <xsl:attribute name="src">
    								  <xsl:call-template name="getRelativeUrl">
    								    <xsl:with-param name="path">img/s.gif</xsl:with-param>
    								  </xsl:call-template>
    								 </xsl:attribute>	</img>		                
                    </xsl:if>                
                    </td>
                    <td valign="top" bgcolor="#DCDCDC">
                         <xsl:if test="$online='T'">
                    <img src="/img/s.gif" width="5" height="1" alt="" />
                    </xsl:if>
                     <xsl:if test="$online='F'">
    		              <img  width="5" height="1" alt="" >
    		                <xsl:attribute name="src">
    						  <xsl:call-template name="getRelativeUrl">
    						    <xsl:with-param name="path">img/s.gif</xsl:with-param>
    						  </xsl:call-template>
    						 </xsl:attribute>	</img>		                
                    </xsl:if><br />
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <!-- Loop through all the /category/children[@cat-label] nodes in index.XML -->
                            <xsl:for-each select="/category/children[@cat-label]/child">
                                <xsl:sort select="."/> <!-- Default order is ascending. -->
                                <xsl:variable name="showlink" select="@visible"/> <!-- holds the value of visible attribute -->
                                <xsl:variable name="index" select="."/> <!-- holds the value category node (e.g. A) -->
                                 <xsl:variable name="indexpath" select="@path"/>
                                <xsl:choose>
                                    <xsl:when test="$showlink='T'"> <!-- if showlink is true only then create hyperlink-->
                                        <td align="center">                   
                                            <xsl:if test="$index != '%'">
                                                <a class="udrline">  <!-- if category node length is 1 , then it is either of A...Z nodes -->
                                                    <xsl:if test="string-length(.) = '1'">
                                                        <xsl:attribute name="href"><xsl:if test = "$online = 'T' ">  <xsl:value-of select="concat('/',$short-name,'/library',$taxonomypath,'/',$indexpath,'/')"/> </xsl:if> 
                                                        <xsl:if test = "$online = 'F' "><xsl:value-of select="concat($relativepath,$taxonomypath,'/',$indexpath,'/index.htm')"/></xsl:if> 
                                                        </xsl:attribute>
                                                        <xsl:value-of select="$index"/>
                                                    </xsl:if>    
                                                </a>                                    
                                             </xsl:if>
                                        </td>    
                                    </xsl:when>
                                    <xsl:otherwise>  <!-- if showlink is false, then don't create hyperlinks -->
                                        <td align="center">
                                            <xsl:if test="$index != '%'"> <!-- if category name is % , don't display anything -->
    						<xsl:if test="string-length(.) = '1'">
    							<xsl:value-of select="$index"/>                                    
    						</xsl:if> 	
                                            </xsl:if>
                                        </td>    
                                    </xsl:otherwise> 
                                </xsl:choose>                                                            
                           </xsl:for-each>
                            
                            <!-- Handle % symbol case here. -->
                           <xsl:for-each select="/category/children[@cat-label]/child">
                                <xsl:variable name="showlink" select="@visible"/> <!-- holds the value of visible attribute -->
                                <xsl:variable name="index" select="."/> <!-- holds the value category node (e.g. A) -->
                                <xsl:variable name="indexpath" select="@path"/>
                               <xsl:choose>
                                        <xsl:when test="$showlink='T'"> <!-- if showlink is true only then create hyperlink-->
                                            <td align="center">                   
                                                <xsl:if test="$index = '%'">
                                                    <a class="udrline">  <!-- if category node length is 1 , then it is either of A...Z nodes -->
                                                        <xsl:if test="string-length(.) = '1'">
                                                            <xsl:attribute name="href"><xsl:if test = "$online = 'T' ">  <xsl:value-of select="concat('/',$short-name,'/library',$taxonomypath,'/',$indexpath,'/')"/> </xsl:if> 
                                                            <xsl:if test = "$online = 'F' "><xsl:value-of select="concat($relativepath,$taxonomypath,'/',$indexpath,'/index.htm')"/></xsl:if> 
                                                            </xsl:attribute>
                                                            <xsl:value-of select="$index"/>
                                                        </xsl:if>    
                                                    </a>                                    
                                                 </xsl:if>
                                            </td>    
                                        </xsl:when>
                                        <xsl:otherwise>  <!-- if showlink is false, then don't create hyperlinks -->
                                            <td align="center">
                                                <xsl:if test="$index = '%'"> <!-- if category name is % , don't display anything -->
                                                    <xsl:value-of select="$index"/>                                    
                                                </xsl:if>
                                            </td>    
                                        </xsl:otherwise> 
                                    </xsl:choose>        
                           </xsl:for-each>
                           <!-- End of creation of % node in the A...Z index -->  
                        </tr>
                    </table>
                   </td>
                </tr>
                <tr class="decoration" bgcolor="#DCDCDC"><td colspan="2">     <xsl:if test="$online='T'">
                    <img src="/img/s.gif" width="5" height="1" alt="" />
                    </xsl:if>
                     <xsl:if test="$online='F'">
    		              <img  width="5" height="1" alt="" >
    		                <xsl:attribute name="src">
    						  <xsl:call-template name="getRelativeUrl">
    						    <xsl:with-param name="path">img/s.gif</xsl:with-param>
    						  </xsl:call-template>
    						 </xsl:attribute>	</img>		                
                    </xsl:if></td></tr>
             </table> 
       </redirect:write>
    
       <!-- End of generation of indexlink.htm file -->
    The redirect write is also created a process instruction as"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">" , since a html which is also created by xml also as an process instruction already.

    please find the attached indexlink htm file along with is reply.

    Can any one please tell me how to create a well formed html file dynamically through xsl.

    Thanks in advance

    Regards,
    Rashmi
    Attached Files Attached Files
    Last edited by Alex Vincent; 01-06-2006 at 04:16 AM.

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Is it possible to write index.htm as well-formed XHTML instead? XSLT processors can convert XHTML to HTML via the <xsl:output/> tag, so the output isn't a problem.
    Last edited by Alex Vincent; 01-06-2006 at 04:16 AM.

  • #5
    New Coder
    Join Date
    Jan 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    How can I make my indexlink.htm as xhtml in xsl. I want a well-formed html file as I want the content to be included in the other html file through xsl and xsl expects a well formed file when including.

    Regards
    Rashmi

  • #6
    New Coder
    Join Date
    Jan 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    I added xmlns="http://www.w3.org/1999/xhtml" and now my html is well formed but xsl:output is added doctype processing instruction <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > and when my want to include one html into other html I'm getting error because of this processing instruction and if I remove this I'm able to include. I have to generate html file dynamically and xsl:output is adding processing instruction. Can any one please tell me how to avoid processing instruction so that I can include a html file.

    Thanks in advance.

    Regards,
    Rashmi
    Last edited by Alex Vincent; 01-07-2006 at 04:52 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •