Solved

xsl:Include

Posted on 2002-05-07
9
940 Views
Last Modified: 2013-11-18
I am trying to use xsl:include am am having no luck. Below are the two XSL Files (MAIN.XSL and HEADER.XSL) that i need assistance with.

MAIN.XSL
=================

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="page">
  <xsl:for-each select="element">
    <xsl:if test="type/text()='header'">
     <xsl:call-template name="header" />
    </xsl:if>
  </xsl:for-each>
 </xsl:template>
 <xsl:include href="header.xsl" />
</xsl:stylesheet>

HEADER.XSL
==================

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template name="header">
  <table width="100%" border="0">            
   <tr><td><img src="images/header_left.gif" /></td></tr>
  </table>
 </xsl:template>
</xsl:stylesheet>

=============================
The error message being returned is:

msxml4.dll (0x80004005)
The system cannot locate the object specified. Error occurred during compilation of included or imported stylesheet 'header.xsl'.

==============================

Please note that if i replace the line in MAIN.XSL:

<xsl:include href="header.xsl" />

With:

 <xsl:template name="header">
  <table width="100%" border="0">            
   <tr><td><img src="images/header_left.gif" /></td></tr>
  </table>
</xsl:template>

The transformation works perfectly.

Also note that MAIN.XSL & HEADER.XSL reside in the same directory.

Thanks


0
Comment
Question by:greenrc
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 6995686
how do you use the XSLT documents
==================================
Under VB, everything works fine with straight transforms as well as using the XSLTemplate

Under ASP, everything works fine with straight transforms as well as using the XSLTemplate

Under the client, everything works fine with straight transforms as well as using the XSLTemplate.

Tell me where and how are you getting the said error?
0
 

Author Comment

by:greenrc
ID: 6995752
I am transforming the files with the following ASP code:
=============================
Set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set pagexml = FSO.OpenTextFile(Server.MapPath("xml/page.xml"), ForReading, False, TristateTrue)
strXml = pagexml.ReadAll()
pagexml.close
oXmlDoc.loadXML strXml
oXmlDoc.setProperty "SelectionLanguage", "XPath"    

Set strXsl = FSO.OpenTextFile(Server.MapPath("xsl/page.xsl"), ForReading, False, TristateTrue)
oXslDoc.loadXML strXsl.ReadAll()
strXsl.close

PageHTML = oXmlDoc.transformNode(oXslDoc)

XML is as follows:
======================
<xml>
 <page>
  <element>
   <type>header</type>
  </element>
 </page>
</xml>
0
 

Author Comment

by:greenrc
ID: 6995753
Error is a server side ASP Transformation error.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:greenrc
ID: 6995761
Sorry XSL path S/B

Server.MapPath("xsl/main.xsl"), ....
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 100 total points
ID: 6995778
The ASP Code you used is incorrect.
===========================================
<%
Dim oXmlDoc, oXslDoc
Set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
oXmlDoc.async = False
oXslDoc.async = False
oXmlDoc.load Server.MapPath("xml/page.xml")
oXslDoc.load Server.MapPath("xsl.main.xsl")
oXmlDoc.transformNodeToObject oXslDoc, Response
Set oXmlDoc = Nothing
Set oXslDoc = Nothing
%>

Notes
=====
1. The problem with the linking is that you are using the FileSystemObject to load the file and pass it into a variable and then load it via the loadXML method. Now whenever documents are loaded via the loadXML method, the starting point of the url is taken from the existing asp  page and thus, it is looking for header.xsl in the same directory as the asp page.

2. By using the load method along with the Server.MapPath method, you will be using the url of the XSLT document as the starting point to find the included XSLT document.

Regards,

Brandon Driesen
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6995807
typo with path
====
<%
Dim oXmlDoc, oXslDoc
Set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
oXmlDoc.async = False
oXslDoc.async = False
oXmlDoc.load Server.MapPath("xml/page.xml")
oXslDoc.load Server.MapPath("xsl/main.xsl")
oXmlDoc.transformNodeToObject oXslDoc, Response
Set oXmlDoc = Nothing
Set oXslDoc = Nothing
%>
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6998846
green, it's been a while. Feedback please.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7004300
green, second call =)
0
 

Author Comment

by:greenrc
ID: 7021402
oXmlDoc.load works ... excellent!

Thanks again Brandon.


0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question