...

View Full Version : How to include a html file into a xsl file



Rashmir
12-19-2005, 07:18 AM
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

vinyl-junkie
12-19-2005, 06:16 PM
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.

Rashmir
01-05-2006, 11:02 AM
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.


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

jkd
01-05-2006, 02:27 PM
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.

Rashmir
01-06-2006, 02:34 AM
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

Rashmir
01-06-2006, 11:04 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum